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"