Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2003
    Posts
    35

    Unanswered: How to use IF ELSE in sqlplus

    Hi All,
    I need to check a value returned from a function or procedure.

    if i have this sqlplus command:

    declare a number
    begin
    a:=func_get_value;
    end;


    How can i do as follows:
    -if a!=0 sqlplus exit with exit code!=0
    -if a=0 sqlplus exit with exit code=0

    Thanks for the help from all expert.

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    62
    declare a number
    begin
    a:=func_get_value;
    end;


    The code should be -----------
    Declare
    a number;
    begin
    a:= func_get_value;

    if a = 0 then
    exit;
    elsif a = 1 the
    write what you want;
    else
    write statements for else condition;
    endif;

    end;
    Regards,

    Rushi

  3. #3
    Join Date
    Jun 2003
    Posts
    35
    Hi Rushi,

    Are you sure what you suggestion is working under sqlplus?Not inside procedure or function that is calling another procedure or function.

  4. #4
    Join Date
    Jan 2004
    Location
    India
    Posts
    62
    The Sample code that I have written is for sqlplus.
    It will exit sqlplus on the specified condition.
    The declare - begin - end part is called an anonymous block, so it will not be stored in the database. so each time you will have to write it or you will have to store the code in a .sql file and then you will have to execute the .sql file when the same code is required.
    I am not sure about the exit code 0 or whatever you are looking for.
    But the samplecode will definately run on sql prompt.
    Regards,

    Rushi

Posting Permissions

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