I have a script which send sql query to oracle db and return value to my script.
dummy code like below:
using above code, when query has error, it send error to same out put file and exit code is 0, is there any way to make the sqlplus exit code other than 0 if the query contains any error?
I'm having a question about for loops. (bash)
I have the following for example:
for file in `ls *.txt`
do
read file ...
done
Now when there is a file present there is no problem, now when there is no file present I get the following output in my standard mail box : "No such... (4 Replies)
Hello,
I need some help from the experts on PL/SQL and Shell scripting. I need a shell script that runs a PL/SQL procedure and gets the values returned from the PL/SQL procedure into the shell variables. The PL/SQL procedure returns multiple values.
I was able to assign a single return value... (1 Reply)
Hi all
Im trying to call a PL SQl block from a ksh file like this :
sqlplus -s $DB_USERID/$DB_PASSWD@$DB_NAME<<eof
whenever SQLERROR exit 1
var varError VARCHAR2(200);
exec ODAS_BATCH_JOBS_RETRIEVE.retrieve_user_info(:varError);
eof
If there is a error then varError will return a... (1 Reply)
Hi Everyone,
How to use catch, try and final in bash script?
what is (SQLException e) and (IOException e), who to conver this 2 function to bash script?
Thank you (8 Replies)
I tried searching the forum for similar posts but its closed now.
Would appreciate any help on this.
I am trying to capture return value from a select query into a variable.
DB is Oracle
I am able to spool it to a file but I donot intend to use it.
Here is my script that does not work ;)
I... (27 Replies)
I have some unstable mistake in my program and out-of-idea how to catch it.
I am looking for advice with a way to work it out!
I have in a pretty complicated program (but one source file) set of int-counters - 15, if exactly.
Lately, on final printout I have inpossible value (I am... (3 Replies)
We have script running to SFTP some file to the remote server. The problem is the SFTP transfer returns an exit code of 0 even if there is permission error during file transfer, connection refuse (like when sftp server is down), thus, returning the status of the script as success.
I was thinking... (3 Replies)
I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts.
Here is my script
#!/bin/csh -f
source .orapass
set user = $USER
set pass = $PASS
cd /opt/data/scripts
echo... (2 Replies)
Hi Experts,
Problem summary :
I am facing the below problem on huge files when the disk is getting full on the half way through the execution.
If the disk was already full , the commands fail & everything is fine.
Sample Code :
head_rec_data_file=`head -1 sample_file.txt`
cat... (9 Replies)
Hello,
I have a main.sql file which runs around 5-6 .sql files and each .sql file is spooling it in separate text file.
In my shell script I am appending main.sql to one of my log file but I am not able to get detailed error if anything fails from those 5-6 .sql files. Those errors are... (1 Reply)
Discussion started by: sp92
1 Replies
LEARN ABOUT PHP
sqlsrv_query
SQLSRV_QUERY(3)SQLSRV_QUERY(3)sqlsrv_query - Prepares and executes a query.SYNOPSIS
mixed sqlsrv_query (resource $conn, string $sql, [array $params], [array $options])
DESCRIPTION
Prepares and executes a query.
PARAMETERS
o $conn
- A connection resource returned by sqlsrv_connect(3).
o $sql
- The string that defines the query to be prepared and executed.
o $params
- An array specifying parameter information when executing a parameterized query. Array elements can be any of the following:
oA literal value
oA PHP variable
oAn array with this structure: array($value [, $direction [, $phpType [, $sqlType]]])
The following table describes the elements in the array structure above:
Array structure
+----------------------+---------------------------------------------------+
| Element | |
| | |
| | Description |
| | |
+----------------------+---------------------------------------------------+
| $value | |
| | |
| | A literal value, a PHP variable, or a PHP by-ref- |
| | erence variable. |
| | |
|$direction (optional) | |
| | |
| | One of the following SQLSRV constants used to |
| | indicate the parameter direction: SQL- |
| | SRV_PARAM_IN, SQLSRV_PARAM_OUT, SQL- |
| | SRV_PARAM_INOUT. The default value is SQL- |
| | SRV_PARAM_IN. |
| | |
| $phpType (optional) | |
| | |
| | A SQLSRV_PHPTYPE_* constant that specifies PHP |
| | data type of the returned value. |
| | |
| $sqlType (optional) | |
| | |
| | A SQLSRV_SQLTYPE_* constant that specifies the |
| | SQL Server data type of the input value. |
| | |
+----------------------+---------------------------------------------------+
o $options
- An array specifing query property options. The supported keys are described in the following table:
Query Options
+-----------------------+--------------------------------------+---+
| Key | | |
| | | |
| | Values | |
| | | |
| | Description | |
| | | |
+-----------------------+--------------------------------------+---+
| QueryTimeout | | |
| | | |
| | A positive integer value. | |
| | | |
| | Sets the query timeout in seconds. | |
| | By default, the driver will wait | |
| | indefinitely for results. | |
| | | |
|SendStreamParamsAtExec | | |
| | | |
| | | |
| | TRUE or FALSE (the default is TRUE) | |
| | | |
| | Configures the driver to send all | |
| | stream data at execution ( TRUE), or | |
| | to send stream data in chunks ( | |
| | FALSE). By default, the value is set | |
| | to TRUE. For more information, see | |
| | sqlsrv_send_stream_data(3). | |
| | | |
| Scrollable | | |
| | | |
| | SQLSRV_CURSOR_FORWARD, SQLSRV_CUR- | |
| | SOR_STATIC, SQLSRV_CURSOR_DYNAMIC, | |
| | or SQLSRV_CURSOR_KEYSET | |
| | | |
| | See Specifying a Cursor Type and | |
| | Selecting Rows in the Microsoft SQL- | |
| | SRV documentation. | |
| | | |
+-----------------------+--------------------------------------+---+
RETURN VALUES
Returns a statement resource on success and FALSE if an error occurred.
EXAMPLES
Example #1
sqlsrv_query(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 = "INSERT INTO Table_1 (id, data) VALUES (?, ?)";
$params = array(1, "some data");
$stmt = sqlsrv_query( $conn, $sql, $params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
?>
NOTES
For statements that you plan to execute only once, use sqlsrv_query(3). If you intend to re-execute a statement with different parameter
values, use the combination of sqlsrv_prepare(3) and sqlsrv_execute(3).
SEE ALSO sqlsrv_prepare(3), sqlsrv_execute(3).
PHP Documentation Group SQLSRV_QUERY(3)