SQL Script run in KSH Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers SQL Script run in KSH Script
# 1  
Old 02-10-2006
SQL Script run in KSH Script

I've got a SQL script that is executed through a UNIX ksh script. It is working fine, but I wanted to add a line to put a date/time stamp in the log file that it generates.

This is more of a SQL question, but I'm hoping someone can help me get the date/time...I've changed the script with the bold statement below to find the sysdate, but for some reason, it is displayed twice in the log file. And I don't know how to find the time...


DEFINE LOG_DIR=&1
SPOOL &&LOG_DIR/tf_tbl_daily.log
ALTER SYSTEM FLUSH SHARED_POOL

/
TRUNCATE TABLE tf_tbl;
select sysdate from dual;
/
SPOOL OFF
EXIT
# 2  
Old 02-10-2006
Code:
select sysdate from dual;
/

"/" and ";" are functionally the same here. Lose one of them.
Code:
select to_char(sysdate, 'mm/dd/yyyy hh24:mi:ss') from dual;

will give you the time.

By the way, why are you flushing the shared pool?
# 3  
Old 02-13-2006
Over the weekend, my DBA pointed out to me that I should not be using that ALTER SYSTEM statement. Don't know why it was added originally, it's not my original code.

Thanks, the date/time statement works great!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

Time taken to run a SQL script

Hello I am asked to run around 5-6 SQL queries in a shell script and take a note of the time taken to execute each query to a file. How do I get the time taken to run the individual SQL queries (2 Replies)
Discussion started by: vat1kor
2 Replies

3. Shell Programming and Scripting

how to Connect from ksh script to SQL server

I need to connect sql server 2008 from korn shell script. Can you please give me the script which connects sql server 2008 from korn shell script. (2 Replies)
Discussion started by: santoshhegde
2 Replies

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

5. Shell Programming and Scripting

Run Sql plus in shell script

Hello, I want to connect to ssh, run a query, and store that into a variable in the shell script. Also I need to pass the variable back to php to display the query results. I have created a public/private key pair for ssh connection and that is working fine. Also I am able to run query in the... (8 Replies)
Discussion started by: shekhar2010us
8 Replies

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

7. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

8. Shell Programming and Scripting

KSH script SQL timeout issue

Hi all, I have a KSH script which is kicking off an sql scripts as follows: /usr/local/installs/instantclient_10_2/sqlplus -s username/password @$sql_path/sql_query.sql > $tmp_path/sql_query_results The problem I have is that sometimes the 10g Oracle Database spits out an error saying... (4 Replies)
Discussion started by: Donkey25
4 Replies

9. Shell Programming and Scripting

what is the uses in sql script in ksh

hi, iam new of unix. how to call sql script in ksh script (1 Reply)
Discussion started by: naveeng.81
1 Replies

10. UNIX for Dummies Questions & Answers

problem to run sql startment in script

Hello, I have a script to run a list of customer information, but it not work. can anyone help below: echo "Please input list to check customer detail:" read list for file in 'cat $list.txt' do echo "select cuname as "FROM CUNAME", invo_num as "RECS", total_amount as "AMOUNT", tax_amount as... (7 Replies)
Discussion started by: happyv
7 Replies
Login or Register to Ask a Question