Hey,
I want to create a table in bash, my db server is oracle. You can find my script below:
I am very confused. I tried to run this script many times without any luck. Please help!
Hey,
I want to create a table in bash, my db server is oracle. You can find my script below:
I am very confused. I tried to run this script many times without any luck. Please help!
The parenthesis in your subquery are probably being interpreted by the shell. Backquote them like you did the *.
I don't think you need to give backslash before '*' and also in ur script brefore login1 '$' is missing. Also post what error you are getting.
I removed backslash before *. I put backslashes before parenthesis. I put $ sign before login1. Unfortunately it did not help. I wish to put here any error message but I did not get any info. Any ideas?
I appreciate your help!
in your script, before the sql loop, add this:
sqlplus () {
echo >&2 "$*"
cat >&2
}
Then you can see on STDERR what is actually getting to the sqlplus command.
Hey. I finally resolved the problem. I am put here correct code, maybe someone will need it:
I thought that the maybe my query is too long to put it in one line. I decided to split it - just like above. It is working fine now.
Thanks a lot for help!
It is not necessary or desirable to execute the sqlplus command within backticks and put the result into an environment variable. This will hide errors and give you issues with line breaks.
The SQL "DROP TABLE IF EXISITS " is a SQL syntax error.
sqlplus -s "$login/$passwd@$db"<<EOF
DROP TABLE IF EXISITS $table1;
CREATE TABLE $table1 AS SELECT * FROM $login.$table WHERE $i IN (SELECT $i FROM $login.$table MINUS SELECT $i FROM $login1.$table);
exit
EOF