02-01-2008
Execute oracle query determined at runtime from a unix script
Hi
I am trying to run a SQL statement from a unix script determined at runtime.
It is throwing me an error. Please advise some solution to this.
echo "Enter username for the database"
read username
echo "Enter password for the database"
read password
echo "Enter SQL stmt"
read sqlstatement
sqlplus ${username}/${password} <<EOF
spool output.lst;
execute immediate '$sqlstatement';
spool off;
EOF
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
We are researching the possibility of using Oracle 10g Scheduler on Solaris 10 to launch scripts at our site, and the script that I am testing does not get $HOME (and other environment variables) set correctly. Here is the Korn shell script (show_info.ksh):
#!/usr/bin/ksh
id
env | sort
Here... (4 Replies)
Discussion started by: shew01
4 Replies
2. Shell Programming and Scripting
Hi All,
How to run multiple oracle script in unix at-a-time.I appriciate if any send the script for me.
Regards,
Ravi kumar.Gongati (2 Replies)
Discussion started by: ravi gongati
2 Replies
3. Shell Programming and Scripting
I want to store the sql query output into a variable
#!/bin/ksh
ORACLE_SID=DB01;
export ORACLE_SID;
export FILE_PATH=/home/asg/Tmp
# Order Checking
echo " removing old files "
rm $FILE_PATH/Malformed_Order.txt
echo " Enter the Malformed Order ....!"
read orders
echo "Regrade... (5 Replies)
Discussion started by: Nareshp
5 Replies
4. Shell Programming and Scripting
Hi
I am new in unix. oracle and unix are installed in my sytem.i need the script
which could connect to the oracle using username ,password and schema and can run the select * from tab query.
Thanks
vijay (8 Replies)
Discussion started by: vijays3
8 Replies
5. Shell Programming and Scripting
Hi,
I have a requirement as below which needs to be done viz UNIX shell script
(1) I have to connect to an Oracle database
(2) Exexute "SELECT field_status from table 1" query on one of the tables.
(3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies
6. Shell Programming and Scripting
hi Guys,
i have a problem with oracle query in my unix script..
I'm getting the following error while executing..
./logtab.sh: sqlplus -s "pmutv/pmutv1" << EOFSQL^Jset head off^Jinsert into... (2 Replies)
Discussion started by: apple2685
2 Replies
7. Shell Programming and Scripting
Hi,
I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database.
For instance:
USER CITY
--------- ----------
A CITY_A
B CITY_B
C ... (2 Replies)
Discussion started by: DevendraG
2 Replies
8. Shell Programming and Scripting
I'm working on a ksh script and was wondering if anyone knows if it's possible to access an array by a variable that is determined at runtime?
I have created a test example below, but essentially I will have declared and populated an array (see colorArray below). What I'd like to do is access... (9 Replies)
Discussion started by: bs103950
9 Replies
9. Shell Programming and Scripting
#!/bin/bash
function getDeliveredDispatches(firstDateTime, lastDateTime, limit) {
var cursor = db.dispatches.find(
{$and: }}
]},
{"deliveryGroupId" : 1, "batchId": 1, "statusHistory.code" : 1}
);
var wrongDispatchesIds = ;
print("Number of dispatches selected based on filter = " +... (2 Replies)
Discussion started by: neel2462
2 Replies
10. Shell Programming and Scripting
Hi Experts,
Need your support.
Not able to use sql query alias in shell script.
Could you please help me in finding right way to use alias with sql query in shell script.
Below is the code i am using.
#!/bin/bash
sqlplus -s abc/abc@abc << EOF> bcd.csv
set trimspool on
select zone_id... (4 Replies)
Discussion started by: as7951
4 Replies
LEARN ABOUT PHP
dbx_connect
DBX_CONNECT(3) 1 DBX_CONNECT(3)
dbx_connect - Open a connection/database
SYNOPSIS
object dbx_connect (mixed $module, string $host, string $database, string $username, string $password, [int $persistent])
DESCRIPTION
Opens a connection to a database.
PARAMETERS
o $module
- The $module parameter can be either a string or a constant, though the latter form is preferred. The possible values are given
below, but keep in mind that they only work if the module is actually loaded.
o DBX_MYSQL or "mysql"
o DBX_ODBC or "odbc"
o DBX_PGSQL or "pgsql"
o DBX_MSSQL or "mssql"
o DBX_FBSQL or "fbsql"
o DBX_SYBASECT or "sybase_ct"
o DBX_OCI8 or "oci8"
o DBX_SQLITE or "sqlite"
o $host
- The SQL server host
o $database
- The database name
o $username
- The username
o $password
- The password
o $persistent
- The $persistent parameter can be set to DBX_PERSISTENT, if so, a persistent connection will be created.
The $host, $database, $username and $password parameters are expected, but not always used depending on the connect functions for the
abstracted module.
RETURN VALUES
Returns an object on success, FALSE on error. If a connection has been made but the database could not be selected, the connection is
closed and FALSE is returned.
The returned $object has three properties:
o database
- It is the name of the currently selected database.
o handle
- It is a valid handle for the connected database, and as such it can be used in module-specific functions (if required).
<?php
$link = dbx_connect(DBX_MYSQL, "localhost", "db", "username", "password");
mysql_close($link->handle); // dbx_close($link) would be better here
?>
o module
- It is used internally by dbx only, and is actually the module number mentioned above.
CHANGELOG
+--------+---------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------+
| 5.0.0 | |
| | |
| | Introduced DBX_SQLITE. |
| | |
| 4.3.0 | |
| | |
| | Introduced DBX_OCI8. |
| | |
| 4.2.0 | |
| | |
| | Introduced DBX_SYBASECT. |
| | |
| 4.1.0 | |
| | |
| | Introduced DBX_FBSQL. |
| | |
+--------+---------------------------+
EXAMPLES
Example #1
dbx_connect(3) example
<?php
$link = dbx_connect(DBX_ODBC, "", "db", "username", "password", DBX_PERSISTENT)
or die("Could not connect");
echo "Connected successfully";
dbx_close($link);
?>
NOTES
Note
Always refer to the module-specific documentation as well.
SEE ALSO
dbx_close(3).
PHP Documentation Group DBX_CONNECT(3)