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 > Db2 Stored Procedures

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-26-07, 03:47
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
Db2 Stored Procedures

can u specify default values to parameters of stored procedures if they are not supplied??

for eg

create procedure owner.A
(
in X int ,
in Y char(4) ,
in Z varchar(3)
)

it may be possible that for some cases value of Z will not be supplied and i want it to take default values

something in the lines of

create procedure owner.A
(
in X int ,
in Y char(4) ,
in Z varchar(3) default null
)

so if i call procedure A as A(1,2) will it run as A(1,2,null) since by default Z is set to null
Reply With Quote
  #2 (permalink)  
Old 06-29-07, 03:07
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
What do you mean with "not supplied"? When you call a stored procedure, DB2 will identify the proper procedure by the fully qualified name and the number of parameters. Thus, if you omit a parameter, it will resolve to a different procedure.

The only way to achieve what you want is to write two procedures:
Code:
CREATE PROCEDURE proc(IN x INT, IN y CHAR(4), IN z VARCHAR(3))
   ...

CREATE PROCEDURE proc(IN x INT, IN y CHAR(4))
   LANGUAGE SQL
   BEGIN
      CALL proc(x, y, CAST(NULL AS VARCHAR(3));
   END@
__________________
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