05-28-2013
Shell script to run sql query having a long listing of parameters
Hi,
I have a query regarding execution of a sql query having long listing of parameters ..I need to execute this query inside a shell script.
The scenario is like....
Suppose I have a file abc.txt that has the card numbers..it could be in thousands..
then I need to fire a query like
select name from table_name where cardnum in ('$x')
where x is the data from the file abc.txt...I am able to execute the query if the data is less ..but if the file abc.txt has thousands of lines..then in that case how to execute it...because when I execute the shell script..it gave me error that there is a long list of parameters...
Please help me to form the shell script to execute it for a long list of parameters....Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
i have this basic piece of code that i am trying to debug to accept input parameter to be able to display a directory listing of files.
cd /u02/app/eatv/dev/out
CURDIR=`pwd`
echo directory listing of $CURDIR
echo
if ; then
ls -latr
else
ls -latr $1
fi
basically if the script... (9 Replies)
Discussion started by: wtolentino
9 Replies
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
Hello,
If I run this command on the server it works.
# dbc "update config set radio_enabled = 0;"
how can I execute the same command in perl. I have defined the dbc path. Can any one please correct the last line.
#!/usr/bin/perl
#database path
$dbc='/opt/bin/psql -Userver... (0 Replies)
Discussion started by: sureshcisco
0 Replies
4. Shell Programming and Scripting
Hello,
I have this shell script that runs awk code by passing in parameters however now it doesn't work anymore with the parameters and I don't know why.
It removes duplicates from an input file based on a part of the last field and a key column. It removes the record with the older datetime... (0 Replies)
Discussion started by: script_op2a
0 Replies
5. UNIX for Dummies Questions & Answers
Hello,
When listing the file systems (using ls -ltr) , if the group names are longer the group name is getting truncated.
Can someone help with the script which would display the truncated group name?
I appreciate if someone could help in this regard. (3 Replies)
Discussion started by: mike12
3 Replies
6. Shell Programming and Scripting
I need to run sql script from shell script which takes the input from a file and contents of file will be like :
12345
34567
78657
and query will be like :
select seq_nbr from bus_event where event_nbr='12345';
select seq_nbr from bus_event where event_nbr='34567';
select seq_nbr... (1 Reply)
Discussion started by: rkrish
1 Replies
7. Shell Programming and Scripting
I need to run a SQL select query in Oracle database and have to capture the list of retrieved records in shell script. Also i would like to modify the query for certain condition and need to fetch it again. How can i do this?
Is there a way to have a persistent connection to oracle database... (9 Replies)
Discussion started by: vel4ever
9 Replies
8. Shell Programming and Scripting
Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database.
I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :(
What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies
9. UNIX for Dummies Questions & Answers
Please read How To Ask Questions The Smart Way (1 Reply)
Discussion started by: balu_279013
1 Replies
10. Shell Programming and Scripting
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
LEARN ABOUT PHP
sqlitedatabase.query
SQLITEDATABASE.QUERY(3) SQLITEDATABASE.QUERY(3)
SQLiteDatabase.query - Executes a query against a given database and returns a result handle
SYNOPSIS
resource sqlite_query (resource $dbhandle, string $query, [int $result_type = SQLITE_BOTH], [string &$error_msg])
DESCRIPTION
resource sqlite_query (string $query, resource $dbhandle, [int $result_type = SQLITE_BOTH], [string &$error_msg])
Object oriented style (method): SQLiteResult SQLiteDatabase::query (string $query, [int $result_type = SQLITE_BOTH], [string
&$error_msg])
Executes an SQL statement given by the $query against a given database handle.
PARAMETERS
o $dbhandle
- The SQLite Database resource; returned from sqlite_open(3) when used procedurally. This parameter is not required when using the
object-oriented method.
o $query
- The query to be executed. Data inside the query should be properly escaped.
o $result_type
-The optional $result_type parameter accepts a constant and determines how the returned array will be indexed. Using SQLITE_ASSOC
will return only associative indices (named fields) while SQLITE_NUM will return only numerical indices (ordinal field numbers).
SQLITE_BOTH will return both associative and numerical indices. SQLITE_BOTH is the default for this function.
o $error_msg
- The specified variable will be filled if an error occurs. This is specially important because SQL syntax errors can't be fetched
using the sqlite_last_error(3) function.
Note
Two alternative syntaxes are supported for compatibility with other database extensions (such as MySQL). The preferred form is the
first, where the $dbhandle parameter is the first parameter to the function.
RETURN VALUES
This function will return a result handle or FALSE on failure. For queries that return rows, the result handle can then be used with func-
tions such as sqlite_fetch_array(3) and sqlite_seek(3).
Regardless of the query type, this function will return FALSE if the query failed.
sqlite_query(3) returns a buffered, seekable result handle. This is useful for reasonably small queries where you need to be able to ran-
domly access the rows. Buffered result handles will allocate memory to hold the entire result and will not return until it has been
fetched. If you only need sequential access to the data, it is recommended that you use the much higher performance
sqlite_unbuffered_query(3) instead.
CHANGELOG
+--------+---------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------+
| 5.1.0 | |
| | |
| | Added the $error_msg parameter |
| | |
+--------+---------------------------------+
NOTES
Warning
SQLite will execute multiple queries separated by semicolons, so you can use it to execute a batch of SQL that you have loaded from
a file or have embedded in a script. However, this works only when the result of the function is not used - if it is used, only the
first SQL statement would be executed. Function sqlite_exec(3) will always execute multiple SQL statements.
When executing multiple queries, the return value of this function will be FALSE if there was an error, but undefined otherwise (it
might be TRUE for success or it might return a result handle).
SEE ALSO
sqlite_unbuffered_query(3), sqlite_array_query(3).
PHP Documentation Group SQLITEDATABASE.QUERY(3)