05-26-2016
You can do this in a few ways.
- You can call sqlplus and pass it a deck/file of multiple SQL commands.
- You can call sqlplus in what is called a here document and pass in the commands from your script
- Probably others......
How much SQL code are you planning to pass in, and will it be static or based on variables in the main script?
Robin
This User Gave Thanks to rbatte1 For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I new to Unix and scripting. Following is my requirement. Can someone tell me whether its possible or not. Also please let me know how to proceed further if this is possible.
List of queries are stored in a file. For example, I have to run a query like this:
Select * from &XYZ where... (0 Replies)
Discussion started by: simhasuri
0 Replies
2. Shell Programming and Scripting
Hi,
When i execute the below statement , the value is not getting stored in the variable.
AnneeExercice=`sqlplus $LOGSQL/$PASSWORDSQL << FIN >> $GEMOLOG/gemo_reprev_reel_data_ventil_$filiale.trc
SELECT bi09exercice
FROM bi09_scenario
WHERE bi09idfiliale=UPPER('de')
AND ... (1 Reply)
Discussion started by: krishna_gnv
1 Replies
3. Shell Programming and Scripting
Hi,
I need your help in sedning sql queries output to different excel sheets.
My requirement is like this:
Query1: Select name from table1 where status = 'Complete'
Query2: Select name from table1 where status = 'Failed'
Query3: Select name from table1 where status = 'Ignored'
... (4 Replies)
Discussion started by: parvathi_rd
4 Replies
4. Shell Programming and Scripting
i have to do a check in my UNIX script to see whats saved in the database. depending on whats there will fork data to certain functions. However i do not know how to capture SQL output into a UNIX variable.
Below is what i have tried, but i get an error:
Error 3706 Failure 3706 Syntax error:... (3 Replies)
Discussion started by: purplebirky
3 Replies
5. Shell Programming and Scripting
Hi,
I want to write the shell script to change multple file name (the file name is get from DB)
e.g. cp db1.txt file1_new.txt
cp db2.txt file2_new.txt
cp db3.txt file3_new.txt
I have write the script like this:
VAR=`sqlplus -s $LOGON @<<ENDOFTEXT
set termout off
... (0 Replies)
Discussion started by: jackyntk
0 Replies
6. Shell Programming and Scripting
In c:/zaheer/123-456/sql/ folder i have below 7 sql files.
cv_abc_a.sql
cv_abc_b.sql
cv_abc_c.sql
vtemp_d.sql
vtemp_e.sql
cv_abc_f.sql
Exviews.sql
In Exviews.sql file i have mentioned all cv and vtemp files to run like
start ${SQLDIR}/cv_abc_a.sql
start ${SQLDIR}/cv_abc_b.sql... (1 Reply)
Discussion started by: Zaheer.mic
1 Replies
7. Shell Programming and Scripting
Hi!
I would like to do a single connection to sqlplus and execute some querys.
Actually I do for every query one connection to database
i.e
echo 'select STATUS from v$instance;
exit' > $SQL_FILE
sqlplus user/pass@sid @$SQL_FILE > $SELECT_RESULT
echo 'select VERSION from v$instance;... (6 Replies)
Discussion started by: guif
6 Replies
8. Shell Programming and Scripting
Hi,
I have a script where I make a sqlplus connection. In the script I have multiple sql queries within that sqlplus connection. I want the result of the queries to be stored in shell variables declared earlier. I dont want to use procedures. Is there anyway else.
Thanks in advance..
Cheers (6 Replies)
Discussion started by: gonchusirsa
6 Replies
9. Shell Programming and Scripting
Dear All,
I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File.
The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files.
Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies
10. Shell Programming and Scripting
Hi All,
I have a file queries.txt as follows :
SELECT COLUMN1 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN1 FROM SCDEMA2.TABLE2;
SELECT COLUMN2 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN2 FROM SCDEMA2.TABLE2;
SELECT COLUMN3 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN3 FROM SCDEMA2.TABLE2;
SELECT... (2 Replies)
Discussion started by: SriRamKrish
2 Replies
isql(1) UnixODBC Reference isql(1)
NAME
isql - utility to submit SQL queries to a data source.
iusql - Unicode version of isql.
SYNOPSIS
isql DSN [UID [PWD]] [options]
DESCRIPTION
isql can be used to submit SQL to a data source and to format/output results. It can be used in batch or interactive mode.
OPTIONS
DSN Name of the data source you want to connect to.
UID Your login to connect the DSN.
PWD Your password needed to login to the DSN.
-b Batch mode. It will not do any prompting.
-dx Delimit columns with x.
-x0xXX Delimit columns with XX, where XX is in hex. For example -x0x09 will use a tab.
-w Wrap results in an HTML table
-c Print column names on first row. This options only has effect in combination with the -d option.
-mn Limit column display width to n
-v Verbose output.
--version
This prints the version.
EXAMPLES
cat My.sql | isql WebDB MyID MyPWD -w
Each line in My.sql must contain exactly 1 SQL command except for the last line which must be blank.
AUTHOR
This manual page was written by Kurt Roeckx <kurt@roeckx.be> for the Debian package of unixODBC.
UnixODBC Dec 2004 isql(1)