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

Thread: How do I pass the value of a bind variable to a SQL plus variable?

  1. #1
    Join Date
    Mar 2001
    Posts
    287
    How do I pass the value of a bind variable to a SQL plus variable? I tried the following way, but it does not work the way I want. I want the value of ENV_VAR=test_value_for_bind_variable.


    SQL> var bind_var varchar2(100)
    SQL> begin
    2 :bind_var :='test_value_for_bind_variable';
    3 end;
    4 /

    PL/SQL procedure successfully completed.

    SQL> print :bind_var

    test_value_for_bind_variable

    SQL> define env_var=:bind_var
    SQL> define env_var
    DEFINE ENV_VAR = ":bind_var" (CHAR)
    --This is not I want!

  2. #2
    Join Date
    Feb 2001
    Posts
    103
    Hi,
    Can you please elaborate your question.
    When the going gets tough, the tough gets going

  3. #3
    Join Date
    Apr 2001
    Location
    UK
    Posts
    137
    Use the new_value feature:

    var myvar varchar2(30)
    exec myvar := 'Hello'
    col myvar new_value myvar

    select :myvar myvar
    from dual
    /

    select '&myvar'
    from dual
    /

  4. #4
    Join Date
    Apr 2001
    Location
    UK
    Posts
    137
    Sorry, should read:

    var myvar varchar2(30)
    exec :myvar := 'Hello'
    col myvar new_value myvar

    select :myvar myvar
    from dual
    /

    select '&myvar'
    from dual
    /

  5. #5
    Join Date
    Mar 2001
    Posts
    287
    Thank you!!!

  6. #6
    Join Date
    Mar 2001
    Posts
    287

    Can you execute OS command inside a PL/SQL?

    Can you execute OS commands inside a PL/SQL procedure?
    I know in SQL script, you can use HOST. How do you do this in PL/SQL?

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