Sponsored Content
Top Forums Shell Programming and Scripting UNIX variable to SQL statement Post 302749127 by Scott on Thursday 27th of December 2012 02:34:41 PM
Old 12-27-2012
That's not very helpful. Please show everything you did.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sql query variable not exactly unix

I know htis isnt exactly unix.... but hopefully someone can help me or direct me someplace to get help. I can run sql queries in scripts against my informix db using: dbaccess mydb myquery.sql >> sql.output I need to write my script to select based on todays date. Its very... (5 Replies)
Discussion started by: MizzGail
5 Replies

2. Shell Programming and Scripting

Executing a Oracle SQL statement in a UNIX script

Hi All, I need to select one column from a table based upon the passed in parameter. I tried this: sqlplus -silent $MISP_USER << EOF set feedback off; set verify off; set sqlprompt "" SELECT mail_flag FROM dailyjobs WHERE job_name = '$1'; exit 0 EOF exit... (1 Reply)
Discussion started by: ganga.dharan
1 Replies

3. Shell Programming and Scripting

how to pass a variable to an update sql statement inside a loop

hi all, i am experiencing an error which i think an incorrect syntax for the where clause passing a variable was given. under is my code. sqlplus -s ${USERNAME}/${PASSWORD}@${SID} << END1 >> $LOGFILE whenever sqlerror exit set serveroutput on size 1000000 declare l_rc ... (0 Replies)
Discussion started by: ryukishin_17
0 Replies

4. Shell Programming and Scripting

Using Unix Variable in a PL/SQL block

Hi, I have a unix varaible called as account which hold values which i want to use in a PL/SQL block in a shell script. This variable value is being used in multiple places in the PL/SQL block and i get an erroe whenenevr is use this varaible with $prompt. Help Urgently (1 Reply)
Discussion started by: sumi_mn
1 Replies

5. Shell Programming and Scripting

I want to get the Unix variable value in the sql stmt

Hi All I have a requirement where in I am stuck. There is a shell script that is being developed by me. It consist of the sql stmt also. I need to export a variable called HOMEPAGE with a value say www.abc.com. and then use this $HOMEPAGE variable in the sql stmt. My ultimate aim is to fetch all... (1 Reply)
Discussion started by: amitsinha
1 Replies

6. Shell Programming and Scripting

Unix shell command output to a sql statement

Can i do this Say one command sed 's/:*/ /g' $summf is returning C1234 C2345 C3434 some no of rows, now this ouput i have to insert it into a DB table how do i do this?? (2 Replies)
Discussion started by: depakjan
2 Replies

7. UNIX for Dummies Questions & Answers

unix script with SQL statement problem

Hello, I have a script to get the information from database, however, it's look like the loop is not work, can someone help? :confused: echo Input file list to check: read filelist for file in 'cat $filelist.txt' do echo "select FILENAME from FILE_TABLE where filename like '${file}'%;" >>... (9 Replies)
Discussion started by: happyv
9 Replies

8. UNIX for Dummies Questions & Answers

SQL statement is not work on unix script

Hi, I have the following basic script. However, the statement (line 5) is not work. The output data is not able to set my request format a30. Any advise? :mad: echo " Column filename format a30"|sqlplus4 echo Input file list to check: read filelist for file in `cat $filelist.txt` do... (1 Reply)
Discussion started by: happyv
1 Replies

9. Shell Programming and Scripting

SQL output to UNIX variable

I have a sql statement , i need to assign to a variable in Unix sel count(*) AS num_files from TABLE_A; i need to use "num_files" in unix statements. let me know how to assign unix variable to above num_files (1 Reply)
Discussion started by: nani1984
1 Replies

10. Shell Programming and Scripting

UNIX Sqlplus - Capture the sql statement about to run and execution status

Greetings Experts, I am on AIX using ksh. Created a unix script which generates the CREATE OR REPLACE VIEW ... and GRANT .. statements, which are placed in a single .txt file. Now I need to execute the contents in the file (there are around 300 view creation and grant statements) in Oracle and... (4 Replies)
Discussion started by: chill3chee
4 Replies
OCI_PARSE(3)															      OCI_PARSE(3)

oci_parse - Prepares an Oracle statement for execution

SYNOPSIS
resource oci_parse (resource $connection, string $sql_text) DESCRIPTION
Prepares $sql_text using $connection and returns the statement identifier, which can be used with oci_bind_by_name(3), oci_execute(3) and other functions. Statement identifiers can be freed with oci_free_statement(3) or by setting the variable to NULL. PARAMETERS
o $connection - An Oracle connection identifier, returned by oci_connect(3), oci_pconnect(3), or oci_new_connect(3). o $sql_text - The SQL or PL/SQL statement. SQL statements should not end with a semi-colon (";"). PL/SQL statements should end with a semi- colon (";"). RETURN VALUES
Returns a statement handle on success, or FALSE on error. EXAMPLES
Example #1 oci_parse(3) example for SQL statements <?php $conn = oci_connect('hr', 'welcome', 'localhost/XE'); // Parse the statement. Note there is no final semi-colon in the SQL statement $stid = oci_parse($conn, 'SELECT * FROM employees'); 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> "; ?> Example #2 oci_parse(3) example for PL/SQL statements <?php /* Before running the PHP program, create a stored procedure in SQL*Plus or SQL Developer: CREATE OR REPLACE PROCEDURE myproc(p1 IN NUMBER, p2 OUT NUMBER) AS BEGIN p2 := p1 * 2; END; */ $conn = oci_connect('hr', 'welcome', 'localhost/XE'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $p1 = 8; // When parsing PL/SQL programs, there should be a final semi-colon in the string $stid = oci_parse($conn, 'begin myproc(:p1, :p2); end;'); oci_bind_by_name($stid, ':p1', $p1); oci_bind_by_name($stid, ':p2', $p2, 40); oci_execute($stid); print "$p2 "; // prints 16 oci_free_statement($stid); oci_close($conn); ?> NOTES
Note This function does not validate $sql_text. The only way to find out if $sql_text is a valid SQL or PL/SQL statement is to execute it. SEE ALSO
oci_execute(3), oci_free_statement(3). PHP Documentation Group OCI_PARSE(3)
All times are GMT -4. The time now is 10:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy