Hello,
I'd like to write a procedure, which processes actions (mainly insert/delete), which an autocommit after a defined amount of actions.
Therefore I've created a procedure, which takes a parameter and opens it in a cursor - something like this:
This technically works, but I've to predefine for each table the Type with
I found in various documentations of DB2 (we are using DB2 9.7 on Windows) that there is an equivalent for %ROWTYPE of Oracle - but it's usually used in the block between IS and BEGIN.
I'm not familiar with DB2, but somehow this version doesn't recognise this syntax?
Another question is - is there a possibility to insert the values, which were assigned to a %rowtype-like structure to another table, or is it necessary to do this manually?
Thanks in advance,
Best regards Martin
I'd like to write a procedure, which processes actions (mainly insert/delete), which an autocommit after a defined amount of actions.
Therefore I've created a procedure, which takes a parameter and opens it in a cursor - something like this:
Code:
CREATE OR REPLACE procedure doSomething
(IN sqlstring varchar(200))
LANGUAGE SQL
BEGIN
DECLARE c1 weakCursorType;
DECLARE myVar jurlvRow;
DECLARE lvid varchar(20);
DECLARE SQL_CURS1 CHAR(100) ;
--DECLARE STMT_CURS1 CHAR(100);
DECLARE CURS2 CURSOR WITH RETURN FOR STMT_CURS1;
PREPARE STMT_CURS1 FROM sqlstring ;
OPEN CURS2;
FETCH CURS2 INTO myVar;
CALL DBMS_OUTPUT.PUT_LINE(myVar.lvid || ' ' || myVar.bearbid );
close CURS2;
RETURN 0;
END
@
SET SERVEROUTPUT ON@
call doSomething('SELECT * from TABLENAME')@
Code:
CREATE or replace TYPE jurlvRow AS ROW ANCHOR ROW OF TABLENAME@
I'm not familiar with DB2, but somehow this version doesn't recognise this syntax?
Another question is - is there a possibility to insert the values, which were assigned to a %rowtype-like structure to another table, or is it necessary to do this manually?
Thanks in advance,
Best regards Martin