Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    10

    Unanswered: db2 sql stored procedure

    Is there a way to add conditional logic in sql stored procedures
    I want to say
    if(my query return no rows) then
    do this;
    else
    do other;

    Thanks for any info

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    I think one of the ways to accomplish this would be
    Code:
    IF EXISTS (SELECT ... FROM ... WHERE ...) THEN...

  3. #3
    Join Date
    Aug 2004
    Posts
    15
    can use

    get diagnostic cnt = row_count;
    if cnt = 0 then
    ...

    ..

  4. #4
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    This may not be the best way to do existence checking ...

    Cheers
    sathyaram

    Quote Originally Posted by vidyaraok
    can use

    get diagnostic cnt = row_count;
    if cnt = 0 then
    ...

    ..
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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