Posted: Tue Oct 01, 2002 8:01 am Post subject: Use of CURSORs in passthru
Acolyte
Joined: 19 Sep 2002 Posts: 74 Location: Newton, MA
I've got the following SQL to get through a passthru statement:
DECLARE c1 CURSOR WITH HOLD FOR
SELECT seed_value
FROM sequence_table
WHERE client_column_name = 'abp_unq_id'
FOR UPDATE OF seed_value;
OPEN c1;
FETCH c1 INTO v_seed_value;
UPDATE sequence_table
SET seed_value = (v_seed_value + 1)
WHERE client_column_name = 'abp_unq_id';
CLOSE c1;
I've placed the first part (first ; ends the first part) into a passthru statement and I get the following in the exception list:
IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token
"DECLARE c1 CURSOR WITH HOLD FOR" was found following "BEGIN-OF-STATEMENT".
Expected tokens may include: "<space>". SQLSTATE=42601
Joined: 26 Jun 2001 Posts: 103 Location: IBM IT Education Services, Germany
I think you can only PASSTHRU one single statement. You are trying to perform a series of statements. This should work with Stored Procedures of the database. You can execute these stored procs via PASSTHRU, or by creating a user-defined external procedure in ESQL
(CREATE PROCEDURE ...)
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum