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 > calling aprocedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-03, 04:26
satya_adk satya_adk is offline
Registered User
 
Join Date: Nov 2003
Posts: 10
calling aprocedure

Hi, can someone please clearify how to call a procedure from command window. I am facing few problem--

firstly one of my parameter itself contain comma (') as part of value, is there something like excape characted here. for example a value to be passed is satya's.

secondly if i call a procedure i get some output like here-

db2 => call ABCX.USER_ACT_COMM('READ','2003','I')
SQL0206N "I" is not valid in the context where it is used. SQLSTATE=42703

i dont understand what is the error here..


Thanks for your help
Satyendra
Reply With Quote
  #2 (permalink)  
Old 12-04-03, 08:29
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Satyendra,
Can you post the definition of the Stored Procedure (name and parameters is all that is necessary)? THis will help me to give you a valid answer.

Andy
Reply With Quote
  #3 (permalink)  
Old 12-04-03, 08:40
satya_adk satya_adk is offline
Registered User
 
Join Date: Nov 2003
Posts: 10
Andy this is my stored procedure

USR_ACT_COMM (IN busCode VARCHAR(20),
IN inpYear VARCHAR(20),
IN userCode VARCHAR(10)

I want to call this stored procedure where in want to pass 'I','E' (including all quotes and comma ) as value for third parameter userCode, basically i am usiing that value in a IN clause in a select query so i have to pas aformatted string for that.

hope i put things clear.

Thanks
Satyendra
Reply With Quote
  #4 (permalink)  
Old 12-04-03, 08:48
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Try:
CALL USR_ACT_COMM('Read','2003','I'',''E')

Note the '' are two single quotes.

HTH

Andy

Quote:
Originally posted by satya_adk
Andy this is my stored procedure

USR_ACT_COMM (IN busCode VARCHAR(20),
IN inpYear VARCHAR(20),
IN userCode VARCHAR(10)

I want to call this stored procedure where in want to pass 'I','E' (including all quotes and comma ) as value for third parameter userCode, basically i am usiing that value in a IN clause in a select query so i have to pas aformatted string for that.

hope i put things clear.

Thanks
Satyendra
Reply With Quote
  #5 (permalink)  
Old 12-05-03, 01:12
satya_adk satya_adk is offline
Registered User
 
Join Date: Nov 2003
Posts: 10
Hi Andy,

The procs is getting called but the value does not seem to be passed correctly.

this is what i get--

db2 => CALL ABCX.USER_ACT_COMM('Read','2003','I'',''E')
SQL0104N An unexpected token "','" was found following "a.USAGE_TYPE IN (I". E
xpected tokens may include: ",". SQLSTATE=42601


basically the third parameter i am passing is supposed to just sit a IN clause.

example-

select...

where..
.
.
and a.USAGE_TYPE IN ( *** here**)
.
.


And this is working fine when beeing called from java code.I need to run that from command window for testing purpose.


thanks
Satyendra
Reply With Quote
  #6 (permalink)  
Old 12-05-03, 08:08
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Satyendra,
I am confused. What is the select statement you just presented have to do with calling a stored procedure. Could you be totally explicit what you want?

Andy



Quote:
Originally posted by satya_adk
Hi Andy,

The procs is getting called but the value does not seem to be passed correctly.

this is what i get--

db2 => CALL ABCX.USER_ACT_COMM('Read','2003','I'',''E')
SQL0104N An unexpected token "','" was found following "a.USAGE_TYPE IN (I". E
xpected tokens may include: ",". SQLSTATE=42601


basically the third parameter i am passing is supposed to just sit a IN clause.

example-

select...

where..
.
.
and a.USAGE_TYPE IN ( *** here**)
.
.


And this is working fine when beeing called from java code.I need to run that from command window for testing purpose.


thanks
Satyendra
Reply With Quote
  #7 (permalink)  
Old 12-10-03, 02:38
satya_adk satya_adk is offline
Registered User
 
Join Date: Nov 2003
Posts: 10
Hi Andy, sorry for delay, i was on off for few days.

You need not to considere that select statement, that i used just to clearify that i am using that value in one of select statement within the procedure body...so you know within the body of procedure there is a select statement where there is a IN clause which values are supplied as third parameter to the procedure, so typically the value to be passed should be like 'I','E'.
Reply With Quote
  #8 (permalink)  
Old 12-10-03, 08:02
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Satyendra,

What DB2 version and OS are you using?

Andy
Reply With Quote
  #9 (permalink)  
Old 12-11-03, 04:54
satya_adk satya_adk is offline
Registered User
 
Join Date: Nov 2003
Posts: 10
Hi, its DB2 7.1 and OS is sun solaris.
Reply With Quote
  #10 (permalink)  
Old 12-11-03, 08:03
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Satyendra,

Have you tried using the Stored Procedure Builder (SPB) to debug the SP to see if the parameters are being passed properly?

Andy
Reply With Quote
  #11 (permalink)  
Old 12-11-03, 23:33
satya_adk satya_adk is offline
Registered User
 
Join Date: Nov 2003
Posts: 10
Andy,

This procedure is running fine, both through java code and also running fine when i call it through stored procedure builder where i write my parameters in the prompt window. My problem is i want to call it from command window, the reason being i dont have stored porocedure builder istalled on clients's production environment.

so i need the way how i can call it through command window on db2 prompt.

I hope you understand what is my need.

doesn't that look strange we do not have any mean to pass parameters that itself contain comma (,) and single quote (') as part of parameter value from command prompt when it runs fine from procedure builder.

Thanks for your efforts and time in discussing this problem.
Reply With Quote
  #12 (permalink)  
Old 12-12-03, 08:57
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Satyendra,
What is the exact value of the parameter you want to pass. I want to see what it should look like inside the SP.

Andy

Quote:
Originally posted by satya_adk
Andy,

This procedure is running fine, both through java code and also running fine when i call it through stored procedure builder where i write my parameters in the prompt window. My problem is i want to call it from command window, the reason being i dont have stored porocedure builder istalled on clients's production environment.

so i need the way how i can call it through command window on db2 prompt.

I hope you understand what is my need.

doesn't that look strange we do not have any mean to pass parameters that itself contain comma (,) and single quote (') as part of parameter value from command prompt when it runs fine from procedure builder.

Thanks for your efforts and time in discussing this problem.
Reply With Quote
  #13 (permalink)  
Old 12-14-03, 23:55
satya_adk satya_adk is offline
Registered User
 
Join Date: Nov 2003
Posts: 10
Hi,

The value that should reach within SP is 'I','E','N'

all ' and , are part of value.


Thanks
Satyendra
Reply With Quote
  #14 (permalink)  
Old 12-17-03, 08:25
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Satyendra,

Sorry I did not reply sooner, I was out of the office for a few days.

Try:
CALL USR_ACT_COMM('Read','2003','''I'',''E'',''N''')

The ''' are 3 single quotes and the '' are 2.

HTH

Andy


Quote:
Originally posted by satya_adk
Hi,

The value that should reach within SP is 'I','E','N'

all ' and , are part of value.


Thanks
Satyendra
Reply With Quote
  #15 (permalink)  
Old 12-18-03, 04:00
satya_adk satya_adk is offline
Registered User
 
Join Date: Nov 2003
Posts: 10
Andy,

Yeah, it works now.
I can see the SP returning results as expected on comand window.

Thank you very much
Satyendra
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