Sponsored Content
Top Forums Programming Assign variable for INSERT INTO statement Post 302464103 by durden_tyler on Tuesday 19th of October 2010 09:39:12 AM
Old 10-19-2010
Post the contents of your entire script over here.

Quote:
...For point (b), I want to check the table is exists in database or not, If it exists then only do for INSERT INTO statement, So i used if condition with select count(*) statement. ...
Do you have a reason to believe that someone/something will drop that table ?
If you do, then there's something seriously wrong with either your application or its security.

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

2. Shell Programming and Scripting

error in insert statement

hi, When i try to run the code below, i get the following error "ksh: syntax error: `(' unexpected" i am not able to figure it out. Can anyone help me? Code: (2 Replies)
Discussion started by: ragavhere
2 Replies

3. Programming

Dynamic Insert statement

I have a form , where i will put the values to a table. I wrote a insert statement for the same. Table structure is ename | character varying(30) | eadd | character varying(30) | eid | integer | sal | integer In the statements, i don't... (1 Reply)
Discussion started by: pritish.sas
1 Replies

4. Shell Programming and Scripting

How can i assign an select statement into a variable?

I am trying to assign an select statement into a variable. Can someone hel me with this. example : a='select * from dual' echo $a should give me select * from dual But this is not working. I trying with \ before * and quotes too. (1 Reply)
Discussion started by: rdhanek
1 Replies

5. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

6. Shell Programming and Scripting

How to insert numbers to a in between statement

Hi Guys, I want to create a shell script that will give me the output below. I want to insert the numbers from the input file to my url addresses below. And from the numbers below, I want to separate the last digit with a period (i.e. from 222222222222 to 22222222222.2). Appreciate any help.... (14 Replies)
Discussion started by: pinpe
14 Replies

7. Shell Programming and Scripting

How to insert date in a statement?

Hi Guys, Can somebody help me in inserting today's DATE format (20110709) in my awk statement. I have a script but its not working. inputfile.txt: 269,1,0,AAA,430 231,2,0,BBB,430 252,3,0,CCC,430 214,4,0,DDD,430 script.sh #!/bin/bash DATE="`date +%Y%m%d`" cd /var/opt/ (8 Replies)
Discussion started by: pinpe
8 Replies

8. Shell Programming and Scripting

How to insert a space and assign the value to another variable?

Hello, I need to insert a space between 2 strings. I used many techniques and all of them worked but when I assign the value to another variable then the inserted space vanishes, strange! Please advise. # dat=`date |awk '{print $2,$3}'` # echo $dat Nov 3 The above is perfectly fine. Now... (4 Replies)
Discussion started by: prvnrk
4 Replies

9. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

10. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies
OCI_EXECUTE(3)															    OCI_EXECUTE(3)

oci_execute - Executes a statement

SYNOPSIS
bool oci_execute (resource $statement, [int $mode = OCI_COMMIT_ON_SUCCESS]) DESCRIPTION
Executes a $statement previously returned from oci_parse(3). After execution, statements like INSERT will have data committed to the database by default. For statements like SELECT, execution per- forms the logic of the query. Query results can subsequently be fetched in PHP with functions like oci_fetch_array(3). Each parsed statement may be executed multiple times, saving the cost of re-parsing. This is commonly used for INSERT statements when data is bound with oci_bind_by_name(3). PARAMETERS
o $statement - A valid OCI statement identifier. o $mode - An optional second parameter can be one of the following constants: Execution Modes +----------------------+---------------------------------------------------+ | Constant | | | | | | | Description | | | | +----------------------+---------------------------------------------------+ | | | |OCI_COMMIT_ON_SUCCESS | | | | | | | Automatically commit all outstanding changes for | | | this connection when the statement has succeeded. | | | This is the default. | | | | | | | | OCI_DESCRIBE_ONLY | | | | | | | Make query meta data available to functions like | | | oci_field_name(3) but do not create a result set. | | | Any subsequent fetch call such as | | | oci_fetch_array(3) will fail. | | | | | | | | OCI_NO_AUTO_COMMIT | | | | | | | Do not automatically commit changes. Prior to PHP | | | 5.3.2 (PECL OCI8 1.4) use OCI_DEFAULT which is | | | equivalent to OCI_NO_AUTO_COMMIT. | | | | +----------------------+---------------------------------------------------+ Using OCI_NO_AUTO_COMMIT mode starts or continues a transaction. Transactions are automatically rolled back when the connection is closed, or when the script ends. Explicitly call oci_commit(3) to commit a transaction, or oci_rollback(3) to abort it. When inserting or updating data, using transactions is recommended for relational data consistency and for performance reasons. If OCI_NO_AUTO_COMMIT mode is used for any statement including queries, and oci_commit(3) or oci_rollback(3) is not subsequently called, then OCI8 will perform a rollback at the end of the script even if no data was changed. To avoid an unnecessary rollback, many scripts do not use OCI_NO_AUTO_COMMIT mode for queries or PL/SQL. Be careful to ensure the appropriate transactional consis- tency for the application when using oci_execute(3) with different modes in the same script. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 oci_execute(3) for queries <?php $conn = oci_connect('hr', 'welcome', 'localhost/XE'); $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_execute(3) without specifying a mode example <?php // Before running, create the table: // CREATE TABLE MYTABLE (col1 NUMBER); $conn = oci_connect('hr', 'welcome', 'localhost/XE'); $stid = oci_parse($conn, 'INSERT INTO mytab (col1) VALUES (123)'); oci_execute($stid); // The row is committed and immediately visible to other users ?> Example #3 oci_execute(3) with OCI_NO_AUTO_COMMIT example <?php // Before running, create the table: // CREATE TABLE MYTABLE (col1 NUMBER); $conn = oci_connect('hr', 'welcome', 'localhost/XE'); $stid = oci_parse($conn, 'INSERT INTO mytab (col1) VALUES (:bv)'); oci_bind_by_name($stid, ':bv', $i, 10); for ($i = 1; $i <= 5; ++$i) { oci_execute($stid, OCI_NO_AUTO_COMMIT); // use OCI_DEFAULT for PHP <= 5.3.1 } oci_commit($conn); // commits all new values: 1, 2, 3, 4, 5 ?> Example #4 oci_execute(3) with different commit modes example <?php // Before running, create the table: // CREATE TABLE MYTABLE (col1 NUMBER); $conn = oci_connect('hr', 'welcome', 'localhost/XE'); $stid = oci_parse($conn, 'INSERT INTO mytab (col1) VALUES (123)'); oci_execute($stid, OCI_NO_AUTO_COMMIT); // data not committed $stid = oci_parse($conn, 'INSERT INTO mytab (col1) VALUES (456)'); oci_execute($stid); // commits both 123 and 456 values ?> Example #5 oci_execute(3) with OCI_DESCRIBE_ONLY example <?php $conn = oci_connect('hr', 'welcome', 'localhost/XE'); $stid = oci_parse($conn, 'SELECT * FROM locations'); oci_execute($s, OCI_DESCRIBE_ONLY); for ($i = 1; $i <= oci_num_fields($stid); ++$i) { echo oci_field_name($stid, $i) . "<br> "; } ?> NOTES
Note Transactions are automatically rolled back when connections are closed, or when the script ends, whichever is soonest. Explicitly call oci_commit(3) to commit a transaction. Any call to oci_execute(3) that uses OCI_COMMIT_ON_SUCCESS mode explicitly or by default will commit any previous uncommitted transaction. Any Oracle DDL statement such as CREATE or DROP will automatically commit any uncommitted transaction. Note Because the oci_execute(3) function generally sends the statement to the database, oci_execute(3) can identify some statement syn- tax errors that the lightweight, local oci_parse(3) function does not. SEE ALSO
oci_parse(3). PHP Documentation Group OCI_EXECUTE(3)
All times are GMT -4. The time now is 04:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy