Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > writing sql error to a log file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-03-08, 05:55
flowers_n flowers_n is offline
Registered User
 
Join Date: Jan 2008
Posts: 2
writing sql error to a log file

I have one procedure which has output parameter error_msg.

i want to pass this error_msg to a log file in unix shell scripting.

how will i do.

thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 01-03-08, 06:37
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Posts: 1,646
You could just redirect the output of your SQL CLP?
__________________
Knut Stolze
Data Warehousing on System z
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 01-03-08, 07:37
flowers_n flowers_n is offline
Registered User
 
Join Date: Jan 2008
Posts: 2
How to redirect it that i don't know.


STORAGE_TYPE=$1

echo "########### SQL SESSION STARTED ###########"

sqlplus tcupro/tcupro_dev@BDD1OPTN << THEEND


Code:
SET SERVEROUTPUT ON DECLARE V_STORAGE_TYPE varchar2(3); V_ERR_MSG varchar2(255) ; BEGIN V_STORAGE_TYPE := '$STORAGE_TYPE'; V_ERR_MSG := 'SUCCESS'; dbms_output.put_line(V_STORAGE_TYPE); TCUPRO.PURGE_TABLES_TEST(V_STORAGE_TYPE, V_ERR_MSG); dbms_output.put_line(V_ERR_MSG); dbms_output.put_line(V_STORAGE_TYPE); END; / EXIT; THEEND

V_ERR_MSG IS TO BE PASSED TO A LOG FILE. HOW CAN I PASS.
Reply With Quote
  #4 (permalink)  
Old 01-03-08, 09:08
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Posts: 1,646
Oracle has some functions like PUT_LINE that you can use to write to a file on the server. http://www.psoug.org/reference/dbms_output.html If you want to write things to a file on the client, you need some sort of application logic. For example, you can capture the output stream, extract the message with tools like SED, AWK, Perl or whatever you prefer, and then do with the message whatever you like, e.g. writing it to another file. Since I don't know the exact output produced by your script (I don't use Oracle often), others could help you there.

p.s: Personally, I don't think it is a good idea to write something to a file residing on the database server. Most systems beyond the scale of toy systems use a multi-tiered architecture and your application doesn't run on the DBMS server.
__________________
Knut Stolze
Data Warehousing on System z
IBM Germany Research & Development
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On