Sponsored Content
Top Forums Shell Programming and Scripting How to get full sql table data using shell script Post 302551374 by ss135r on Tuesday 30th of August 2011 07:41:43 AM
Old 08-30-2011
How to get full sql table data using shell script

i have a Oracle table like
Code:
col1 col2
---- -----
a       1
b       2
c       3

when i write a script for it , it gives me all the data in one column.
Please give me the solution which gives the exact result like we see in sql editors.
Code:
for a in `echo "
set feedback off;
set pagesize 40;
select * from tblname;
exit;" | sqlplus -s scott/tiger`
do
echo $a
done


Thanks,
Shrawan

Last edited by pludi; 08-30-2011 at 08:52 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help for writing shell script to export table data

Hi All, I need to write a shell script(ksh) to take the tables backup in oracle(exporting tables data). The tables list is not static, and those are selecting through dynamic sql query. Can any body help how to write this shell script. Thanks, (3 Replies)
Discussion started by: sankarg
3 Replies

2. Shell Programming and Scripting

How to pass pl/sql table values to shell script

Hello, i am using '#!/bin/bash', i want to make a loop in pl/sql, this loop takes values from a table according to some conditions, each time the loop choose 3 different variables. What i am not able to do is that during the loop i want my shell script to read this 3 variables and run a shell... (1 Reply)
Discussion started by: rosalinda
1 Replies

3. Shell Programming and Scripting

shell script to read data from text file and to load it into a table in TOAD

Hi....can you guys help me out in this script?? Below is a portion text file and it contains these: GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL005675 000001... (1 Reply)
Discussion started by: pallavishetty
1 Replies

4. Shell Programming and Scripting

Bash shell script that inserts a text data file into an HTML table

hi , i need to create a bash shell script that insert a text data file into an html made table, this table output has to mailed.I am new to shell scripting and have a very minimum idea of shell scripting. please help. (9 Replies)
Discussion started by: intern123
9 Replies

5. Shell Programming and Scripting

Shell script to export data from Oracle table .

Hi, I want to write a shell script which will export data from oracle table . I don't want to save that data . I want the queries . Right now i am right clicking on the table and clicking on export as to my desktop . Please let me know if any one have any idea . (2 Replies)
Discussion started by: honey26
2 Replies

6. Homework & Coursework Questions

Write a shell script for SQL loader to load data into a staging table

Hi, I'm new to Linux. I'm working on a database, and need to load data in a database table (which I already created) using shell script. The table has two columns - Acct_number (not nullable) and date (timestamp). I'm not able to write a shell script for that. Can any one help me? ... (3 Replies)
Discussion started by: saisudeep
3 Replies

7. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

8. Shell Programming and Scripting

How to create SQL statement out of data using shell script?

Table TAB1 contains following example data (its a tree sitting in table data format & its driven based CHILD & PARENT column pick the RULE condition to generate the below SQL: CHILD PARENT SS MID MNM VNM RULE FLG 1 ? S1 ? ? V1 rule004 I 2 1 S1 ? ? V1 0 Z 3 1 S1 ? ? V1 1 Z ... (6 Replies)
Discussion started by: gksenthilkumar
6 Replies

9. UNIX and Linux Applications

How to delete a data starting with a phrase in a table - SQL?

Hello, I am trying to remove some rows in a table, which are including a phrase at a defined column but i could not find the unique result for this. What I wish to do is to remove all lines including http://xx.yy at link column ... (2 Replies)
Discussion started by: baris35
2 Replies

10. Shell Programming and Scripting

Using Isql for SQL SERVER to get the table rows counts in UNIX shell script to

need to create shell script to read the table's name from file and connect SQL SERVER using isql (odbcunix) i 'm able connect to database with below command line syntex but i could not get working in shell script with SQL and storing the row count in variable. isql -v DSN USERNAME PASSWD ... (6 Replies)
Discussion started by: pimmit22043
6 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 01:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy