Hi all,
I have created a procedure that selects from a table based on the value of another table concatenated with some text.
So this code below should select all from the table FL_TIME_DIM(value)
However I get an error that states
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "DECLARE" was found following "RE V_SQL
VARCHAR(64)". Expected tokens may include: "<psm_semicolon >". LINE
NUMBER=1. SQLSTATE=42601
If anyone could help me out it would be much appreciated.
Thanks,
apple
I have created a procedure that selects from a table based on the value of another table concatenated with some text.
So this code below should select all from the table FL_TIME_DIM(value)
However I get an error that states
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "DECLARE" was found following "RE V_SQL
VARCHAR(64)". Expected tokens may include: "<psm_semicolon >". LINE
NUMBER=1. SQLSTATE=42601
Code:
CREATE PROCEDURE TEST_1 DYNAMIC RESULT SETS 1 LANGUAGE SQL INHERIT SPECIAL REGISTERS BEGIN DECLARE V_SQL VARCHAR(64) DECLARE V_TABLE VARCHAR(256) DECLARE C_SQL CURSOR WITH RETURN FOR S_SQL SET V_TABLE = 'concat(''FL_TIME_DIM'',(select [I]Value from table[/I] ))' SET V_SQL = 'SELECT * FROM '||V_TAB||'FOR READ ONLY' PREPARE S_SQL FROM V_SQL OPEN C_SQL END;
Thanks,
apple
Comment