If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Setting out parameters in SP with if & elseif

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-14-09, 10:48
xerg xerg is offline
Registered User
 
Join Date: Aug 2009
Posts: 5
Setting out parameters in SP with if & elseif

Hi guys, I was try execute this code
Code:
CREATE PROCEDURE test (IN CODE varchar(10), OUT MSG varchar(20))
  LANGUAGE SQL
  DYNAMIC RESULT SETS 1 
BEGIN
	
	IF CODE = 'A123' THEN
		SET MSG = 'HELLO IM NEWBIE';
	ELSEIF CODE= 'A124' THEN
               SET MSG = 'BYE IM NEWBIE';
	ELSE THEN
		SET MSG = 'CODE NOT EXIST';
		
	END IF;

END;
When I try execute this procedure console gave me : SQL0206N (not valid context). What thing i'm doing wrong?????

Last edited by xerg; 08-14-09 at 10:52.
Reply With Quote
  #2 (permalink)  
Old 08-14-09, 11:39
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
I am confused. Do you get the error when you try to create the Stored Procedure or when you execute it? If it is when you execute it, please provide the exact call statement and the full error. Also include DB2 version and OS.

Andy
Reply With Quote
  #3 (permalink)  
Old 08-14-09, 11:54
xerg xerg is offline
Registered User
 
Join Date: Aug 2009
Posts: 5
Quote:
Originally Posted by ARWinner
I am confused. Do you get the error when you try to create the Stored Procedure or when you execute it? If it is when you execute it, please provide the exact call statement and the full error. Also include DB2 version and OS.

Andy
You're right, I got that error when I was try CREATE PROCEDURE, sorry for that

Info about db2.
Product identifier SQL09050
Level identifier 03010107
Level DB2 v9.5.0.808
Build level s071001
PTF NT3295
Reply With Quote
  #4 (permalink)  
Old 08-14-09, 12:23
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What is the full error message you are getting?

Andy
Reply With Quote
  #5 (permalink)  
Old 08-14-09, 13:21
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Code:
	ELSE THEN
		SET MSG = 'CODE NOT EXIST';
Your code has syntax error.
"THEN" is not neccessary.
Reply With Quote
  #6 (permalink)  
Old 08-14-09, 17:04
xerg xerg is offline
Registered User
 
Join Date: Aug 2009
Posts: 5
Thanks you!
Reply With Quote
  #7 (permalink)  
Old 08-17-09, 05:11
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
And you also shouldn't use ';' as statement terminator for the whole CREATE PROCEDURE statement - only for the statements inside the procedure body.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On