Might I suggest that you alter your SQL call to something like this:-
This should get rid of much of the unwanted parts and (assuming that you have only one lines returned) will parse the output into values $col1, $col2, $col3, etc. for you to work with later in your script.
Using the format above hides the credentials from a ps command that anyone could be running. The two set commands turn off the titles and the page split respectively. The -S flag will prevent the output of the usual banner messages when starting SQL.
I hope that this helps. If I've missed the point, please post the section of code you are stuck with, including the SQL call.
Hi,
My requirement is :
We are calling an sql statement from a UNIX session, and fetching data into some variables from a table .. now we are unable to access these variables from outside the SQL part. Please let me know how can I achieve this.
Can you please share a code snippet which... (4 Replies)
i'm used a sql query in a unix script to get the information from table. but unable to extract the output which i need. Any help with logic will be greatly appreciated.
my sql query provide output some thing like this -
col1 col2 count
---- ---- ------
A B 10
c D 6
e... (8 Replies)
Hi,
I am executing sql files in my unix shell script. Now i want to find whether its a success or a failure record and redirect the success or failure to the respective files. meaning.
success records to success.log file
failure record to failure.log file.
As of now i am doing like... (1 Reply)
Hello Guys,
This message is somewhat relates with last thread. But I need to re-write thing. I start over a little. I am stuck now and need your help.
Here is my script-
#! /bin/ksh
export ORACLE_HOME=/opt/oracle/app/oracle/product/9.2
/opt/oracle/app/oracle/product/9.2/bin/sqlplus -s... (5 Replies)
Hi
I want ot save SQL query result in one txt file. for that i have written one code line
sqlplus -s $dbstring @/usr/local/bin/sched/nightly_Cronjob/exec_123.sql >> /usr/local/bin/sched/nightly_Cronjob/result.txt
but it is not working .
database : Oracle
so please advice me how can i... (7 Replies)
Hi All,
#!/bin/ksh
call_sql ()
{
sql=$1
sqlplus -s $sqlparam_sieb <<EOF
SET ECHO OFF;
SET NEWPAGE NONE;
SET SQLBL OFF;
SET VERIFY OFF;
SET LINESIZE 2000;
SET... (2 Replies)
Hi
I am trying to run sql query from solaris in csh script and send the output to email. Below is my sql query
select p.spid,se.program seprogram, se.machine, se.username, sq.sql_text,sq.retrows from v$process p
inner join v$session se on p.addr = se.paddr
inner join
( select... (2 Replies)
Hi
iam new to shell scripting
how to declare variables as redshift query and I have to compare two counts by using if condition .
ex:count=select count(*) from prd;
select count(*) from prd;
select count(*) from tag;
can any one help me .
Please use CODE tags when displaying... (1 Reply)
I am writing the following script to create the file v_out.txt.
sqlplus -s /nolog << EOF
CONNECT scott/tiger@orcl;
whenever sqlerror exit sql.sqlcode;
set newpage 0;
SET PAGESIZE 0;
SET ECHO OFF;
SET FEEDBACK OFF;
SET HEADING OFF;
SET VERIFY OFF;
SET LINESIZE 100;
set tab off;
set... (7 Replies)
Hi Team,
below sql rerturn 20 records, the result set i am going to assign to one variable and it showing count is 1.
and i don't use count() in sql query... based on count, i need to fail the script.
No_of_step=`echo ${g_count} | wc -l`
function gf_count()
{
g_count=`sqlplus -s... (8 Replies)
Discussion started by: bmk123
8 Replies
LEARN ABOUT PHP
sqlsrv_rows_affected
SQLSRV_ROWS_AFFECTED(3)SQLSRV_ROWS_AFFECTED(3)sqlsrv_rows_affected - Returns the number of rows modified by the last INSERT, UPDATE, or DELETE query executedSYNOPSIS
int sqlsrv_rows_affected (resource $stmt)
DESCRIPTION
Returns the number of rows modified by the last INSERT, UPDATE, or DELETE query executed. For information about the number of rows
returned by a SELECT query, see sqlsrv_num_rows(3).
PARAMETERS
o $stmt
- The executed statement resource for which the number of affected rows is returned.
RETURN VALUES
Returns the number of rows affected by the last INSERT, UPDATE, or DELETE query. If no rows were affected, 0 is returned. If the number of
affected rows cannot be determined, -1 is returned. If an error occurred, FALSE is returned.
EXAMPLES
Example #1
sqlsrv_rows_affected(3) example
<?php
$serverName = "serverNamesqlexpress";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password" );
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$sql = "UPDATE Table_1 SET data = ? WHERE id = ?";
$params = array("updated data", 1);
$stmt = sqlsrv_query( $conn, $sql, $params);
$rows_affected = sqlsrv_rows_affected( $stmt);
if( $rows_affected === false) {
die( print_r( sqlsrv_errors(), true));
} elseif( $rows_affected == -1) {
echo "No information available.<br />";
} else {
echo $rows_affected." rows were updated.<br />";
}
?>
SEE ALSO sqlsrv_num_rows(3).
PHP Documentation Group SQLSRV_ROWS_AFFECTED(3)