Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2003
    Location
    Paris
    Posts
    38

    Unanswered: function output in sqlplus

    I'd like to know whether it be possible to return a value from a stored function to a defined variable in sqlplus.
    Cordialement

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: function output in sqlplus

    Originally posted by Crassus
    I'd like to know whether it be possible to return a value from a stored function to a defined variable in sqlplus.
    Yes:

    SQL> variable x number;
    SQL> exec :x := sqrt(2);

    PL/SQL procedure successfully completed.

    SQL> print x

    X
    ----------
    1.41421356

  3. #3
    Join Date
    Feb 2003
    Location
    Paris
    Posts
    38
    Thanks, Tony.

    I noticed that you used 'variable'. How is it different to 'define'?
    Cordialement

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Originally posted by Crassus
    Thanks, Tony.

    I noticed that you used 'variable'. How is it different to 'define'?
    They are quite different. VARIABLEs are true bind variables that can be used in SQL and PL/SQL, and can have values assigned to them within SQL or PL/SQL (as in my example).

    DEFINE creates "substitution" variables which are meaningful only to the SQL Plus program. They are simply substituted with their defined values BEFORE SQL Plus sends the SQL or PL/SQL to the server. Silly example:

    SQL> define x = dbms_output.put_line('Hello');
    SQL> exec &x
    Hello

    PL/SQL procedure successfully completed.

Posting Permissions

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