SQL PLUS from shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SQL PLUS from shell
# 1  
Old 01-21-2006
SQL PLUS from shell

can anyone tel me the logic behind the foll kind of blocks....the ones we use when v embed sql queries qithin shell script...

for example...

<path> sqlplus << A
.............................
.............................
SQL statements
.............................
................................
B

i have noticed that the above block works for any value of A and B...

also A may not necessarily equal B

can anyone kindly provide me with a conceoptual answer as to why do v need to do this and what is the significance behind this...

i mean how does it atually work...?

thanks...........
# 2  
Old 01-21-2006
Quote:
Originally Posted by tej.buch
can anyone tel me the logic behind the foll kind of blocks....the ones we use when v embed sql queries qithin shell script...

for example...

<path> sqlplus << A
.............................
.............................
SQL statements
.............................
................................
B

i have noticed that the above block works for any value of A and B...

also A may not necessarily equal B

can anyone kindly provide me with a conceoptual answer as to why do v need to do this and what is the significance behind this...

i mean how does it atually work...?

thanks...........
The block is called a "here document" It's simply a document or block of text that gets utilized by some utility. In sqlplus' case, it's a script. As for "A" vs "B" markers, check your script. The ending block marker is the same as the beginning block marker. If you're trying this in a script without any other commands following the ending block marker then it will seem like it doesn't matter because of the script end-of-file marker. Try adding more lines to your script.
# 3  
Old 01-22-2006
hi...thanks a lot....
will try it using diff end and beginning markers.....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with SQL Shell script

Hi, I need to excute two .sql scripts sequentially within file.sh sqlplus user/pass@db1 @/opt/Infor/Outbound_Marketing/7.2.2/custom/iadeploy1.sql THEN sqlplus user/pass@db2 @/opt/Infor/Outbound_Marketing/7.2.2/custom/iadeploy3.sql Thanks, Soph (4 Replies)
Discussion started by: soph1997
4 Replies

2. Shell Programming and Scripting

Run SQL thru shell script: how to get a new line when run sql query?

Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database. I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :( What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies

3. UNIX for Advanced & Expert Users

Call parallel sql scripts from shell and return status when both sql are done

Hi Experts: I have a shell script that's kicked off by cron. Inside this shell script, I need to kick off two or more oracle sql scripts to process different groups of tables. And when both sql scripts are done, I will continue in the shell script to do other things like checking processing... (3 Replies)
Discussion started by: huasheng8
3 Replies

4. Shell Programming and Scripting

LIKE in SQL shell script

sqlplus -s <<__END__ ${USER}/${PASS}@${DB} WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK WHENEVER OSERROR EXIT FAILURE ROLLBACK SET ECHO ON SET TIMING ON SET SERVEROUTPUT ON SIZE 1000000 select count(*) from table where start LIKE '10-JUN-10'; EXIT __END__ result=$? echo $resultThis gives... (9 Replies)
Discussion started by: sandy1028
9 Replies

5. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

Hi , I used the below script to get the sql data into csv file using unix scripting. I m getting the output into an output file but the output file is not displayed in a separe columns . #!/bin/ksh export FILE_PATH=/maav/home/xyz/abc/ rm $FILE_PATH/sample.csv sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies

6. Shell Programming and Scripting

using SQL from Shell

Hi, I would like to access SQL plus from my unix, and learn to run some SQL scripts in Unix. How do i begin. Is there any known website that offers a quick tutorial or tips? Thanks, unxhopeful (1 Reply)
Discussion started by: unxhopeful
1 Replies

7. Shell Programming and Scripting

Calling SQL LDR and SQL plus scripts in a shell script

Hi- I am trying to achieve the following in a script so I can schedule it on a cron job. I am fairly new to the unix environment... I have written a shell script that reads a flat file and loads the data into an Oracle table (Table1) via SQLLDR. This Works fine. Then, I run a nested insert... (5 Replies)
Discussion started by: rajagavini
5 Replies

8. Shell Programming and Scripting

Shell Script - SQL

Guys,Please look at a simple shell which validates presence of a customer table in OASIS schema. SQL Query for validation is wrong(Table name in quotes should not have schema name OASIS.). And shell is working correctly (with exit 1) as it will never get count=1 with this query. But it is... (2 Replies)
Discussion started by: bhush782003
2 Replies

9. Shell Programming and Scripting

connecting sql from shell

Hi all, I am running an sql file from unix .In the log file along with the output i am getting details of connecting and disconnecting sqlplus like It saves the output with "Connected to Oracle8i Enterprise Edition Release 8.1.7.4.0 Connected as apps" and "disconnected... (1 Reply)
Discussion started by: rrs
1 Replies

10. UNIX for Dummies Questions & Answers

sql in shell script

Hey I have this shell script that I am trying to run and receive a value from a sql query.Then later use the value in an if stmt... I cannot get this to work for nothing.. Here is the script (sqlplus -s $usrname/$passwrd <<! set head off feed off pagesize 0 select b from table; set head... (9 Replies)
Discussion started by: devaris22
9 Replies
Login or Register to Ask a Question