Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

passing variables from shell script to separate sqlplus script

User469534-OCApr 5 2013 — edited Apr 5 2013
Hi, I am having issues passing variables to a separate sqlplus script invoked by the shell script, e.g.

#!/bin/sh

DB_NAME=TEST
PWD1=PA55W0rd

echo exit | sqlplus / as sysdba @${DB_NAME}.sql ${DB_NAME} $PWD1 >> ${DB_NAME}.sql

exit 0


The script picks up the $DB_NAME variable fine, and therefore invokes the required sql script.
However, when I pass the variable $PWD1 to the sql script I get an error.
The script creates a database link:

create or replace procedure new.link
is
begin
execute immediate 'create database link TEST
connect to TESTSCH identified by '$PWD1'
using ''TEST''';
end;
/
exec new.link;
/

output is:

ERROR at line 1:
ORA-00911: invalid character
ORA-06512: at "NEW.LINK", line 4
ORA-06512: at line 1

any help appreciated!

Edited by: 969765 on Apr 5, 2013 4:24 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 3 2013
Added on Apr 5 2013
13 comments
2,471 views