Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How do I use SQL to query based off file data? Post 302329338 by whoknows on Friday 26th of June 2009 05:06:28 PM
Old 06-26-2009
Power How do I use SQL to query based off file data?

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 ptcpnt_cmpsit PC
where
PC.gndr_type = 'F'
;
done

Hopefully, you get the gist.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unloading sql query to file

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

how to use data in unix text file as input to an sql query from shell

Hi, I have data in my text file something like this. adams robert ahmed gibbs I want to use this data line by line as input to an sql query which i run by connecting to an oracle database from shell. If you have code for similar scenario , please ehlp. I want the output of the sql query... (7 Replies)
Discussion started by: rdhanek
7 Replies

3. Shell Programming and Scripting

redirecting sql query output to a file

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

4. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

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

5. Shell Programming and Scripting

Dynamic SQL query based on shell script parameters

Hi, I need a script that will run a dynamic Oracle SQL. Dynamic meaning the SQL statement depends on the parameter. For instance, something like this: #!/bin/ksh -x # Set environment . /home/mine/set_vars sqlplus $LOGINID <<! >> /home/mine/log.txt select count(1) from $1 where... (2 Replies)
Discussion started by: laiko
2 Replies

6. UNIX for Advanced & Expert Users

Output the SQL Query result to a File

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

7. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

8. Shell Programming and Scripting

Read input file and used it to SQL query

Hi All, Seeking for your assistance to read each line $1 and $2 of input file and used it to query. Ex. file1.txt(number range) 9064500000 9064599999 9064600000 9064699999 9064700000 9064799999 Database name: ranges_log a_no message 9064500001 test 9064700000 ... (7 Replies)
Discussion started by: znesotomayor
7 Replies

9. Shell Programming and Scripting

Run sql query in shell script and output data save as delimited text

I want to run sql query in shell script and output data save as delimited text (delimited text would be comma) Code: SPOOL_FILE=/pgedw/dan.txt SQL=/pgedw/dan.sql sqlplus -s username/password@myhost:port/servicename <<EOF set head on set COLSEP , set linesize 32767 SET TRIMSPOOL ON SET... (8 Replies)
Discussion started by: Jaganjag
8 Replies

10. Programming

Need sql query to string split and normalize data

Hello gurus, I have data in one of the oracle tables as as below: Column 1 Column 2 1 NY,NJ,CA 2 US,UK, 3 AS,EU,NA fyi, Column 2 above has data delimited with a comma as shown. I need a sql query the produce the below output in two columns... (5 Replies)
Discussion started by: calredd
5 Replies
PG_SEND_QUERY_PARAMS(3) 												   PG_SEND_QUERY_PARAMS(3)

pg_send_query_params - Submits a command and separate parameters to the server without waiting for the result(s).

SYNOPSIS
bool pg_send_query_params (resource $connection, string $query, array $params) DESCRIPTION
Submits a command and separate parameters to the server without waiting for the result(s). This is equivalent to pg_send_query(3) except that query parameters can be specified separately from the $query string. The function's parameters are handled identically to pg_query_params(3). Like pg_query_params(3), it will not work on pre-7.4 PostgreSQL connections, and it allows only one command in the query string. PARAMETERS
o $connection - PostgreSQL database connection resource. o $query - The parameterized SQL statement. Must contain only a single statement. (multiple statements separated by semi-colons are not allowed.) If any parameters are used, they are referred to as $1, $2, etc. o $params - An array of parameter values to substitute for the $1, $2, etc. placeholders in the original prepared query string. The number of elements in the array must match the number of placeholders. RETURN VALUES
Returns TRUE on success or FALSE on failure. Use pg_get_result(3) to determine the query result. EXAMPLES
Example #1 Using pg_send_query_params(3) <?php $dbconn = pg_connect("dbname=publisher") or die("Could not connect"); // Using parameters. Note that it is not necessary to quote or escape // the parameter. pg_send_query_params($dbconn, 'select count(*) from authors where city = $1', array('Perth')); // Compare against basic pg_send_query usage $str = pg_escape_string('Perth'); pg_send_query($dbconn, "select count(*) from authors where city = '${str}'"); ?> SEE ALSO
pg_send_query(3). PHP Documentation Group PG_SEND_QUERY_PARAMS(3)
All times are GMT -4. The time now is 03:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy