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

Thread: executing function on SQL prompt

  1. #1
    Join Date
    Dec 2000
    Posts
    255

    executing function on SQL prompt

    Hi All

    How to execute a FUNCTION on SQL prompt. I know about using the command 'variable ' and then assigning output to it. But I dont know how to assign returning value of a function to it.
    I have done

    variable i number
    i := exec reval(2);
    print i

    This does not work but ....

    If I execute it in begin ... end block it shows proper out put.

    What is the way I can see output in variable i.

    Amol

  2. #2
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434

    Re: executing function on SQL prompt

    Originally posted by amolik
    Hi All

    print i

    Amol
    Print???

    this seems to be SQL Server command....rather than oracle...
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    Code:
    lsc@DEV817-ES7J2BKT8ZM0YY>create or replace function mynumber
      2  return number
      3  as
      4    l_number number;
      5  begin
      6    select 1
      7      into l_number
      8      from dual;
      9    return l_number;
     10  end;
     11  /
    
    Function created.
    
    lsc@DEV817-ES7J2BKT8ZM0YY>variable x number
    lsc@DEV817-ES7J2BKT8ZM0YY>exec :x:=mynumber
    
    PL/SQL procedure successfully completed.
    
    lsc@DEV817-ES7J2BKT8ZM0YY>print x
    
             X
    ----------
             1

  4. #4
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439

    Re: Re: executing function on SQL prompt

    Originally posted by abhaysk
    Print???

    this seems to be SQL Server command....rather than oracle...
    SQL*Plus reference manual is a good reading sometimes......
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  5. #5
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434

    Re: Re: Re: executing function on SQL prompt

    Originally posted by jmodic
    SQL*Plus reference manual is a good reading sometimes......
    I shud start i think...
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  6. #6
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712

    Works as well ...

    Code:
    select reval(2) from dual;
    Ales
    The whole difference between a little boy and an adult man is the price of toys

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