0

So I have something like the following inside a bash script:

sqlplus un/pw@db \@xxx.sql $PARAM1 $PARAM2 <<EOF > $LOGPATH
quit
EOF

As this gets often called in the script with different parameters, I would like to extract this code into a function.

Unfortunately I can't get the parameters to work correctly.

I have tried the following:

do_sql() {
sqlplus un/pw@db $1 << EOF >> $2
quit
EOF
}

do_sql "\@xxx.sql $PARAM1 $PARAM2" "$LOGPATH"

AND

do_sql() {
sqlplus un/pw@db << EOF >> $2
start $1
quit
EOF
}

do_sql "xxx.sql $PARAM1 $PARAM2" "$LOGPATH"

1 Answer 1

1

Just issue you sqlplus command like this:

sqlplus un/pw@db \@xxx.sql $PARAM1 $PARAM2

Don't forget to add the

exit;

at the end of your sql file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.