Sponsored Content
Top Forums Shell Programming and Scripting Calling SQL LDR and SQL plus scripts in a shell script Post 302143946 by gus2000 on Monday 5th of November 2007 01:31:04 PM
Old 11-05-2007
Using the "here document"

Using a "here" document would essentially be the same as using a long string. These are equivalent:

Code:
print "query1
query2
query3" | sqlplus

Code:
cat <<-\EOF | sqlplus
         query1
         query2
         query3
EOF

Code:
print "query1" | sqlplus
print "query2" | sqlplus
print "query3" | sqlplus

Either of the first two should be more efficient than the last. Take this example:


Code:
# This takes a long time (20-30 sec)
i=0
time while (((i+=1)<100)); do
    rsh localhost date;
done

# This is fast!  1 second!
cat <<-\EOF | rsh localhost sh
                i=0
                while (((i+=1)<100)); do
                        date
                done
                EOF

Since I use "-\EOF", the dash "-" removes any leading tabs from each line. The backslash "\" prevents all the text from being evaluated, and without it I would need to escape any special characters.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling SQL scripts through Shell Script

Oracle and Scripting gurus, I need some help with this script... I am trying to add the query SELECT * FROM ALL_SYNONYMS WHERE SYNONYM_NAME = 'METADATA' in the current script.... Read the result set and look for the TABLE_NAME field. If the field is pointing to one table eg.... (18 Replies)
Discussion started by: madhunk
18 Replies

2. UNIX for Advanced & Expert Users

Calling PL/SQL Script in Shell Programming

Hi all, In a shell script I need to pass two parameters to a pl/sql script and get the ouput of the pl/sql script and use it in shell script. For example Shell script : test.sh PL/SQL script : get_id.sql parameter1 parameter2 Actually get_id.sql has a select statement something... (1 Reply)
Discussion started by: lijju.mathew
1 Replies

3. Shell Programming and Scripting

calling sql file from shell script

Hello everybody I need help calling sql file from shell script. Can anyone help me creating a small shell script which calls an sql file . The .sql file should contain some select statements like select emp_no from emp_table; select emp_id from emp_table; And the results should be... (6 Replies)
Discussion started by: dummy_needhelp
6 Replies

4. Shell Programming and Scripting

any possible solution on sql calling scripts

hi all, i have a function which will take i/p as a ddl sctipt as i/p and execute it, let function execute_sql { db_var="$1" v_cnt=`sqlplus -s XXXXX/XXXXX@aXXX << ENDSQL | sed -e "s/Connected\.//" -e "/^$/d" set pagesize 0 feedback off verify off heading off echo off serveroutput on size... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

5. Shell Programming and Scripting

Calling sql in shell script with parameters

Dear All, I want to call an sql script within a unix shell script. I want to pass a parameter into the shell script which should be used as a parameter in teh sql script. e.g $ ./shell1.sh 5000129 here 5000129 is a prameter inside shell script i am calling one sql script e.g. ... (2 Replies)
Discussion started by: Radhe
2 Replies

6. UNIX for Advanced & Expert Users

Calling sql file from shell script

Hi I have a shell script that call a sql file. The sql file will create a spool file. My requirement is, when ever i get an OS error like file not found. I have to log it in a log file. Could some who worked in a like scenario help me by giving the code sample. Many Thanks.. (1 Reply)
Discussion started by: chintapalli001
1 Replies

7. Shell Programming and Scripting

calling a sql file in my shell script

Hi, I want to call a sql file in my shell script. see the below code:- if ] then ( isql -U${S_USER} -S${S_SERV} -w100 -b -h0 <<ENDSQL | sed -e "s/Password://" ${S_PWD} set nocount on go use ${S_DB} go // need to call a file name... (16 Replies)
Discussion started by: dazdseg
16 Replies

8. Shell Programming and Scripting

Calling sql file from shell script with parameters.

Hi, I am calling a sql file script.sql from shell script and passing few parameters also as shown below: sqlplus -S id/password @script.sql $param1 $param2 Now,In sql file I have to create a extract text file after querying oracle tables based on the parameters passed(param1,param2) as... (7 Replies)
Discussion started by: anil029
7 Replies

9. UNIX for Advanced & Expert Users

Call parallel sql scripts from shell and return status when both sql are done

Hi Experts: I have a shell script that's kicked off by cron. Inside this shell script, I need to kick off two or more oracle sql scripts to process different groups of tables. And when both sql scripts are done, I will continue in the shell script to do other things like checking processing... (3 Replies)
Discussion started by: huasheng8
3 Replies

10. Shell Programming and Scripting

[Solved] Calling PL/SQL Block into Shell Script

Hi, i have one simple PL/SQL Block and i have saved it as .sql file, which i am trying to call from UNIX script. PL/SQL block structure CONNECT DB_NAME/PWD@Database whenever SQLERROR EXIT 1; Declare ..Variables... BEGIN --Code-- exception END; exit; I have save this block as... (3 Replies)
Discussion started by: abhii
3 Replies
YAZ_SEARCH(3)								 1							     YAZ_SEARCH(3)

yaz_search - Prepares for a search

SYNOPSIS
bool yaz_search (resource $id, string $type, string $query) DESCRIPTION
yaz_search(3) prepares for a search on the given connection. Like yaz_connect(3) this function is non-blocking and only prepares for a search to be executed later when yaz_wait(3) is called. PARAMETERS
o $id - The connection resource returned by yaz_connect(3). o $type - This parameter represents the query type - only "rpn" is supported now in which case the third argument specifies a Type-1 query in prefix query notation. o $query - The RPN query is a textual representation of the Type-1 query as defined by the Z39.50 standard. However, in the text represen- tation as used by YAZ a prefix notation is used, that is the operator precedes the operands. The query string is a sequence of tokens where white space is ignored unless surrounded by double quotes. Tokens beginning with an at-character ( @) are considered operators, otherwise they are treated as search terms. RPN Operators +-----------------------------+---------------------------------------------------+ | Construct | | | | | | | Description | | | | +-----------------------------+---------------------------------------------------+ | | | | @and query1 query2 | | | | | | | intersection of query1 and query2 | | | | | | | | @or query1 query2 | | | | | | | union of query1 and query2 | | | | | | | | @not query1 query2 | | | | | | | query1 and not query2 | | | | | | | | @set name | | | | | | | result set reference | | | | | | | | @attrset set query | | | | | | | specifies attribute-set for query. This con- | | | struction is only allowed once - in the beginning | | | of the whole query | | | | | | | |@attr [set] type=value query | | | | | | | applies attribute to query. The type and value | | | are integers specifying the attribute-type and | | | attribute-value respectively. The set, if given, | | | specifies the attribute-set. | | | | +-----------------------------+---------------------------------------------------+ You can find information about attributes at the Z39.50 Maintenance Agency site. Note If you would like to use a more friendly notation, use the CCL parser - functions yaz_ccl_conf(3) and yaz_ccl_parse(3). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Query Examples You can search for simple terms, like this: computer The query "knuth donald" This query applies two attributes for the same phrase. The query @and @or a b @not @or c d e (a or b) and ((c or d) not e). Another, more complex, one: @attrset gils @and @attr 1=4 art @attr 1=2000 company art occur in the title (GILS,BIB-1) and in which company occur as Distributor (GILS). PHP Documentation Group YAZ_SEARCH(3)
All times are GMT -4. The time now is 10:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy