-
Using Shell Variables in SQLPLUS
I am trying to find a way to use a variable in my shell (Korn) in a simple select statement in sqlplus.
For example:
$ SHELLVAR=10
$ sqlplus '/ as sysdba'
SQL> select name from v$archived_log
2> where seqeunce# = $SHELLVAR
3> /
This is basically what I want to do. In the way is it written here, I get an error from SQLPLUS.
Is there any way to use the value of shell variable in sqlplus?
-
I think I found my answer ....
I should use positional parameters! As in:
sqlplus '/ as sysdba' @myscript.sql $SHELLVAR
And myscript.sql would like this:
select name from v$archived_log
where sequence# = &1
-
or
$ export SHELLVAR=222
$ sqlplus /@yourdb <
select * from xyz where id = $SHELLVAR;
EOF
Jeff Hunter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|