06-11-2014
iirc, isql supports -o <output file>.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
In
unload to
"/usr/home/data.012202"
I wish to use a date variable as in
unload to
"/usr/home/data.`date`" for the file
is that possible in a query to do, or will i need to add a mv command after the query to do it.
I tried backquotes, , and () on `date` but didn't seem to work
Thanks... (2 Replies)
Discussion started by: Link_02
2 Replies
2. Shell Programming and Scripting
Hi,
I search all post...and no soluation about..if i would like to run a sql statement and output the result to txt file.
for example,
i usually run "sql" to logon the database and run select statement. Then I need to copy the output into the result.txt. Can I run the script to do this... (7 Replies)
Discussion started by: happyv
7 Replies
3. Shell Programming and Scripting
Hi ,
I just found you while surfing for the string
'Redirecting sql select query output from within a shell script to txt file/excel file'
Could you find time sending me the code for the above question?
It'll be great help for me.
I have a perl file that calls the sql file... (1 Reply)
Discussion started by: dolphin123
1 Replies
4. Shell Programming and Scripting
Hi Yogesh,
Lucky that i caught you online. Yeah i read about DBI and the WriteExcel module. But the server is not supporting these modules. It said..."Cannot locate DBI"..."Cannot locate Spreadsheet::WriteExcel"
I tried creating a simple text file to get the query output, but the... (1 Reply)
Discussion started by: dolphin123
1 Replies
5. Shell Programming and Scripting
Hi All,
I want to format the result driven from the query into neat format.
For example pls find the below code,
#! /bin/sh
result='
sqlplus -s uname/passwrd@DBname
select no,name,address,ph_no, passport_no,salary,designation
from emp_table where salary>1000;
exit
EOF'
... (8 Replies)
Discussion started by: little_wonder
8 Replies
6. UNIX for Dummies Questions & Answers
This is basically what I want to do:
I have a file that contains single lines of IDs.
I want to query the oracle database using these IDs
to get a count of which ones match a certain condition.
the basic idea is:
cat myfile |
while read id
do
$id in select count(PC.ptcpnt_id)
from... (4 Replies)
Discussion started by: whoknows
4 Replies
7. Shell Programming and Scripting
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)
Discussion started by: sailaja_80
1 Replies
8. Shell Programming and Scripting
Hi ,
I used the below script to get the sql data into csv file using unix scripting.
I m getting the output into an output file but the output file is not displayed in a separe columns .
#!/bin/ksh
export FILE_PATH=/maav/home/xyz/abc/
rm $FILE_PATH/sample.csv
sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies
9. UNIX for Advanced & Expert Users
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)
Discussion started by: thepurple
5 Replies
10. Programming
Dear community,
please help with a query on Oracle. I'm using SQLPlus (but with SQLDeveloper is the same) to accamplish a sinple query like:
select count(*) from ARCHIT_D_TB where (TYP_ID=22 OR TYP_ID=23) and SUB_TM like '%SEP%' and CONS=1234This is a very simple query that works perfect until... (5 Replies)
Discussion started by: Lord Spectre
5 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)