Sponsored Content
Top Forums Shell Programming and Scripting get result from database into shell script Post 302257746 by ali560045 on Thursday 13th of November 2008 02:22:24 AM
Old 11-13-2008
get result from database into shell script

hi,

I have a script that will logon to a database siebel and do the select query and then get the result in command prompt of unix.Below the script.

#!/bin/ksh


. $HOME/conf/systemProperties/EnvSetup.properties

#set -x
while read i
do
echo $i

connect1=`sqlplus -silent siebel/home1@ednamip.world <<END
set pagesize 0 feedback off verify off heading off echo off
SELECT Premise.X_CLIENT_PRMSE_ID,
meter.X_UDC_ASSET_ID
FROM
SIEBEL.S_ASSET Meter,
SIEBEL.S_ASSET SDP,
SIEBEL.s_asset_rel ARSM,
SIEBEL.S_ADDR_PER Premise,
SIEBEL.S_ASSET Route,
SIEBEL.s_asset_rel ARSR
WHERE
-- sdp to meter
ARSM.par_asset_id = SDP.row_id AND
ARSM.asset_id = Meter.row_id AND
ARSM.relation_type_cd = 'SDP-METER' AND
ARSM.x_rel_status = 'Active' AND
-- SDP to PREMISE
SDP.PER_ADDR_ID = Premise.row_id AND
-- SDP to Route
ARSR.par_asset_id = Route.row_id AND
ARSR.asset_id = SDP.row_id AND
ARSR.relation_type_cd = 'ROUTE-SDP' AND
ARSR.x_rel_status = 'Active' AND
Premise.X_CLIENT_PRMSE_ID = '$i'
exit;
END`
echo "$connect1" >> /ednadtu3/u01/pipe/naveed/class/nav1.txt
echo "Completed for $i"
done < TNS_AMRI_INACTIVE.txt
--------------------------------------------------------------------------contents of TNS_AMRI_INACTIVE.txt

0001636564
0001644841
0008076686
0001644965
--------------------------------------------------------------------------

result should i get in a file nav1.txt is:

0001644965 092276477LG
0008076686 090030615LG
0001644841 090845090LG
0001636564 090845086LG
-----------------------------------------------------------------------

but the file nav1.txt showing the below error when i cat it:

exit
*
ERROR at line 21:
ORA-00933: SQL command not properly ended
exit
*
ERROR at line 21:
ORA-00933: SQL command not properly ended
exit
*
ERROR at line 21:
ORA-00933: SQL command not properly ended
exit
*
ERROR at line 21:
ORA-00933: SQL command not properly ended

--------------------------------------------------------------------------

but the query is working fine in databse. plz help me in this?

Last edited by ali560045; 11-13-2008 at 03:28 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Could any one tell me how to do get result in fraction in shell script

Could any one tell me how to do get result in fraction in shell script. I am using expr for division of 2 number but it is giving Quitent. I need it in full fraction value. please helpp. how to do it using "dc" or "bc" (5 Replies)
Discussion started by: Neerajjaiswal
5 Replies

2. AIX

The shell script is not returning proper result

Can anybody pls look into this script and tell me where I went wrong. After running this script, it is showing like "Trying to overlay current working directory ABORT!!!" :-( ARGCNT=$# if then echo "Two parameters are needed for this shell " echo "Please try again with... (1 Reply)
Discussion started by: clnsharma123
1 Replies

3. Shell Programming and Scripting

shell script result to file

Since I'm not an expert in shell scripting, I have question on sending script result to file. I have script like this... if condition=0: then echo "service is not running" | mail -s "Server Status" uname@companyname fi sleep 10 if configtion=1: then echo "service is not running" | mail -s... (3 Replies)
Discussion started by: s_linux
3 Replies

4. Shell Programming and Scripting

How to get and process mysql result set in shell script

Hi All, I am in a problem here is the description, Actually in my shell script i am firing a mysql query which returns multiple records and i have to process each record one by one. So could any one please suggest me how to solve my problem? Thanks in Advance Ashok Sharma (4 Replies)
Discussion started by: ashok1979
4 Replies

5. Homework & Coursework Questions

A function in shell script,how can i get the right result

there is a directory /data/users/osa/psidp/dmp/files/cimdir ,it have some subdirectories ,and also the subdirectoriy have it's subdirectoriis. I want to get all the leaf nodes of the directory path . but the result of the script is wrong ,how can i get the right result somebody who can help... (1 Reply)
Discussion started by: fw0037
1 Replies

6. Shell Programming and Scripting

a function in shell script,how can i get the right result

there is a directory /data/users/osa/psidp/dmp/files/cimdir ,it have some subdirectories ,and also the subdirectoriy have it's subdirectoriis. I want to get all the leaf nodes of the directory path . but the result of the script is wrong ,how can i get the right result somebody who can... (1 Reply)
Discussion started by: fw0037
1 Replies

7. Shell Programming and Scripting

A function in shell script,how can i get the right result

there is a directory /data/users/osa/psidp/dmp/files/cimdir ,it have some subdirectories ,and also the subdirectoriy have it's subdirectoriis. I want to get all the leaf nodes of the directory path . but the result of the script is wrong ,how can i get the right result somebody who can help me... (3 Replies)
Discussion started by: fw0037
3 Replies

8. Shell Programming and Scripting

shell script - unexpected result

I hv a file --am executing a script which is giving me unexpected results COntents of file: f1 CMT_AP1_CONT:/opt/sybase/syboc125:150:ASE12_5::Y:UX: CMT_AP1:/opt/sybase/syboc125:150:ASE12_5::Y:UX f1.tmp CMT_AP1_CONT:/opt/sybase/syboc125:150:ASE12_5::Y:UX:... (2 Replies)
Discussion started by: rajashekar.y
2 Replies

9. Shell Programming and Scripting

Executing the result of a program as a shell script

I have a program that returns a shell script and I want to execute the script. I'll use cat in my simple example, but wget is an example that is feasible. $ # First setup a script $ echo "ls > df" > simple $ # "cat simple" is now a program that returns a script $ cat simple ls df $ ... (3 Replies)
Discussion started by: kopite
3 Replies

10. Programming

Query result from shell script

Hi, I wrote the below script to get the query result from a Syabase DB. isql -s -U **** -P **** SYBASE SERVERNAME USE ***(Database name in Sybase) @command.sql But im not getting the output. Can anyone help me on this (2 Replies)
Discussion started by: rohan G
2 Replies
SQLITE_EXEC(3)															    SQLITE_EXEC(3)

sqlite_exec - Executes a result-less query against a given database

SYNOPSIS
bool sqlite_exec (resource $dbhandle, string $query, [string &$error_msg]) DESCRIPTION
bool sqlite_exec (string $query, resource $dbhandle) Object oriented style (method): bool SQLiteDatabase::queryExec (string $query, [string &$error_msg]) Executes an SQL statement given by the $query against a given database handle (specified by the $dbhandle parameter). Warning SQLite will execute multiple queries separated by semicolons, so you can use it to execute a batch of SQL that you have loaded from a file or have embedded in a script. PARAMETERS
o $dbhandle - The SQLite Database resource; returned from sqlite_open(3) when used procedurally. This parameter is not required when using the object-oriented method. o $query - The query to be executed. Data inside the query should be properly escaped. o $error_msg - The specified variable will be filled if an error occurs. This is specially important because SQL syntax errors can't be fetched using the sqlite_last_error(3) function. Note Two alternative syntaxes are supported for compatibility with other database extensions (such as MySQL). The preferred form is the first, where the $dbhandle parameter is the first parameter to the function. RETURN VALUES
This function will return a boolean result; TRUE for success or FALSE for failure. If you need to run a query that returns rows, see sqlite_query(3). The column names returned by SQLITE_ASSOC and SQLITE_BOTH will be case-folded according to the value of the sqlite.assoc_case configuration option. CHANGELOG
+--------+---------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------+ | 5.1.0 | | | | | | | Added the $error_msg parameter | | | | +--------+---------------------------------+ EXAMPLES
Example #1 Procedural example <?php $dbhandle = sqlite_open('mysqlitedb'); $query = sqlite_exec($dbhandle, "UPDATE users SET email='jDoe@example.com' WHERE username='jDoe'", $error); if (!$query) { exit("Error in query: '$error'"); } else { echo 'Number of rows modified: ', sqlite_changes($dbhandle); } ?> Example #2 Object-oriented example <?php $dbhandle = new SQLiteDatabase('mysqlitedb'); $query = $dbhandle->queryExec("UPDATE users SET email='jDoe@example.com' WHERE username='jDoe'", $error); if (!$query) { exit("Error in query: '$error'"); } else { echo 'Number of rows modified: ', $dbhandle->changes(); } ?> SEE ALSO
sqlite_query(3), sqlite_unbuffered_query(3), sqlite_array_query(3). PHP Documentation Group SQLITE_EXEC(3)
All times are GMT -4. The time now is 03:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy