my function is
CREATE FUNCTION BOD_SEQ_NEXT
()
RETURNS NUMERIC(19)
LANGUAGE SQL
MODIFIES SQL DATA
FENCED
NOT DETERMINISTIC
EXTERNAL ACTION
BEGIN ATOMIC
declare v_seq_next NUMERIC(19) default -1;
-- If the sequence table was initialized at table creation with one row,
-- the delete & insert could be replaced with single update.
-- Also, the SEQ column need not be declared as PRIMAY KEY since
-- a sequence table should only contain one row.
-- delete from BOD_SEQ;
-- insert into BOD_SEQ (SEQ) values (default);
update TMGIIM.BOD_SEQ set SEQ = default;
select max(SEQ) into v_seq_next from TMGIIM.BOD_SEQ;
RETURN v_seq_next;
END@
but i get the error
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 "v_seq_next " was found following "select
max(SEQ) into". Expected tokens may include: "<space>". LINE NUMBER=18.
SQLSTATE=42601
(btw
db2 version is 7.2.1 and patch is FP12_WR21337
)
thanks
CREATE FUNCTION BOD_SEQ_NEXT
()
RETURNS NUMERIC(19)
LANGUAGE SQL
MODIFIES SQL DATA
FENCED
NOT DETERMINISTIC
EXTERNAL ACTION
BEGIN ATOMIC
declare v_seq_next NUMERIC(19) default -1;
-- If the sequence table was initialized at table creation with one row,
-- the delete & insert could be replaced with single update.
-- Also, the SEQ column need not be declared as PRIMAY KEY since
-- a sequence table should only contain one row.
-- delete from BOD_SEQ;
-- insert into BOD_SEQ (SEQ) values (default);
update TMGIIM.BOD_SEQ set SEQ = default;
select max(SEQ) into v_seq_next from TMGIIM.BOD_SEQ;
RETURN v_seq_next;
END@
but i get the error
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 "v_seq_next " was found following "select
max(SEQ) into". Expected tokens may include: "<space>". LINE NUMBER=18.
SQLSTATE=42601
(btw
db2 version is 7.2.1 and patch is FP12_WR21337
)
thanks
Comment