Sponsored Content
Top Forums Shell Programming and Scripting output arguments from a sqlplus Post 302357210 by shell_zen on Tuesday 29th of September 2009 05:50:04 AM
Old 09-29-2009
output arguments from a sqlplus

Hi.

I need to output a 4 queries result into another application using
result=`sqlplus -s ${3}/${4}@${2} << EOF
...
query1
query2
query3
query4
....
echo "$metrics1"

and returning those individual values into another app.
(query1 and 3compute one value, query 2 and 4 compute 4 values. All of them floats)
For a normal situation I output the values this way,
server_avail1=`echo $tt1| awk '{print $1}'`; server_term1=`echo $tt1| awk '{print $7}'`;
server_menu_avail=`echo $tt1| awk '{print $2}'`; server_menu_avail=`echo $tt1| awk '{print $3}'`; ...............
the problem I'm facing is sometimes some values of a query are returned NULL and thus aren't echoed, which breaks my static outputting (and if the 1st value of the 2nd query goes NULL, the values that goes into server_menu_avail is the 2nd val of the 2nd query, etc)

To gain a little control, I tried to force substituting those NULLs with a 'NULL' word
echo "$scfmetrics1" | sed 's/^$/NULL/g'
but it's getting an extra NULL between the result of query1 and 2, and query 3 and 4.
Eg: 0 NULL NULL 100 NULL 100 100 NULL 0 NULL NULL 88.46 NULL 99.12 100

Any idea how to skin this rabbit?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File Format issue: Output of sqlplus

Hi, I am using a query like below in my shell script : { { echo "set echo off" echo "set head off" echo "whenever sqlerror exit -1; select NUMBER ||','|| FNAME ||','|| LOC ||','|| ... (2 Replies)
Discussion started by: deepakgang
2 Replies

2. UNIX for Advanced & Expert Users

sqlPlus output with new line character

Hi, I have a script which calls a sqlplus command and i'm saving the output in a variable. Z=`sqlplus -s $TC_ORACLE_USER/$TC_ORACLE_PASSWORD@$TC_CONNECT_STRING <<eof set echo off set head off set serveroutput on; set feedback off; select description from period where trunc(sysdate)... (2 Replies)
Discussion started by: decci_7
2 Replies

3. UNIX for Dummies Questions & Answers

Getting output parameter in sqlplus

I need to get the output parameter from a stored procedure in sql plus using shell script. Can anyone help me please ... (1 Reply)
Discussion started by: risshanth
1 Replies

4. Shell Programming and Scripting

Formatting Oracle sqlplus output

a job extracts orcle data into unix as flat file. a single record breaks into two record in unix flat file. This is the case only for 6 records out of 60 lack records. (its not single record in two line. but its single record into record. ie., \n come into picture) can you tell me what... (6 Replies)
Discussion started by: Gopal_Engg
6 Replies

5. Shell Programming and Scripting

store sqlplus output in variable

hi how can i store sqlplus output to a variable in sh script (not bash) Thanks MM (1 Reply)
Discussion started by: murtymvvs
1 Replies

6. Shell Programming and Scripting

Log sqlplus output from Shell

UNIX Gods, I'll be running this script from CRON. I need to log the status of each of the six sqlplus calls into a file when this job is kicked off. Any suggestions? Thanks in advance. #!/bin/ksh export USAGE="USAGE: `basename $0` -e <DBUSER> <DBPASSWD> <TNSNAME>" if ; then ... (2 Replies)
Discussion started by: WhoDatWhoDer
2 Replies

7. Solaris

sqlplus output from ksh.

Hi All, I have the below simple script. It runs just fine by itself when I manually invoke it. But once I put it in the crontab with entry: * * * * * /users/myuser/test.ksh >> /users/myuser/log/test.txt" It does NOT print the returned value ($REMAIN) from the DB!? The result in the... (3 Replies)
Discussion started by: steve701
3 Replies

8. Shell Programming and Scripting

Sending sqlplus output to a shell variable

I am trying to import a sqlplus output into a shell variable but it doesnt seem to be working. set -x export DEPENDENT_CR_NO=`sqlplus -s /nolog <<EOF conn username/passwd set heading off select dependency from custom_patches where patch_name='PATCH.zip'; exit; EOF` echo $DEPENDENT_CR_NO ... (2 Replies)
Discussion started by: beginer314
2 Replies

9. Shell Programming and Scripting

Sqlplus function output to bash

Hi, I would like to have the output from an Oracle procedure be captured into a bash variable, then emailed to me when it runs on the cron daily as such: ~~~~~bash script~~~~~~~~~~~ #!/bin/bash shellvar=`sqlplus -s <<EOF execute test(); commit; exit; EOF` echo $shellvar mail -s "email... (1 Reply)
Discussion started by: inlinesidekick
1 Replies

10. Shell Programming and Scripting

Passing sqlplus output to shell variable

Hi , I am using below code : for i in `ps -ef|grep pmon|awk {' print $8 '}|cut -f3 -d'_'|grep -v '^grep'` do ORACLE_SID=$i export ORACLE_SID; dest=`sqlplus "/ as sysdba" <<EOF set heading off feedback on verify off select DESTINATION from v\\$archive_dest where target in... (5 Replies)
Discussion started by: admin_db
5 Replies
INGRES_RESULT_SEEK(3)							 1						     INGRES_RESULT_SEEK(3)

ingres_result_seek - Set the row position before fetching data

SYNOPSIS
bool ingres_result_seek (resource $result, int $position) DESCRIPTION
This function is used to position the cursor associated with the result resource before issuing a fetch. If ingres.array_index_start is set to 0 then the first row is 0 else it is 1. ingres_result_seek(3) can be used only with queries that make use of scrollable cursors. It cannot be used with ingres_unbuffered_query(3). Note Related Configurations See also the ingres.scrollable and ingres.array_index_start directives in Runtime Configuration. PARAMETERS
o $result - The result identifier for a query o $position - The row to position the cursor on. If ingres.array_index_start is set to 0, then the first row is 0, else it is 1 RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Position the cursor on the 3rd row <?php $result=ingres_query($link, "select * from airport where ap_ccode = 'ES' order by ap_place asc"); /* goto row 3 */ if (!ingres_result_seek($result, 3)) { echo ingres_errno() . " - " . ingres_error . " "; die("i died"); } else { $airport = ingres_fetch_object ($result); { echo $airport->ap_iatacode . " - " . $airport->ap_name . " "; } } ingres_commit($link); ?> SEE ALSO
ingres_query(3), ingres_fetch_array(3), ingres_fetch_assoc(3), ingres_fetch_object(3), ingres_fetch_row(3). PHP Documentation Group INGRES_RESULT_SEEK(3)
All times are GMT -4. The time now is 08:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy