Sponsored Content
Top Forums Shell Programming and Scripting How to pass Variable from shell script to select query for SqlPlus? Post 302857189 by aroragaurav.84 on Wednesday 25th of September 2013 03:16:27 PM
Old 09-25-2013
How to pass Variable from shell script to select query for SqlPlus?

Code:
echo "set echo off"; echo "set feedback off"; echo "set linesize 4000"; echo " set pagesize 0"; echo " set sqlprompt ''"; echo " set trimspool on"; 

Select statement is mentioned below
echo "select res.ti_book_no from disney_ticket_history res where res.ti_status =${STATUS} and res.request_file_id IN (select req.request_file_id from disney_ticket_request_file req  where transaction_date=${TRANSACTION_DATE});") | ${ORACLE_HOME}/bin/sqlplus -S tipls/tipls@plsdev)

OUTPUT IN SQL WITH ERROR:
select res.ti_book_no from disney_ticket_history res where res.ti_status =('\''PENDING'\'') and res.request_file_id IN (select req.request_file_id from disney_ticket_request_file req  where transaction_date=09212013)

ERROR at line 1:
ORA-00911: invalid character

Error is due to highligted red colour. I need to pass it as a string like 'PENDING' through script

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass variable to SQLPLUS in a ksh script?

Hi, I am writing a ksh script which will use sqlplus to run a sql and pass 2 variables as the SQL request. In the ksh script, I have 2 variables which are $min_snap and $max_snap holding 2 different numbers. Inside the same script, I am using SQLPLUS to run an Oracle SQL script,... (6 Replies)
Discussion started by: rwunwla
6 Replies

2. UNIX for Dummies Questions & Answers

select count(*) in sqlplus into variable unix shell

Need to select count(*) from table to check for zero result in unix script (2 Replies)
Discussion started by: struggle
2 Replies

3. Shell Programming and Scripting

How to pass parameter from sqlplus(procedure completed) to your shell script

if then # mail -s "Import failed file does not exist" sanjay.jaiswal@xyz.com echo "FILE does not exist" exit 1 fi echo "FILE EXIST" size=-1 set $(du /export/home/oracle/nas/scott21.dmp.gz) while do echo "Inside the loop" size=$1 set $(du... (1 Reply)
Discussion started by: sanora600
1 Replies

4. Shell Programming and Scripting

In a csh script, can I set a variable to the result of an SQLPLUS select query?

Can someone tell me why I'm getting error when I try to run this? #!/bin/csh -f source ~/.cshrc # set SQLPLUS = ${ORACLE_HOME}/bin/sqlplus # set count=`$SQLPLUS -s ${DB_LOGIN} << END select count(1) from put_groups where group_name='PC' and description='EOD_EVENT' and serial_number=1;... (7 Replies)
Discussion started by: gregrobinsonhd
7 Replies

5. Shell Programming and Scripting

redirecting oracle sqlplus select query into file

So, I would like to run differen select queries on multiple databases.. I made a script wich I thought to be called something like.. ./script.sh sql_file_name out.log or to enter select statement in a command line.. (aix) and I did created some shell script wich is not working.. it... (6 Replies)
Discussion started by: bongo
6 Replies

6. Shell Programming and Scripting

Problems with storing oracle sqlplus query output shell script

Hello everyone, I have a RHEL 5 system and have been trying to get a batch of 3-4 scripts each in a separate variables and they are not working as expected. I tried using following syntax which I saw a lot of people on this site use and should really work, though for some reason it doesn't... (3 Replies)
Discussion started by: rockf1bull
3 Replies

7. Shell Programming and Scripting

How to run a SQL select query in Oracle database through shell script?

I need to run a SQL select query in Oracle database and have to capture the list of retrieved records in shell script. Also i would like to modify the query for certain condition and need to fetch it again. How can i do this? Is there a way to have a persistent connection to oracle database... (9 Replies)
Discussion started by: vel4ever
9 Replies

8. Shell Programming and Scripting

How to print the output of a select query using shell script?

HI, I want to connect to database and fetch the count from a table. The sql query is as below : select count(*) from table_test where test_column='read'; How can I print the output of this statement using shell script. Thanks in advance. (4 Replies)
Discussion started by: confused_info
4 Replies

9. Shell Programming and Scripting

Shell Script (ksh) - SQLPlus query filter using a string variable

Using ksh, I am using SQLPlus to execute a query with a filter using a string variable. REPO_DB=DEV1 FOLDER_NM='U_nmalencia' FOLDER_CHECK=$(sqlplus -s /nolog <<EOF CONNECT user/pswd_select@${REPO_DB} set echo off heading off feedback off select subj_name from subject where... (5 Replies)
Discussion started by: nkm0brm
5 Replies

10. Shell Programming and Scripting

Pass a VARIABLE to sqlplus script

Hi Team, I am trying to run a sqlplus script against several databases via a FOR/LOOP and also passing the loop variable to a sqlplus script I am calling, as follows: #!/bin/bash export ORACLE_SID=plgc1 export ORACLE_HOME=/opt/oracle/product/11.2.0.2/db_1 export... (1 Reply)
Discussion started by: jonnyd
1 Replies
DB2_ROLLBACK(3) 							 1							   DB2_ROLLBACK(3)

db2_rollback - Rolls back a transaction

SYNOPSIS
bool db2_rollback (resource $connection) DESCRIPTION
Rolls back an in-progress transaction on the specified connection resource and begins a new transaction. PHP applications normally default to AUTOCOMMIT mode, so db2_rollback(3) normally has no effect unless AUTOCOMMIT has been turned off for the connection resource. PARAMETERS
o $connection - A valid database connection resource variable as returned from db2_connect(3) or db2_pconnect(3). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Rolling back a DELETE statement In the following example, we count the number of rows in a table, turn off AUTOCOMMIT mode on a database connection, delete all of the rows in the table and return the count of 0 to prove that the rows have been removed. We then issue db2_rollback(3) and return the updated count of rows in the table to show that the number is the same as before we issued the DELETE statement. The return to the original state of the table demonstrates that the roll back of the transaction succeeded. <?php $conn = db2_connect($database, $user, $password); if ($conn) { $stmt = db2_exec($conn, "SELECT count(*) FROM animals"); $res = db2_fetch_array( $stmt ); echo $res[0] . " "; // Turn AUTOCOMMIT off db2_autocommit($conn, DB2_AUTOCOMMIT_OFF); // Delete all rows from ANIMALS db2_exec($conn, "DELETE FROM animals"); $stmt = db2_exec($conn, "SELECT count(*) FROM animals"); $res = db2_fetch_array( $stmt ); echo $res[0] . " "; // Roll back the DELETE statement db2_rollback( $conn ); $stmt = db2_exec( $conn, "SELECT count(*) FROM animals" ); $res = db2_fetch_array( $stmt ); echo $res[0] . " "; db2_close($conn); } ?> The above example will output: 7 0 7 SEE ALSO
db2_autocommit(3), db2_commit(3). PHP Documentation Group DB2_ROLLBACK(3)
All times are GMT -4. The time now is 11:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy