on 10-25-2013 4:22 PM
Hi all,
I am using release 64 HANA SPS 6.
I have a question on how to compare array elements. Here is what I have so far:
1) Used array_agg to get two columns of a table
2) I iterate over those, and compare values in Column A to Column B
IF :a[:i] = :b[:i] then ....
END IF.
However, I get an error saying array A comparison with array B is not supported. (note that both are NVARCHAR(12) arrays)
3) I tried to assign the values to two scalars, so as to compare the scalars thereafter, but converting ONE value in an array to a scalar is not supported either.
Any pointers on how to go about comparing values in arrays ?
Does anyone have a working example of array processing ? (beyond just "array_agg" and "unnest" ? )
Regards,
Andy Anand
Hi Andy,
Did you find a way to read an array element into a scalar?
According to the SQL script guide linked to above, section 7.7.4 "RETURN AN ELEMENT OF AN ARRAY" says that this sort of code should work:
CREATE PROCEDURE test (OUT output integer) READS SQL DATA AS
BEGIN
DECLARE id INTEGER ARRAY := ARRAY(1, 2, 3);
DECLARE n INTEGER := 1;
output := :id[:n];
END;
I am using SPS06 and Studio Rev 62 and the above code does not compile. It complains about this line, saying that the "[" is misplaced:
output := :id[:n];
Thanks,
Kevin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please see if following document gives you some help.
See page 73 from the reference guide.
http://help.sap.com/hana/SAP_HANA_SQL_Script_Reference_en.pdf
BR
Prabhith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.