IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

"SQLSTATE" is not valid in the context where it is


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Madhu Chandran

New User


Joined: 31 Jan 2006
Posts: 2

PostPosted: Thu Feb 02, 2006 6:46 pm
Reply with quote

Hi gurus,
I am new to DB2 and tried out the following sp in version 7 for windows
but it generated an error
"[IBM][CLI Driver][DB2/LINUX] SQL0206N "SQLSTATE" is not valid in the context where it is used. LINE NUMBER=15. SQLSTATE=42703"

Please help me out with this icon_confused.gif



CREATE PROCEDURE USER1.cur (INOUT empno int )
RESULT SETS 1
LANGUAGE SQL
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
P1: BEGIN
-- Declare cursor
DECLARE cr1 CURSOR WITH hold FOR
SELECT employee_id FROM employees
for update of salary;

-- Cursor left open for client application
open cr1;
while (sqlstate='00000') do
fetch cr1 into empno;
update employees set salary=10670 where current of cr1;
end while;

END P1

Thanks and regards,
Madhu
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Feb 03, 2006 10:23 am
Reply with quote

Hi

Use SQLCODE instead of SQLSTATE

Thanks & Regards
Prabs
Back to top
View user's profile Send private message
Madhu Chandran

New User


Joined: 31 Jan 2006
Posts: 2

PostPosted: Fri Feb 03, 2006 10:52 am
Reply with quote

Thanks for the reply prabs but i tried using sqlcode instead of sqlstate and recieved the same error message replacing sqlstate with sql code thts all....... icon_sad.gif
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Feb 03, 2006 11:38 am
Reply with quote

Hi

The reason might be an undefined column,attribute or parameter name
If I smell something else I will let u know.

Thanks & Regards
Prabs
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Mon Feb 06, 2006 4:25 pm
Reply with quote

Use this code:


------
------
while (sqlcode = 0 ) do
fetch cr1 into empno;

if (sqlcode = 0)
update employees set salary=10670 where current of cr1;

end while;
------
-----

there may be code syntax error.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts PuTTY - "User is not a surrogate... IBM Tools 5
No new posts Newbie Stuck on "Duplicate Datas... TSO/ISPF 5
No new posts RABBIT HOLE NEEDED - "Live"... All Other Mainframe Topics 0
No new posts Using PARM=('JPn"&SYMBOL&quo... DFSORT/ICETOOL 2
No new posts Syncsort "Y2C" Function SYNCSORT 1
Search our Forums:

Back to Top