Sponsored Content
Top Forums Shell Programming and Scripting How to pass Oracle sql script as argument to UNIX shell script? Post 302913895 by a1_win on Wednesday 20th of August 2014 02:59:28 PM
Old 08-20-2014
How to pass Oracle sql script as argument to UNIX shell script?

Hi all,

$ echo $SHELL
/bin/bash


Requirement - How to pass oracle sql script as argument to unix shell script?

$ ./output.sh users.sql

Below are the shell scripts and the oracle sql file in the same folder.

Code:
Shell Script

$ cat output.sh
#!/bin/bash
. /test1/product/r12/TEST1/apps/apps_st/appl/APPSTEST1_xyz.env

/test1/product/r12/TEST1/apps/tech_st/10.1.2/bin/sqlplus apps/apps@TEST1  <<-EOF

spool fnd_user_output.xls
@users.sql
spool off
exit;
EOF


Code:
Oracle Sql script

cat users.sql
EXPLAIN PLAN SET STATEMENT_ID='TIM1' FOR
select q.concurrent_queue_name || ' - ' || target_node qname
     ,a.request_id "Req Id"
     ,decode(a.parent_request_id,-1,NULL,a.parent_request_id) "Parent"
     ,a.concurrent_program_id "Prg Id"
     ,a.phase_code,a.status_code
     ,b.os_process_id "OS"
     ,vs.sid
     ,vp.spid
     ,(nvl(actual_completion_date,sysdate)-actual_start_date)*1440 "Time"
     ,c.concurrent_program_name||' - '||
      c2.user_concurrent_program_name "program"
from APPLSYS.fnd_Concurrent_requests a,APPLSYS.fnd_concurrent_processes b
   ,applsys.fnd_concurrent_queues q
   ,APPLSYS.fnd_concurrent_programs_tl c2
   ,APPLSYS.fnd_concurrent_programs c
   ,sys.v$session vs
   ,sys.v$process vp
where a.controlling_manager = b.concurrent_process_id
 and a.concurrent_program_id = c.concurrent_program_id
 and a.program_application_id = c.application_id
 and c2.concurrent_program_id = c.concurrent_program_id
 and a.phase_code in ('I','P','R','T')
 and b.queue_application_id = q.application_id
 and b.concurrent_queue_id = q.concurrent_queue_id
 and c2.language = 'US'
 and vs.process (+) = b.os_process_id
 and vs.paddr = vp.addr (+)
order by 1,2
/


SET LINESIZE 130
set feedback off verify off heading off pagesize 0
SELECT * FROM  TABLE(DBMS_XPLAN.DISPLAY('PLAN_TABLE','TIM1','ADVANCED'));

Thank You for your time!

Regards,
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to pass values from oracle sql plus to unix shell script

how to pass values from oracle sql plus to unix shell script (2 Replies)
Discussion started by: trichyselva
2 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. UNIX for Advanced & Expert Users

How to use parameter in sql script pass from unix script?

Hi, I am unable to use parameter in sql script passed from unix script. my sql script CREATE_SBI_LIST_GROUP.sql is like this - ------------------------------- SELECT SDS.ID "SO_ID", SDS.SO a1, sgp.sga__code SGA_CODE, FROM sga sga,sales_genl_provision sgp , comm_product_condn cpc... (2 Replies)
Discussion started by: apskaushik
2 Replies

4. Shell Programming and Scripting

pass null value to sql script from korn shell script

There are 4 parameters that I have to pass from korn shell to sql script. 1) I have to check if $1 , $2 , $3 and $4 are null values or not . How can I do that ? 2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
Discussion started by: megha2525
11 Replies

5. Shell Programming and Scripting

How we can pass the argument when calling shell script from perl script

Can someone let me know how could I achieve this In one of per script I am calling the shell script but I need to so one thing that is one shell script call I need to pass pne argument.In below code I am calling my ftp script but here I want to pass one argument so how could I do this (e.g:... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies

6. Programming

pass value from Oracle sql to Korn shell

Hi All , I am trying to pass a value from sqlplus to korn shell . There is a table tab1 in Oracle that has a column userdate. I need to pass the userdate to the korn shell . This is what I am doing . VALUE=`sqlplus -silent username/password << END set pagesize 0 feedback off verify off... (14 Replies)
Discussion started by: megha2525
14 Replies

7. UNIX for Advanced & Expert Users

Use of Oracle pl/sql in UNIX shell script

Hi, I have basic knowledge on how to write pl/sql code inside shell script. I am looking for more advance thing. Is there any book for that which can just talk about how to write more advance plsql code inside shell script. Please help Thanks!!!!!! (1 Reply)
Discussion started by: diehard
1 Replies

8. Shell Programming and Scripting

How to pass command line argument in shell script?

I need to write a shell script, when I run that script I should pass those arguments if not, then script should not run and pass the error message like invalid option - - should pass the argument. and Exit from the script https://www.unix.com/images/misc/progress.gif (1 Reply)
Discussion started by: Nsharma3006
1 Replies

9. UNIX for Dummies Questions & Answers

How to pass command line argument in shell script?

I need to write a shell script, when I run that script I should pass those arguments if not, then script should not run and pass the error message like invalid option - - should pass the argument. and Exit from the script (8 Replies)
Discussion started by: Nsharma3006
8 Replies

10. Shell Programming and Scripting

Unable to pass value from .Shell script to .SQL file

Hi All, I am new to shell script. I am trying to pass value from .sh file to .sql file . But I am able to run the .sql file from .sh file with values in sql file. But I am unable to pass the values from .sh file. can some one please help to resolve this. here is my .sh file s1.sh ... (4 Replies)
Discussion started by: reddy298599
4 Replies
cvm-sql(7)						 Miscellaneous Information Manual						cvm-sql(7)

NAME
cvm-sql - CVM SQL Framework QUERY SUBSTITUTION
$VAR and ${VAR} are replaced with the quoted value of the environment variable named VAR. Use the second form when VAR contains anything other than alpha-numeric or underscore (_) characters. Do not include quotes in the query. The variables account and domain contain the account and domain names given by the CVM client. $$ is replaced with a single dollar sign. QUERY RESULTS
The query must produce the following fields exactly in order. All required fields must not be null or empty. 1. Password, encrypted with crypt(3) (required) 2. Actual account name (required) 3. User ID (integer) (required) 4. Group ID (integer) (required) 5. Directory (required) 6. Real name (optional) 7. Login shell (optional) 8. Group name (optional) 9. Domain name (optional) 10. System account name (optional) 11. System account directory (optional) 12. Mailbox path (optional) DEFAULT QUERY
SELECT password, username, userid, groupid, directory, realname, shell, groupname, domain, sys_username, sys_directory FROM accounts WHERE username=$account AND domain=$domain SEE ALSO
cvm-mysql(8), cvm-pgsql(8), cvm-pwfile(8), cvm-qmail(8), cvm-unix(8), cvm-vmailmgr(8), cvm-benchclient(8), cvm-checkpassword(8), cvm-test- client(8) http://untroubled.org/cvm/cvm.html cvm-sql(7)
All times are GMT -4. The time now is 06:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy