Thank you for the prompt reply!
The problem is similar to mine. I did this the moment I received your reply
================================
CREATE PROCEDURE session.T1_SPx()
LANGUAGE SQL
BEGIN
DECLARE sname VARCHAR(50);
END@
================================
But still getting an 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 "END-OF-STATEMENT" was found following "RE sname
VARCHAR(50)". Expected tokens may include: "<psm_semicolon>". LINE
NUMBER=4. SQLSTATE=42601
SQL0104N An unexpected token "END-OF-STATEMENT" was found following "RE sname VARCHAR(50)". Expected tokens may include: "<psm_semicolon> ".
================================
Sorry but I am novice in using cursors in DB2. I have this script that should update a table and got a problem and my solution is I need to iterate the records in order for me to update the table correctly. Reason I want to use a cursor or control statements to achieve my goal.
The logic that I would like to do in my script is similar to this one below
================================
FOR v1 AS
c1 CURSOR FOR
SELECT name, id
FROM session.T1_TBL
DO
SET sname = name concat 'Hi';
UPDATE session.T1_TBL
SET name = sname;
END FOR;
================================
And as you know it is not working. I really need help how this cursor works in DB2.
Honestly, I really appreciate your help. And I hope sooner or later I can make this work with your help.
[-]