Sponsored Content
Top Forums Shell Programming and Scripting Connecting sqlplus from UNIX with multiple select statement Post 302773867 by lovelysethii on Friday 1st of March 2013 12:15:47 AM
Old 03-01-2013
Connecting sqlplus from UNIX with multiple select statement

hi,
i have a requirement where i need to connect sqlplus from unix and i am able to do so by following command:
Code:
cust_count=`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF
                set pagesize 0
                set feedback off
                set verify off
                set heading off
                select count(*) from BCHISTEVENT b, bcuser u
                where b.type != 'com.avolent.apps.event.LogoutEvent'
                and b.actinguserid = u.identifier
                and u.type = 'CustomerView'
                /*and (to_char(b.createdt, 'dd/mm/yy hh24:mi:ss') between
                to_char((SYSTIMESTAMP - INTERVAL '30' MINUTE),'dd/mm/yy hh24:mi:ss') and to_char(SYSTIMESTAMP,'dd/mm/yy hh24:
mi:ss'))*/
                AND b.bucket = to_char(sysdate, 'YYYYMM')
                group by u.type;
EOF`


but i have one more select statement here and if i am using the same above command then i am getting no output while echoing the variabe value:
Code:
biller_count=`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID   << EOF
                set pagesize 0
                set feedback off
                set verify off
                set heading off
                select count(*) from BCHISTEVENT b, bcuser u
                where b.type != 'com.avolent.apps.event.LogoutEvent'
                and b.actinguserid = u.identifier
                and u.type = ' BillerAdminView'
                /*and (to_char(b.createdt, 'dd/mm/yy hh24:mi:ss') between
                to_char((SYSTIMESTAMP - INTERVAL '30' MINUTE),'dd/mm/yy hh24:mi:ss') and to_char(SYSTIMESTAMP,'dd/mm/yy hh24:
mi:ss'))*/
                AND b.bucket = to_char(sysdate, 'YYYYMM')
                group by u.type;
EOF`


echo "Total # of users Logged in @ last 30 minutes . Customer View    :$cust_count">>vmstat.txt;
echo "Total # of users Logged in @ last 30 minutes . Biller View      :$biller_count">>vmstat.txt;


plss suggest how to acheive this....thanks in advance

Last edited by Franklin52; 03-01-2013 at 03:10 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

error connecting to sqlplus

Hi, I wrote a shell script to call oracle procedure. But when i am trying to connet sqlplus with the fallowing statement It is giving me error " callproce.sh : sqlplus: not found". What could be the problem. sqlplus -s $CONNECT_STRING >$LOGFILE <<!! thank u all papachi (2 Replies)
Discussion started by: papachi
2 Replies

2. Windows & DOS: Issues & Discussions

Want to use the output of Select statement in Unix script

Hi, I have a UNIX script which calls SQL Select statement: Now i want to use the output of that select statement within my UNIX script so as to call different shell script depending upon the output of the select statement. Can anyone help me in this regard. TIA Akhil Goel (4 Replies)
Discussion started by: akhilgoel9
4 Replies

3. 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

4. Shell Programming and Scripting

connecting through sqlplus

I am trying to connect to one of the oracle sever using uni through sqlplus command: sqlplus -s BOXI_ALPH_AUDITOR,Q078_audit$@Q047 But its not getting connected. I tried using some different server using same syntax its working. What differene i found is the password is having no special... (2 Replies)
Discussion started by: gander_ss
2 Replies

5. UNIX for Dummies Questions & Answers

Connecting to Oracle DB using sqlplus

Hi, I am very new to shell scripting and trying to write a simple shell script in which i am trying to achieve the following: 1. Connect to oracle database hosted on a different server 2. fire a query on the oracle db 3. store the output in a variable 4. use this variable for further logic... (1 Reply)
Discussion started by: shrutihardas
1 Replies

6. Shell Programming and Scripting

Connecting to Oracle DB using sqlplus

Hi, I am very new to shell scripting and trying to write a simple shell script in which i am trying to achieve the following: 1. Connect to oracle database hosted on a different server 2. fire a query on the oracle db 3. store the output in a variable 4. use this variable for further logic... (26 Replies)
Discussion started by: shrutihardas
26 Replies

7. UNIX for Advanced & Expert Users

Connecting once using sqlplus and doing multiple queries

Hello everyone, It's my first week using unix and shell scripting. I tried creating a script that has a function that execute SQL query. my script looks something like this: ---------------------------------------------------- #!/bin/sh tableName="myTable" secondTable="secondTable"... (2 Replies)
Discussion started by: edlin_r
2 Replies

8. Shell Programming and Scripting

connecting to table to extract multiple rows into file from unix script

I need to extract the data from oracle table and written the below code. But it is not working.There is some problem with the query and output is shown is No rows selected" . If I run the same query from sql developer there is my required output. And if I run the shell script with simple sql... (7 Replies)
Discussion started by: giridhar276
7 Replies

9. Shell Programming and Scripting

SQLPLUS command with more than 1 select statement

Hi all, I'm using below code processId=`sqlplus -s ${sysuser}/${syspwd} <<CHK_PROCESS whenever sqlerror exit sql.sqlcode; set head off feedback off echo off pages 0 SELECT PROCESS_ID FROM LSHADMIN.DATA_DOMAIN WHERE DOMAIN_NAME = '${tabname}' ... (8 Replies)
Discussion started by: Pratiksha Mehra
8 Replies

10. Shell Programming and Scripting

UNIX Sqlplus - Capture the sql statement about to run and execution status

Greetings Experts, I am on AIX using ksh. Created a unix script which generates the CREATE OR REPLACE VIEW ... and GRANT .. statements, which are placed in a single .txt file. Now I need to execute the contents in the file (there are around 300 view creation and grant statements) in Oracle and... (4 Replies)
Discussion started by: chill3chee
4 Replies
OCI_SET_ACTION(3)														 OCI_SET_ACTION(3)

oci_set_action - Sets the action name

SYNOPSIS
bool oci_set_action (resource $connection, string $action_name) DESCRIPTION
Sets the action name for Oracle tracing. The action name is registered with the database when the next 'roundtrip' from PHP to the database occurs, typically when an SQL statement is executed. The action name can subsequently be queried from database administration views such as V$SESSION. It can be used for tracing and monitor- ing such as with V$SQLAREA and DBMS_MONITOR.SERV_MOD_ACT_STAT_ENABLE. The value may be retained across persistent connections. PARAMETERS
o $connection -An Oracle connection identifier, returned by oci_connect(3), oci_pconnect(3), or oci_new_connect(3). o $action_name - User chosen string up to 32 bytes long. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Setting the action <?php $c = oci_connect('hr', 'welcome', 'localhost/XE'); // Record the action oci_set_action($c, 'Friend Lookup'); // Code that causes a roundtrip, for example a query: $s = oci_parse($c, 'select * from dual'); oci_execute($s); oci_fetch_all($s, $res); sleep(30); ?> // While the script is running, the administrator can see the actions // being performed: sqlplus system/welcome SQL> select action from v$session; NOTES
Note Oracle version requirement This function is available when PHP is linked with Oracle Database libraries from version 10 g onwards. Tip Performance With older versions of OCI8 or the Oracle Database, the client information can be set using the Oracle DBMS_APPLICATION_INFO pack- age. This is less efficient than using oci_set_client_info(3). Caution Roundtrip Gotcha Some but not all OCI8 functions cause roundtrips. Roundtrips to the database may not occur with queries when result caching is enabled. SEE ALSO
oci_set_module_name(3), oci_set_client_info(3), oci_set_client_identifier(3). PHP Documentation Group OCI_SET_ACTION(3)
All times are GMT -4. The time now is 01:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy