Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2007
    Posts
    50

    Unanswered: sql stored procedure default parameter

    Is there any way to define a default parameter in a sql stored procedure?

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    No, not in DB2 for LUW.

    Andy

  3. #3
    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.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  6. #6
    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.

  7. #7
    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.

  8. #8
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  9. #9
    Join Date
    Sep 2007
    Posts
    50
    That's a good idea. Thanks for the tip.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •