08-08-2013
Executing Multiple Queries in parallel in Shell
I have n number of SQL queries needs to executed in Shell. Result of this query need to assign in a variable. Once all the queries are executed script needs to exit.
Sample Query:
SQL 1: Select Count(*) from TABLE GROUP BY COL1,COL2
SQL 2: Select Count(*) from TABLE GROUP BY COL1,COL2
Result of the above queries need to assign in variables and shell needs to exit once execution of all queries completed.
Can any one post how it can be achieve in shell script?
Envionment: LINUX
Database : ORACLE 11.G
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi there folks,
I am trying to execute remote sql queries on an Oracle server.
I would like to save the result of the executed sql queries on a text file, and send that text file as an attachment to an email address.
Could anyone give me an idea on how the above could be achieved? Any help... (2 Replies)
Discussion started by: Javed
2 Replies
2. Shell Programming and Scripting
Hi guys,
i know how to run a single query using mysql embedded in a shell script as follows:
`mysql -umyuser -pmypass --host myhost database<<SQL
${query};
quit
SQL`
However, how would i be able to run several queries within the same connection?
The reason for this is i am creating... (3 Replies)
Discussion started by: muay_tb
3 Replies
3. Shell Programming and Scripting
Hi,
I have my informix queries in files named sql1.sql and sql2.sql.
I am executing these queries in a remote informix db server.The data got as a result of executing sql1.sql and sql2.sql is got in file1.dat and file2.dat respectively.
cmd= ssh "$USER_NAME"@"$HOST_NAME" "export... (0 Replies)
Discussion started by: Shri123
0 Replies
4. Shell Programming and Scripting
Hi Experts,
There is a shell script that accepts positional parameter between 1-25 to execute case statement of script depending upon the parameter passed.
Now I need to run all the 25 sessions parallely. In each option of case statement it is connecting with sqlplus and executing a select... (11 Replies)
Discussion started by: Opamps123
11 Replies
5. Shell Programming and Scripting
I have one parent directory and within that parent directory there are several other sub-directories and within those sub-directories there are several other "large number" of sub-directories.
All the sub directories have a shell script in them with a common file name execute_command.sh I want... (4 Replies)
Discussion started by: shoaibjameel123
4 Replies
6. Shell Programming and Scripting
Hi,
I have a script where I make a sqlplus connection. In the script I have multiple sql queries within that sqlplus connection. I want the result of the queries to be stored in shell variables declared earlier. I dont want to use procedures. Is there anyway else.
Thanks in advance..
Cheers (6 Replies)
Discussion started by: gonchusirsa
6 Replies
7. Shell Programming and Scripting
Hi All,
I tried executing set of queries from shell script but not able to capture the input query in the log file. The code looks something similar to below
sqlplus user/pwd@dbname << EOF > output.log
$(<inputfile.txt)
EOF
The above code is capturing the output of queries into... (9 Replies)
Discussion started by: loggedin.ksh
9 Replies
8. Red Hat
hi all,
i have a csv file in which some queries are there and through a shell script
i am reading and trying to excute them but it is not working properly
my csv file is like this
Tid,table,query,values
1,PRD_FRG_FILE_JRNL,SELECT SWI_ID,FT_SWI
2,PRD_FRG_FILE_JRNL,SELECT COUNT(1),1
... (2 Replies)
Discussion started by: ramsavi
2 Replies
9. Linux
how to store the count of queries in variables inside a filein shell script
my output :
filename
-------
variable1=result from 1st query
variable2=result from 2nd query
.
.
.
. (3 Replies)
Discussion started by: sanvel
3 Replies
10. Shell Programming and Scripting
hi
i am trying to execute db2 queries through shell script. it's working fine but for few queries is not working ( those queries are taking time so the script is not waiting to get the complete the execution of that query )
could you please any one help me on this
is there any wait... (1 Reply)
Discussion started by: bhaskar v
1 Replies
LEARN ABOUT PHP
sqlite_query
SQLITE_QUERY(3) SQLITE_QUERY(3)
sqlite_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 SQLITE_QUERY(3)