Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
"SQLSTATE" is not valid in the context where it is

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: "SQLSTATE" is not valid in the context where it is
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    Post subject:
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    Post subject: Re: "SQLSTATE" is not valid in the context where i
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts Include/omit with "ALL" pa... mgl DFSORT/ICETOOL 6 Wed Jun 14, 2017 2:31 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us