DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: NVL question

  1. #1
    Join Date
    Dec 2000
    Posts
    87
    Hi,

    Can someone help me to see the following codes which is part of the trigger, I just like to make sure the syntax is correct.

    if (nvl(:new.keypart1_use,'nothing') = 'nothing') then
    v_keypart1indic := 0;
    else
    v_keypart1indic := 1;
    end if;

    if (nvl(:new.keypart2_use,'nothing') = 'nothing') then
    v_keypart2indic := 0;
    else
    v_keypart2indic := 1;
    end if;

    if (nvl(:new.keypart3_use,'nothing') = 'nothing') then
    v_keypart3indic := 0;
    else
    v_keypart3indic := 1;
    end if;

  2. #2
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Actually, I would use:

    v_keypart1indic := DECODE ( :new.keypart1_use, NULL, 0, 1);

    Actually, however, if you look at my suggestions to your original post, you will see that you should really fill these in the EXCEPTION block:

    ...
    v_keypart1indic := 1;
    ...
    EXCEPTION
    ---WHEN NO_DATA_FOUND THEN
    ------v_keypart1indic := 0;
    ...


    HTH,

    - Chris

  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    [QUOTE][i]Originally posted by chrisrlong [/i]
    [B]Actually, I would use:

    v_keypart1indic := DECODE ( :new.keypart1_use, NULL, 0, 1);

    [/B][/QUOTE]
    Unfortunatelly the DECODE is not supported in PL/SQL.... ;)
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  4. #4
    Join Date
    Dec 2000
    Posts
    87
    The compiler complaint that DECODE' may be used inside a SQL statement only.

Posting Permissions

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


Click Here to Expand Forum to Full Width