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 > sql stored procedure default parameter

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-09-07, 08:46
iskander iskander is offline
Registered User
 
Join Date: Sep 2007
Posts: 50
sql stored procedure default parameter

Is there any way to define a default parameter in a sql stored procedure?
Reply With Quote
  #2 (permalink)  
Old 11-09-07, 10:04
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
No, not in DB2 for LUW.

Andy
Reply With Quote
  #3 (permalink)  
Old 11-09-07, 10:42
iskander iskander is offline
Registered User
 
Join Date: Sep 2007
Posts: 50
Thanks
It is actually z/OS (AS/400) used over iSeries but I assume as long as it is SQL it will be the same. Couldn't find anything in the manual about default parameters.
Reply With Quote
  #4 (permalink)  
Old 11-09-07, 12:23
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
z/OS and AS/400 (iSeries) are two completely different platforms and the DB2 products for both platforms are also different.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 11-09-07, 12:30
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You could write the SP to determine if a parameter needs a value (it is null) and then supply the default.

IF Arg1 is null then set arg1 = <default>; end if;

You would do this as the first executable statements of the SP.

Andy
Reply With Quote
  #6 (permalink)  
Old 11-09-07, 13:39
iskander iskander is offline
Registered User
 
Join Date: Sep 2007
Posts: 50
Quote:
Originally Posted by stolze
z/OS and AS/400 (iSeries) are two completely different platforms and the DB2 products for both platforms are also different.
ok, sorry for being thick.
It is as400 - iseries.
Reply With Quote
  #7 (permalink)  
Old 11-09-07, 13:40
iskander iskander is offline
Registered User
 
Join Date: Sep 2007
Posts: 50
Quote:
Originally Posted by ARWinner
You could write the SP to determine if a parameter needs a value (it is null) and then supply the default.

IF Arg1 is null then set arg1 = <default>; end if;

You would do this as the first executable statements of the SP.

Andy
Thanks mate, that is pretty much what I have done. However, you still need to pass the argument in the call. I guess I can live with this shortcoming.
Reply With Quote
  #8 (permalink)  
Old 11-09-07, 14:00
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Quote:
Originally Posted by iskander
Thanks mate, that is pretty much what I have done. However, you still need to pass the argument in the call. I guess I can live with this shortcoming.
If you want to do it where the argument is left out altogether, then you basically have a different SP--it has a different signature. You can create one like that, it just has to have a different SPECIFIC NAME. It can have the same called name. You could even have the SP with the missing parameter call the other one and supply the value for the missing parameter with the default.

Andy
Reply With Quote
  #9 (permalink)  
Old 11-09-07, 16:18
iskander iskander is offline
Registered User
 
Join Date: Sep 2007
Posts: 50
That's a good idea. Thanks for the tip.
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