Sponsored Content
Top Forums Shell Programming and Scripting How to embed sql query into our shell script? Post 302891321 by pravin27 on Wednesday 5th of March 2014 07:05:44 AM
Old 03-05-2014
Code:
sqlplus -s $user/$passwrd <<ENDOFSQL
whenever sqlerror exit sql.sqlcode;
select sysdate from dual;
exit;
ENDOFSQL

RetCode=$?

#Check the return code from SQL Plus
if [ $RetCode != 0 ]
then
  echo "********************"
  echo "ERROR: The SQL Plus Command Failed. RetCode: $RetCode"
else
  echo "********************"
  echo "SQL Plus Successfully Ran. RetCode: $RetCode"
fi

If provided userid and password is not correct , then sql query will not execute and script will exit, so no need to validate userid and password here.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Executing a SQL query from a shell script

I cannot figure out how to run a SQL script, or just a sqlplus query, from a shell script (bash or ksh). Basically, I need to su - oracle from root and run a query, then test the exit status. (3 Replies)
Discussion started by: 98_1LE
3 Replies

2. UNIX for Advanced & Expert Users

Connecting DB in the Shell Script to do SQL Query

Any link or example to write shell script for the Connecting Oracle for Quering through SQL thanks in advance ... Cheers !! Mehul Doshi (3 Replies)
Discussion started by: mehuldoshi
3 Replies

3. Shell Programming and Scripting

Executing Sql Query Using Shell Script

HI ALL i have a requirement like this. i have to write a shell script to run a sql query. DB is oracle. once the query is run, the results of the query has to be published in a data file. can you please advice me how to go about it. i am absolutely new to shell scripts and this is a part of my job. (14 Replies)
Discussion started by: ragha81
14 Replies

4. Shell Programming and Scripting

executing a SQL query in shell script

Hi ALL, I need an help in connecting to oracle database, executing a select query and printing it on the screen. Can any one please write a simple code or psuedo code and let me know. select query returns multiple values( say select name from emp) Thanks in advance LM (1 Reply)
Discussion started by: lijju.mathew
1 Replies

5. Shell Programming and Scripting

query sql using shell script

query sql using shell script, is it possible? my friend told me to do a file.sql and link to my shell script, but can i query sql using shell script? thanks in advance! (2 Replies)
Discussion started by: kingpeejay
2 Replies

6. Shell Programming and Scripting

$ symbol in sql query in shell script

Hi Team, Can you please help me to resolve this issue. Am unable to use this $ symbol in sql query in the shell script. For Example: # !/bin/sh export USER_NAME=XXX export PASSWORD=YYY export ORACLE_SID=xamdb echo $ORACLE_SID echo " Session Details ..." ... (1 Reply)
Discussion started by: indira_s
1 Replies

7. UNIX for Dummies Questions & Answers

Regarding executing sql query in shell script

Hi, I have one SQL file prepared in UNIX and one script that is executing that. In SQL i have Update and create queries. I want to introduce conditions in SQL file (in UNIX) that if either of the create or update query failes whole transaction should be rollback. I just have 1 create... (2 Replies)
Discussion started by: abhii
2 Replies

8. Red Hat

Sql query through shell script

hey , i am using this code to store value of a sql query and and then use it in other query but after some time , but it is not working. please help #!/bin/bash val_1=$( sqlplus -s rte/rted2@rel76d2 << EOF setting heading off select max(stat_id) from cvt_stats; exit EOF ) nohup... (5 Replies)
Discussion started by: ramsavi
5 Replies

9. Shell Programming and Scripting

Convert the SQL Query in Shell Script

Hi All, I have a query with output below select 'create synonym "'||TABLE_NAME||'" for '||Table_owner||'."'||table_name||'"'||chr(59) from user_synonyms; ================== create synonym "RV_SBC_SIG" for WFCONTROLLER_TE."RV_SBC_SIG"; create synonym "AQM_TASK" for AWQM_TE."AQM_TASK";... (2 Replies)
Discussion started by: pvmanikandan
2 Replies

10. Shell Programming and Scripting

Shell script to execute sql query.

Hi Experts, Need your support. Not able to use sql query alias in shell script. Could you please help me in finding right way to use alias with sql query in shell script. Below is the code i am using. #!/bin/bash sqlplus -s abc/abc@abc << EOF> bcd.csv set trimspool on select zone_id... (4 Replies)
Discussion started by: as7951
4 Replies
ASIP-STATUS.PL(1)						   Netatalk 2.2 						 ASIP-STATUS.PL(1)

NAME
asip-status.pl - Queries AFP servers for their capabilities SYNOPSIS
asip-status.pl [-d] [-i] [-x] HOSTNAME[:PORT] asip-status.pl -v | -version | --version DESCRIPTION
asip-status.pl is a perl script that sends a FPGetSrvrInfo request to an AFP server at HOSTNAME:PORT and displays the results, namely "Machine type", the server's name, supported AFP versions, UAMs and AFP flags, the "server signature" and the network addresses, the server provides AFP services on. When you don't supply :PORT, then the default AFP port, 548, will be used. OPTIONS
-d Enable debug output. -i Show icon if it exists. -x Enable hex dump output. -v, -version, --version Show version. EXAMPLES
asip-status.pl 192.168.21.2 AFP reply from 192.168.21.2:548 Flags: 1 Cmd: 3 ID: 57005 Reply: DSIGetStatus Request ID: 57005 Machine type: Macintosh AFP versions: AFPVersion 1.1,AFPVersion 2.0,AFPVersion 2.1,AFP2.2 UAMs: Cleartxt passwrd,Randnum exchange,2-Way Randnum exchange Flags: SupportsCopyFile,SupportsChgPwd,SupportsServerMessages, SupportsServerSignature,SupportsTCP/IP,SupportsSuperClient Server name: PowerMac 9600/200 Signature: 04 c1 6e 59 04 c1 6e 59 04 c1 6e 59 04 c1 6e 59 ..nY..nY..nY..nY Network address: 192.168.21.2:548 (tcp/ip address and port) Network address: 10.20 (ddp address) asip-status.pl myserver:10548 AFP reply from myserver:10548 Flags: 1 Cmd: 3 ID: 57005 Reply: DSIGetStatus Request ID: 57005 Machine type: Netatalk AFP versions: AFPVersion 1.1,AFPVersion 2.0,AFPVersion 2.1,AFP2.2,AFPX03, AFP3.1 UAMs: Cleartxt passwrd,Randnum exchange,2-Way Randnum exchange,DHCAST128 Flags: SupportsCopyFile,SupportsServerMessages,SupportsServerSignature, SupportsTCP/IP,SupportsSrvrNotifications,SupportsOpenDirectory, SupportsUTF8Servername,SupportsSuperClient Server name: Fire V480 Signature: 83 29 cc 60 83 29 cc 60 83 29 cc 60 83 29 cc 60 .).`.).`.).`.).` Network address: 192.168.21.1:10548 (TCP/IP address and port) Network address: 65282.142 (ddp address) UTF8 Servername: Fire V480 REPORTING BUGS
Report bugs to the Netatalk-devel list <netatalk-devel@lists.sourceforge.net>. Netatalk 2.2 02 Sep 2011 ASIP-STATUS.PL(1)
All times are GMT -4. The time now is 09:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy