Executing pl/sql using sqlplus on unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing pl/sql using sqlplus on unix
# 1  
Old 02-10-2008
Executing pl/sql using sqlplus on unix

Hi to all,

I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes:

sqlplus temp/temp@data @run.sql&
echo $!>>pid.txt

However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.

so I change the endday.sh like this below:

sqlplus temp/temp@data @run.sql& (1)
sqlplus -s temp/temp@data << EOF (2)
insert into liv_pid (pid) values ($!);
exit
EOF

In the insert into statement by using $!, do I take pid of 1 or 2, and indeed can I take the pid? And does this final endday.sh work?

Thank you very much, and I need urgent help....
# 2  
Old 02-11-2008
You can select SPID from v$session and v$process and insert it to table:
select p.spid "Process"
from v$session s, v$process p
where s.paddr = p.addr and audsid = userenv( 'sessionid' );
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX Sqlplus - Capture the sql statement about to run and execution status

Greetings Experts, I am on AIX using ksh. Created a unix script which generates the CREATE OR REPLACE VIEW ... and GRANT .. statements, which are placed in a single .txt file. Now I need to execute the contents in the file (there are around 300 view creation and grant statements) in Oracle and... (4 Replies)
Discussion started by: chill3chee
4 Replies

2. Shell Programming and Scripting

Help in executing the following db2 sql querry in unix

Hi All, Please help me out in executing the following db2 querry in unix db2 "select AP_RQ_ACQ_INST_ID || ',' || txn_classifier || ',' || AP_RS_RESP_CD || ',' || (count(*) AS COUNT1) || ',' || (SUM(AP_RQ_TXN_AMT) AS TOTAL_AMT) from TXN_RECORD where CREATE_TS > '2010-11-22 11:00:00.008645' ... (1 Reply)
Discussion started by: dudd9
1 Replies

3. UNIX for Advanced & Expert Users

Executing SQL file in UNIX

I have few .sql file at some location say /x/y/z. I want to execute those .sql files in UNIX server so that all packages,procedures can be applied on the database of the UNIX server. (1 Reply)
Discussion started by: Dip
1 Replies

4. UNIX for Dummies Questions & Answers

executing SQL query using unix shell script

I want to perform few post-session success tasks like update a status to 'true' in one of the sql database table, update date values to current system date in one of the configuration table in sql. How do i achieve this in a post session command?syntax with example will be helpful. (3 Replies)
Discussion started by: nathanvaithi
3 Replies

5. 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

6. Shell Programming and Scripting

Executing a Oracle SQL statement in a UNIX script

Hi All, I need to select one column from a table based upon the passed in parameter. I tried this: sqlplus -silent $MISP_USER << EOF set feedback off; set verify off; set sqlprompt "" SELECT mail_flag FROM dailyjobs WHERE job_name = '$1'; exit 0 EOF exit... (1 Reply)
Discussion started by: ganga.dharan
1 Replies

7. UNIX for Advanced & Expert Users

Executing SQLPLUS in UNIX Script from JAVA

Hi ALL, I would like to execute one SQL query(ORACLE) in UNIX shell script. For this I used sqlplus in script and tested locally. It worked fine. But my requiremnt is to execute the script from Java. In this case the UNIX part is working but sqlplus is not returning anything The JAVA code used... (0 Replies)
Discussion started by: anooptech
0 Replies

8. UNIX for Advanced & Expert Users

Executing pl/sql using sqlplus on unix

Hi to all, I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes: sqlplus temp/temp@data @run.sql& echo $!>>pid.txt However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.... (1 Reply)
Discussion started by: maverick1234
1 Replies

9. Programming

Executing pl/sql using sqlplus on unix

Hi to all, I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes: sqlplus temp/temp@data @run.sql& echo $!>>pid.txt However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.... (1 Reply)
Discussion started by: maverick1234
1 Replies

10. Solaris

Executing MS-SQL stored procedures from Unix/C Program?

All, We are contemplating a port of an existing software product and would like to expend as little effort as possible. Our new database would be MS-SQL, and we would write stored procedures to perform common db operations. We'd like to call these stored procedures from C or C++ code running... (3 Replies)
Discussion started by: mparks
3 Replies
Login or Register to Ask a Question