开发者

Executing oracle queries in Shell Script

Please tell me how can i excute an oralce query inside a shell script.I am writing a shell script where I need to execute the oracle queries and scripts inside the shell script.

What is the purpose of these lines

sql_file=sachin.sql
cat <<!SQL > $sql_file
        select $1 from开发者_JAVA百科 dual;
        exit;
!SQL

I think they are creating a new file, but what exactly is !SQL


It is the multi-line string terminator (a here-doc). There is no special meaning to the letters used, you could just as well have written !ORACLE, it just denotes that the content of the multi-line string are SQL commands.

What your script does is create a text file called sachin.sql with the contents specified between the two !SQL tokens.

PS: Not sure what shell this is for, my bash does not like the exclamation mark, thinks it is an event.


!SQL is just a token to notify the end of sql statements (here-doc) we can use any token like EOF, ENDSQL anything.

but the pre-requisite is the second token !SQL should start on the first column of the line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜