Sponsored Content
Top Forums Shell Programming and Scripting How to run a SQL select query in Oracle database through shell script? Post 302583715 by radoulov on Wednesday 21st of December 2011 05:19:25 AM
Old 12-21-2011
You can have a persistent connection if your shell implements coprocesses (ksh93, zsh and bash 4 support coprocesses).

If you need something like this though, most probably the shell is not the right choice (use PL/SQL, Perl or some other high level programming language).

Why do you want to fetch n records at a time? I'm just curious ...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

run oracle query remotly with shell script

hello how to run shell script to excute oracle queries on remote db ? i have tried as following sqlplus -s user/password@remote_server "select query;" but not working also this one sqlplus -s user/password@remote_server `select query;` not working :( i add this line to run another... (4 Replies)
Discussion started by: mogabr
4 Replies

2. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

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

3. Shell Programming and Scripting

run sql query via perl script

Hello, If I run this command on the server it works. # dbc "update config set radio_enabled = 0;" how can I execute the same command in perl. I have defined the dbc path. Can any one please correct the last line. #!/usr/bin/perl #database path $dbc='/opt/bin/psql -Userver... (0 Replies)
Discussion started by: sureshcisco
0 Replies

4. Shell Programming and Scripting

Need help to run sql query from a script..which takes input from a file

I need to run sql script from shell script which takes the input from a file and contents of file will be like : 12345 34567 78657 and query will be like : select seq_nbr from bus_event where event_nbr='12345'; select seq_nbr from bus_event where event_nbr='34567'; select seq_nbr... (1 Reply)
Discussion started by: rkrish
1 Replies

5. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

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

6. Shell Programming and Scripting

Korn Script to connect and query oracle database

I've been sent the following script to finish. It's supposed to connect to an oracle database, query it, and send an email if the query result value is one or more. Currently it isn't connecting properly, just giving the following error: ERROR: ORA-01017: invalid username/password; logon denied... (2 Replies)
Discussion started by: jackmorgan2007
2 Replies

7. Shell Programming and Scripting

Run SQL thru shell script: how to get a new line when run sql query?

Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database. I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :( What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies

8. Shell Programming and Scripting

Shell script to run sql query having a long listing of parameters

Hi, I have a query regarding execution of a sql query having long listing of parameters ..I need to execute this query inside a shell script. The scenario is like.... Suppose I have a file abc.txt that has the card numbers..it could be in thousands.. then I need to fire a query like ... (12 Replies)
Discussion started by: vsachan
12 Replies

9. UNIX for Dummies Questions & Answers

Script to run sql query.

Please read How To Ask Questions The Smart Way (1 Reply)
Discussion started by: balu_279013
1 Replies

10. Shell Programming and Scripting

Run sql query in shell script and output data save as delimited text

I want to run sql query in shell script and output data save as delimited text (delimited text would be comma) Code: SPOOL_FILE=/pgedw/dan.txt SQL=/pgedw/dan.sql sqlplus -s username/password@myhost:port/servicename <<EOF set head on set COLSEP , set linesize 32767 SET TRIMSPOOL ON SET... (8 Replies)
Discussion started by: Jaganjag
8 Replies
DBIx::SearchBuilder::Handle::Oracle(3pm)		User Contributed Perl Documentation		  DBIx::SearchBuilder::Handle::Oracle(3pm)

NAME
DBIx::SearchBuilder::Handle::Oracle - An oracle specific Handle object SYNOPSIS
DESCRIPTION
This module provides a subclass of DBIx::SearchBuilder::Handle that compensates for some of the idiosyncrasies of Oracle. METHODS
Connect PARAMHASH: Driver, Database, Host, User, Password Takes a paramhash and connects to your DBI datasource. BuildDSN Customized version of "BuildDSN" in DBIx::SearchBuilder::Handle method. Takes additional argument SID. Database argument used unless SID provided. Two forms of DSN are generated depending on whether Host defined or not: dbi:Oracle:sid=<SID>;host=...[;port=...] dbi:Oracle:<SID> Read details in documentation for DBD::Oracle module. Insert Takes a table name as the first argument and assumes that the rest of the arguments are an array of key-value pairs to be inserted. InsertFromSelect Customization of "InsertFromSelect" in DBIx::SearchBuilder::Handle. Unlike other DBs Oracle needs: o id generated from sequences for every new record. o query wrapping in parens. NOTE that on Oracle there is a limitation on the query. Every column in the result should have unique name or alias, for example the following query would generate "ORA-00918: column ambiguously defined" error: SELECT g.id, u.id FROM ... Solve with aliases: SELECT g.id AS group_id, u.id AS user_id FROM ... KnowsBLOBs Returns 1 if the current database supports inserts of BLOBs automatically. Returns undef if the current database must be informed of BLOBs for inserts. BLOBParams FIELD_NAME FIELD_TYPE Returns a hash ref for the bind_param call to identify BLOB types used by the current database for a particular column type. The current Oracle implementation only supports ORA_CLOB types(112). ApplyLimits STATEMENTREF ROWS_PER_PAGE FIRST_ROW takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW; DistinctQuery STATEMENTREF takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set. BinarySafeBLOBs Return undef, as Oracle doesn't support binary-safe CLOBS DatabaseVersion Returns value of ORA_OCI constant, see "Constants" in DBI. SimpleDateTimeFunctions Returns hash reference with specific date time functions of this database for "DateTimeFunction" in DBIx::SearchBuilder::Handle. ConvertTimezoneFunction Custom implementation of "ConvertTimezoneFunction" in DBIx::SearchBuilder::Handle. Use the following query to get list of timezones: SELECT tzname FROM v$timezone_names; Read Oracle's docs about timezone files: http://download.oracle.com/docs/cd/B14117_01/server.101/b10749/ch4datetime.htm#i1006667 AUTHOR
Jesse Vincent, jesse@fsck.com SEE ALSO
perl(1), DBIx::SearchBuilder perl v5.14.2 2011-09-21 DBIx::SearchBuilder::Handle::Oracle(3pm)
All times are GMT -4. The time now is 12:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy