Sponsored Content
Top Forums Shell Programming and Scripting How to get and process mysql result set in shell script Post 302340332 by ashok1979 on Monday 3rd of August 2009 08:28:54 AM
Old 08-03-2009
Actually i have data in SQLRESULT variable, which i am getting by below statement
SQLRESULT=$(/usr/bin/mysql -uabc -pabc abc -sN -e "SELECT ID, ORG_ID, TRANS_ID FROM SS_TRIGGERED_EVENT WHERE STATUS = 'P' ;")
and when i use below statement i get a single line containing all the rows like
echo "Result from table..."$SQLRESULT
1 2180 10 2 2186 11 3 2198 12

So i was not getting how to loop through it...
 

9 More Discussions You Might Find Interesting

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

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

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

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

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

6. Shell Programming and Scripting

How do i access sybase using isql and how do i get result set in perl script?

Hi, How do i get result set in perl script using isql while connecting sybase server. I have a perl script which connected to sybase and get the result set. but i wanted to get the result set. How do i get the result set in perl script not unix shell script.. $server ="ServerName"; open... (1 Reply)
Discussion started by: solo123
1 Replies

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

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

9. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies
DB2_NUM_ROWS(3) 							 1							   DB2_NUM_ROWS(3)

db2_num_rows - Returns the number of rows affected by an SQL statement

SYNOPSIS
int db2_num_rows (resource $stmt) DESCRIPTION
Returns the number of rows deleted, inserted, or updated by an SQL statement. To determine the number of rows that will be returned by a SELECT statement, issue SELECT COUNT(*) with the same predicates as your intended SELECT statement and retrieve the value. If your application logic checks the number of rows returned by a SELECT statement and branches if the number of rows is 0, consider modi- fying your application to attempt to return the first row with one of db2_fetch_assoc(3), db2_fetch_both(3), db2_fetch_array(3), or db2_fetch_row(3), and branch if the fetch function returns FALSE. Note If you issue a SELECT statement using a scrollable cursor, db2_num_rows(3) returns the number of rows returned by the SELECT state- ment. However, the overhead associated with scrollable cursors significantly degrades the performance of your application, so if this is the only reason you are considering using scrollable cursors, you should use a forward-only cursor and either call SELECT COUNT(*) or rely on the boolean return value of the fetch functions to achieve the equivalent functionality with much better perfor- mance. PARAMETERS
o $stmt - A valid stmt resource containing a result set. RETURN VALUES
Returns the number of rows affected by the last SQL statement issued by the specified statement handle. PHP Documentation Group DB2_NUM_ROWS(3)
All times are GMT -4. The time now is 03:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy