SQL statement output to Log file-How?


 
Thread Tools Search this Thread
Operating Systems HP-UX SQL statement output to Log file-How?
# 1  
Old 08-21-2007
SQL statement output to Log file-How?

Hi all,

I need to bring the message to log file.Teradat/Hp-Ux

script:
-----
### Update Log Table
bteq <<- EOC
.run file ${SRC_DATA}/logon.txt
.run file ${SRC_DATA}/dbstagebteq.txt
.set format off
.set foldline off all
.set sidetitles off
.set width 254
.set foldline on 1


UPDATE GCS_ETL_EXTRACT_LOG
SET Run_Date='${RUN_DATE}'
,Source_Row_count=${SOURCE_CNT}
,Actual_Row_Count=${ACTUAL_CNT}
,Extract_Status='${EXTRACT_STATUS}'
WHERE Source_System_Id='${SOURCE_SYS_ID}'
AND Source_File_Name='${SOURCE_FILE_NAME}'
AND Business_Date='${BUSINESS_DATE}'
ELSE
INSERT INTO GCS_ETL_EXTRACT_LOG
( Source_System_Id
,Source_File_Name
,Business_Date
,Run_Date
,Source_Row_Count
,Actual_Row_count
,Extract_Status)
VALUES( '${SOURCE_SYS_ID}'
,'${SOURCE_FILE_NAME}'
,'${BUSINESS_DATE}'
,'${RUN_DATE}'
,${SOURCE_CNT}
,${ACTUAL_CNT}
,'${EXTRACT_STATUS}');

.IF ERRORCODE = 0 THEN .GOTO UPDATEOK
.LOGOFF
.QUIT 08

.LABEL UPDATEOK
.LOGOFF
.QUIT 0
EOC


if [ $? -eq 0 ]
then
echo " "
echo "Update of GCS_ETL_EXTRACT_LOG table successfully completed."
echo " "
else
echo " "
echo "Update of GCS_ETL_EXTRACT_LOG table failed."
echo " "
exit 99
fi
===============================------------------------------------------------
now output displays on UX box itself,want to brind it into log file:
-------------------------------------------------------
*** Warning: EOF on INPUT stream.
+---------+---------+---------+---------+---------+---------+---------+----
.set format off
+---------+---------+---------+---------+---------+---------+---------+----
.set foldline off all
+---------+---------+---------+---------+---------+---------+---------+----
.set sidetitles off
+---------+---------+---------+---------+---------+---------+---------+----
.set width 254
+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+-
.set foldline on 1
+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+-


UPDATE DBS_GCS_ETL_EXTRACT_LOG
SET Run_Date='2007-08-22'
,Source_Row_count=85
,Actual_Row_Count=85
,Extract_Status='S'
WHERE Source_System_Id='EXE'
AND Source_File_Name='GCS.HK.XXR.dat'
AND Business_Date='2007-02-28'
ELSE
INSERT INTO DBS_GCS_ETL_EXTRACT_LOG
( Source_System_Id
,Source_File_Name
,Business_Date
,Run_Date
,Source_Row_Count
,Actual_Row_count
,Extract_Status)
VALUES( 'EXE'
,'GCS.HK.XXR.dat'
,'2007-02-28'
,'2007-08-22'
,85
,85
,'S');

*** Insert completed. One row added.
*** Total elapsed time was 1 second.


+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+-

.IF ERRORCODE = 0 THEN .GOTO UPDATEOK
.GOTO UPDATEOK
+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+-
.LOGOFF
*** Skipped.
+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+-
.QUIT 08
*** Skipped.
+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+-

.LABEL UPDATEOK
+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+-
.LOGOFF
*** You are now logged off from the DBC.
+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+-
.QUIT 0
*** Exiting BTEQ...
*** RC (return code) = 0

Update of DBS_GCS_ETL_EXTRACT_LOG table successfully completed.


thanks in advance.
# 2  
Old 08-22-2007
How are you running the script? Just run it as:
Code:
./script_name > /path/to/logfile 2>&1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies

2. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

3. Shell Programming and Scripting

Comparing file with Sql output.

Hi Guys, I need to compare the sql output with a column present in a file. I am able to read the column from the file and stored in a variable. Can somebody help how to store output of the below query to a variable. The database is Oracle. Select count(*) from tableName; ... (2 Replies)
Discussion started by: mac4rfree
2 Replies

4. Shell Programming and Scripting

Execute and log each statement/block SQL file

Hi friends, I would like to get some help on the following requirement. I have a SQL file with following things, select 1 from dual; select user from dual; select sysdate from dual; BEGIN PL/SQL Code END; / This file will be saved as sql file. When I run my expected shell script,... (1 Reply)
Discussion started by: ssnair
1 Replies

5. Shell Programming and Scripting

Unix shell command output to a sql statement

Can i do this Say one command sed 's/:*/ /g' $summf is returning C1234 C2345 C3434 some no of rows, now this ouput i have to insert it into a DB table how do i do this?? (2 Replies)
Discussion started by: depakjan
2 Replies

6. Shell Programming and Scripting

Executing sql statement from .sh file

Hi, How to execute sql statements from the .sh file ?? Means, when we run .sh file then the sql statements within it should be get executed one by one from the sqlplus With Regards (3 Replies)
Discussion started by: milink
3 Replies

7. Shell Programming and Scripting

writing the output of SQL into one file

Hi All, Please help me writing the below script. I have two sql queries. 1. Select count(1),Client_id from TABLE_A group by Client_id; 2. Select count(1),Client_id from TABLE_B group by Client_id; I need the output of above two sql queries in a single file. The output 2nd query should be... (4 Replies)
Discussion started by: 46019
4 Replies

8. Shell Programming and Scripting

Redirect output of print statement to file

:confused: I have a ksh script which gathers data from a file. I need to find a way to direct the output to a new file. The code looks something like this: DUP_FILE=`touch /export/.../.../dup_social_$1` while (($# > 0 )) do # Make sure the file exists if ] then print "$1: does not... (4 Replies)
Discussion started by: Muga801
4 Replies

9. Shell Programming and Scripting

Awk output to file in IF statement

Hi all, I currently have the following script in 1) which outputs to a file if the 3rd column is equal to the message_id value. This works. However what I want to do is incorporate an else statement and output to a different file if the 3rd column doesnt equal the message_id values. I tried that... (7 Replies)
Discussion started by: Donkey25
7 Replies

10. Shell Programming and Scripting

Creating an sql statement from a file. Problem with '

Hi, I am trying to create sql statements from a file, but I have a problem with ': This is what I do: cat filex.txt | awk -F: '{print $1,"A","and personnavn like",$5}' | sed -e "s/^/select bruker.brukernavn, person.personnavn from bruker, person where brukernavn like '/" -e "s/$/' and... (2 Replies)
Discussion started by: hannem
2 Replies
Login or Register to Ask a Question