on 01-29-2015 1:24 PM
Dear all,
I am trying to write an select in a For - loop . The procedure logic looks like blow.The procedure pass the compile. But when I call the procedure , the error shows SAP DBTech JDBC: [1287]: identifier must be declared: K . which I had declared.
If i delete "TAB2 = " in the loop, it's fine.
CREATE COLUMN TABLE TRAFFIC.TTEST(
AB1 INT,
AB2 INT
);
INSERT INTO TRAFFIC.TTEST VALUES(1,2);
INSERT INTO TRAFFIC.TTEST VALUES(2,3);
DROP PROCEDURE TRAFFIC.TTTEST;
CREATE PROCEDURE TRAFFIC.TTTEST()
LANGUAGE SQLSCRIPT AS
BEGIN
DECLARE K INT :=1;
DECLARE TEMP INT ARRAY;
TAB1 = SELECT AB1 FROM TRAFFIC.TTEST;
TEMP := ARRAY_AGG(:TAB1.AB1);
FOR K IN 1..2 DO
TAB2 = SELECT * FROM TRAFFIC.TTEST WHERE TO_INT(AB1) = :TEMP[:K];
END FOR;
END;
CALL TRAFFIC.TTTEST();
Thanks in advance.
Best,
Shu
Hi Shu,
tab2 is not an array right. what is the use of looping it there. Because each time your tab2 will be overwritten. And which is your output?. Also try without initializing k to 1.
If removing tab2 works fine, try this too SELECT * FROM TRAFFIC.TTEST into tab2 WHERE TO_INT(AB1) = :TEMP[:K];
Regards,
Safiyu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.