Sponsored Content
Top Forums Shell Programming and Scripting Executing Multiple Queries in parallel in Shell Post 302843392 by Niranjancse on Tuesday 13th of August 2013 04:42:03 AM
Old 08-13-2013
Also all the queries are writted in Parameter file. I need to read the queries from parameter one by one and pass to the Oracle.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sh Shell Script executing remote SQL queries

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

Multiple MySql queries in shell script?

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

Executing informix queries using isqlrf

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

Help with executing parallel sessions for same shell script with different but fixed parameters

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

Find and execute shell scripts in multiple sub directories in parallel

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

How to store results of multiple sql queries in shell variables in ksh?

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

Executing set of sql queries from shell script

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

Reading csv and executing queries

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 count of multiple queries in variables in a shell script?

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

Issue on executing db2 queries through shell script

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
OCI_SET_PREFETCH(3)													       OCI_SET_PREFETCH(3)

oci_set_prefetch - Sets number of rows to be prefetched by queries

SYNOPSIS
bool oci_set_prefetch (resource $statement, int $rows) DESCRIPTION
Sets the number of rows to be buffered by the Oracle Client libraries after a successful query call to oci_execute(3) and for each subse- quent internal fetch request to the database. For queries returning a large number of rows, performance can be significantly improved by increasing the prefetch count above the default oci8.default_prefetch value. Prefetching is Oracle's efficient way of returning more than one data row from the database in each network request. This can result in better network and CPU utilization. The buffering of rows is internal to OCI8 and the behavior of OCI8 fetching functions is unchanged regardless of the prefetch count. For example, oci_fetch_row(3) will always return one row. The prefetch buffer is per-statement and is not used by re-executed statements or by other connections. Call oci_set_prefetch(3) before calling oci_execute(3). A tuning goal is to set the prefetch value to a reasonable size for the network and database to handle. For queries returning a very large number of rows, overall system efficiency might be better if rows are retrieved from the database in several chunks (i.e set the prefetch value smaller than the number of rows). This allows the database to handle other users' statements while the PHP script is processing the current set of rows. Query prefetching was introduced in Oracle 8 i. REF CURSOR prefetching was introduced in Oracle 11 gR2 and occurs when PHP is linked with Oracle 11 gR2 (or later) Client libraries. Nested cursor prefetching was introduced in Oracle 11 gR2 and requires both the Oracle Client libraries and the database to be version 11 gR2 or greater. Prefetching is not supported when queries contain LONG or LOB columns. The prefetch value is ignored and single-row fetches will be used in all the situations when prefetching is not supported. When using Oracle Database 12 c, the prefetch value set by PHP can be overridden by Oracle's client oraaccess.xml configuration file. Refer to Oracle documentation for more detail. PARAMETERS
o $statement -A valid OCI8 statement identifier created by oci_parse(3) and executed by oci_execute(3), or a REF CURSOR statement identifier. o $rows - The number of rows to be prefetched, >= 0 RETURN VALUES
Returns TRUE on success or FALSE on failure. CHANGELOG
+------------------------+---------------------------------------------------+ | Version | | | | | | | Description | | | | +------------------------+---------------------------------------------------+ | 5.3.2 (PECL OCI8 1.4) | | | | | | | Before this release, $rows must be >= 1. | | | | |5.3.0 (PECL OCI8 1.3.4) | | | | | | | Before this release, prefetching was limited to | | | the lesser of $rows rows and 1024 * $rows bytes. | | | The byte size restriction has now been removed. | | | | +------------------------+---------------------------------------------------+ EXAMPLES
Example #1 Changing the default prefetch value for a query <?php $conn = oci_connect('hr', 'welcome', 'localhost/XE'); $stid = oci_parse($conn, 'SELECT * FROM myverybigtable'); oci_set_prefetch($stid, 300); // Set before calling oci_execute() oci_execute($stid); echo "<table border='1'> "; while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) { echo "<tr> "; foreach ($row as $item) { echo " <td>".($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;")."</td> "; } echo "</tr> "; } echo "</table> "; oci_free_statement($stid); oci_close($conn); ?> Example #2 Changing the default prefetch for a REF CURSOR fetch <?php /* Create the PL/SQL stored procedure as: CREATE OR REPLACE PROCEDURE myproc(p1 OUT SYS_REFCURSOR) AS BEGIN OPEN p1 FOR SELECT * FROM all_objects WHERE ROWNUM < 5000; END; */ $conn = oci_connect('hr', 'welcome', 'localhost/XE'); $stid = oci_parse($conn, 'BEGIN myproc(:rc); END;'); $refcur = oci_new_cursor($conn); oci_bind_by_name($stid, ':rc', $refcur, -1, OCI_B_CURSOR); oci_execute($stid); // Change the prefetch before executing the cursor. // REF CURSOR prefetching works when PHP is linked with Oracle 11gR2 or later Client libraries oci_set_prefetch($refcur, 200); oci_execute($refcur); echo "<table border='1'> "; while ($row = oci_fetch_array($refcur, OCI_ASSOC+OCI_RETURN_NULLS)) { echo "<tr> "; foreach ($row as $item) { echo " <td>".($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;")."</td> "; } echo "</tr> "; } echo "</table> "; oci_free_statement($refcur); oci_free_statement($stid); oci_close($conn); ?> If PHP OCI8 fetches from a REF CURSOR and then passes the REF CURSOR back to a second PL/SQL procedure for further processing, then set the REF CURSOR prefetch count to 0 to avoid rows being "lost" from the result set. The prefetch value is the number of extra rows fetched in each OCI8 internal request to the database, so setting it to 0 means only fetch one row at a time. Example #3 Setting the prefetch value when passing a REF CURSOR back to Oracle <?php $conn = oci_connect('hr', 'welcome', 'localhost/orcl'); // get the REF CURSOR $stid = oci_parse($conn, 'BEGIN myproc(:rc_out); END;'); $refcur = oci_new_cursor($conn); oci_bind_by_name($stid, ':rc_out', $refcur, -1, OCI_B_CURSOR); oci_execute($stid); // Display two rows, but don't prefetch any extra rows otherwise // those extra rows would not be passed back to myproc_use_rc(). // A prefetch value of 0 is allowed in PHP 5.3.2 and PECL OCI8 1.4 oci_set_prefetch($refcur, 0); oci_execute($refcur); $row = oci_fetch_array($refcur); var_dump($row); $row = oci_fetch_array($refcur); var_dump($row); // pass the REF CURSOR to myproc_use_rc() to do more data processing // with the result set $stid = oci_parse($conn, 'begin myproc_use_rc(:rc_in); end;'); oci_bind_by_name($stid, ':rc_in', $refcur, -1, OCI_B_CURSOR); oci_execute($stid); ?> SEE ALSO
oci8.default_prefetch ini option . PHP Documentation Group OCI_SET_PREFETCH(3)
All times are GMT -4. The time now is 04:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy