Sponsored Content
Full Discussion: Sqlplus in shell script
Top Forums Shell Programming and Scripting Sqlplus in shell script Post 302857247 by pvmanikandan on Wednesday 25th of September 2013 05:12:09 PM
Old 09-25-2013
Sqlplus in shell script

Hi All,

Please let me know what i am missing in the following code (part of my script)

Code:
Schemas=(AWQM WFCONTROLLER PROVCO PRISM)

for s in "${Schemas[@]}"
do 
    sch="${s}_$tol"
        
    if [ $tol == AD ] || [ $tol == TD ];then

        echo "This is AD or TD region"

        sqlplus -s $sch/$tpwd@$ttns <<EOF
        set feedback off;
        set pagesize 0;
        set linesize 500;
        set trimspool on;

        spool run_$sch_drops.sql

        select 'set echo on'||chr(59) from dual;
        select 'spool run_'${sch}'_drops.log'||chr(59) from dual;
        select 'show user'||chr(59) from dual;
        select '' from dual;
        select 'drop table "'||table_name||'" cascade constraints purge'||chr(59) from all_tables where owner = '${sch}';
        select '' from dual;
        select 'drop synonym "'||synonym_name||'"'||chr(59) from all_synonyms where owner = '${sch}';
        select '' from dual;
        select 'Drop TYPE "'||OBJECT_NAME||'" Force'||chr(59) from all_objects where object_type='TYPE' and owner='${sch}';
        select 'quit'||chr(59) from dual;

        quit;
        EOF
        

    else
        echo "This is Other Env"
        
    fi
done

I am getting error syntax error: unexpected end of file when i run my script.

Please suggest

Thanks,
Mani
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing parameters from a shell script to sqlplus

Hi , I want to pass parameters from a shell script to a sql script and use the parameter in the sql query ..and then I want to spool a particular select query on to my unix box... for 4 different locations by writing only one sql script Right now no file is generated on the unix box...it is a... (2 Replies)
Discussion started by: phani
2 Replies

2. Shell Programming and Scripting

running shell script from sqlplus

I have a script which connects to different database servers using sqlplus. Is there a way by which I can run a shell command on that host from sqlplus? I know about 'host' command but it runs script on the local machine where the original script is running. Is there a way to run command on the... (9 Replies)
Discussion started by: dkr123
9 Replies

3. UNIX for Dummies Questions & Answers

Shell Script And SQLPLUS

i'm having real problems retrieving the returncode of my sqlplus-call. I found a lot of informations on the net, but havn't been able to get it running so far, so now i ask for some help ;) I do start the sqlplus out of my shell script with the parameters stored in the proc_clips.sql, which is... (6 Replies)
Discussion started by: maco_home
6 Replies

4. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

5. Shell Programming and Scripting

Call sqlplus in the shell script

Hi, I am writing a script to test database connection. If the first try fails, it will wait for 1 minutes and then try again. The script is as following: ........ for i in $ORACLE_SID do $ORACLE_HOME/bin/sqlplus $username/$password@$i <<! >/dev/null select * from tab; exit if ; then... (3 Replies)
Discussion started by: beaniebear
3 Replies

6. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

7. Shell Programming and Scripting

SQLPLUS within shell script

Hi I want to connect to the Oracle database using a username/password and get back the query result(a numeric value) in a variable, which I can then compare using a conditional. Can anybody help me with this. Thanks Gaurav (4 Replies)
Discussion started by: gaurav_1711
4 Replies

8. Shell Programming and Scripting

Want to learn/use SQLPLUS in shell script

Hi All, How i will use sqlplus in shell script? Can any one provide sample code which explain following: 1. Connect to oracle DB 2. Exceute select * from tablename 3. Release connection to the DB 4. Append output in file everytime when query executes. Thanks in advance (1 Reply)
Discussion started by: poweroflinux
1 Replies

9. Shell Programming and Scripting

SQLplus and Shell script problem

sql_rows=`sqlplus -s / <<EOF set heading off set pagesize 1000 set tab off set linesize 120 wrap off column "Path" format a15 --column "No_Of_files" format a10 select tablespace_name, substr(file_name,1,instr(file_name,'/',1,2)) as "Path" , count(*) as "No_Of_files" from dba_data_files ... (7 Replies)
Discussion started by: desibabu
7 Replies

10. Shell Programming and Scripting

sqlplus in shell script

Hi When I use sqlplus in shell script, I get sqlplus: command not found. ORACLE_HOME is not set. How to set ORACLE_HOME in unix? Thanks (3 Replies)
Discussion started by: vinoth_kumar
3 Replies
funcen(1)							SAORD Documentation							 funcen(1)

NAME
funcen - find centroid (for binary tables) SYNOPSIS
funcen [-i] [-n iter] [-t tol] [-v lev] <iname> <region> OPTIONS
-i # use image filtering (default: event filtering) -n iter # max number of iterations (default: 0) -t tol # pixel tolerance distance (default: 1.0) -v [0,1,2,3] # output verbosity level (default: 0) DESCRIPTION
funcen iteratively calculates the centroid position within one or more regions of a Funtools table (FITS binary table or raw event file). Starting with an input table, an initial region specification, and an iteration count, the program calculates the average x and y position within the region and then uses this new position as the region center for the next iteration. Iteration terminates when the maximum number of iterations is reached or when the input tolerance distance is met for that region. A count of events in the final region is then output, along with the pixel position value (and, where available, WCS position). The first argument to the program specifies the Funtools table file to process. Since the file must be read repeatedly, a value of "stdin" is not permitted when the number of iterations is non-zero. Use Funtools Bracket Notation to specify FITS extensions and filters. The second required argument is the initial region descriptor. Multiple regions are permitted. However, compound regions (accelerators, variable argument regions and regions connected via boolean algebra) are not permitted. Points and polygons also are illegal. These restrictions might be lifted in a future version, if warranted. The -n (iteration number) switch specifies the maximum number of iterations to perform. The default is 0, which means that the program will simply count and display the number of events in the initial region(s). Note that when iterations is 0, the data can be input via stdin. The -t (tolerance) switch specifies a floating point tolerance value. If the distance between the current centroid position value and the last position values is less than this value, iteration terminates. The default value is 1 pixel. The -v (verbosity) switch specifies the verbosity level of the output. The default is 0, which results in a single line of output for each input region consisting of the following values: counts x y [ra dec coordsys] The last 3 WCS values are output if WCS information is available in the data file header. Thus, for example: [sh] funcen -n 0 snr.ev "cir 505 508 5" 915 505.00 508.00 345.284038 58.870920 j2000 [sh] funcen -n 3 snr.ev "cir 505 508 5" 1120 504.43 509.65 345.286480 58.874587 j2000 The first example simply counts the number of events in the initial region. The second example iterates the centroid calculation three times to determine a final "best" position. Higher levels of verbosity obviously imply more verbose output. At level 1, the output essentially contains the same information as level 0, but with keyword formatting: [sh] funcen -v 1 -n 3 snr.ev "cir 505 508 5" event_file: snr.ev initial_region: cir 505 508 5 tolerance: 1.0000 iterations: 1 events: 1120 x,y(physical): 504.43 509.65 ra,dec(j2000): 345.286480 58.874587 final_region1: cir 504.43 509.65 5 Level 2 outputs results from intermediate calculations as well. Ordinarily, region filtering is performed using analytic (event) filtering, i.e. that same style of filtering as is performed by fundisp and funtable. Use the -i switch to specify image filtering, i.e. the same style filtering as is performed by funcnts. Thus, you can per- form a quick calculation of counts in regions, using either the analytic or image filtering method, by specifying the -n 0 and optional -i switches. These two method often give different results because of how boundary events are processed: [sh] funcen snr.ev "cir 505 508 5" 915 505.00 508.00 345.284038 58.870920 j2000 [sh] funcen -i snr.ev "cir 505 508 5" 798 505.00 508.00 345.284038 58.870920 j2000 See Region Boundaries for more information about how boundaries are calculated using these two methods. SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funcen(1)
All times are GMT -4. The time now is 09:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy