The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
print selected rows with awk tonet Shell Programming and Scripting 6 09-27-2007 03:23 AM
splitting a column into rows spindoctor UNIX for Dummies Questions & Answers 3 07-24-2007 12:25 PM
return number of rows selected new2ss Shell Programming and Scripting 7 01-08-2007 06:46 AM
Factorize some rows in a column frebo UNIX for Dummies Questions & Answers 5 03-21-2006 02:41 AM
Cutting rows after a selected point nhatch Shell Programming and Scripting 4 09-05-2003 07:14 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-27-2005
Registered User
 

Join Date: Feb 2005
Location: Columbus OH
Posts: 132
flags to suppress column output, # of rows selected in db2 sql in UNIX

Hello,

I am new to db2 SQL in unix so bear with me while I try to explain the situation. I have a text file that has the contents of the where condition that I am using for a db2 SQL in UNIX ksh.
Here is the snippet.

Code:
if [ -s /entH/temp/VALUE$$.out ];
         then
            echo "Begin processing VALUEs"
            db2 connect to testdb2 user username using passwd
            while read line
            do
                echo "Processing VALUE $line"
                snrf=$(echo $line | awk -F "." '{print $1}')
                db2 "select document_name, document_type, timestamp_date, loc_code, box_number_from from edv.evctr1 where transaction_id = ${VALUE}" >> /entH/temp/${VALUE}_control_data.$$
                echo "EOF1" >> /entH/temp/${VALUE}_control_data.$$
                db2 "select comments from edv.evcmt1 where transaction_id = ${VALUE}" >> /entH/temp/${VALUE}_control_data.$$
            done < /entH/temp/VALUE$$.out
fi
When executed I get several output files for each record selected from the two tables. The general content of each of the output files include the following

Code:
document_name  document_type, timestamp_date, loc_code, ...
-------------  -------------  --------------  -------------   ...
col1_value1    col2_value1    col3_value1     col4_value1     ...

   1 record(s) selected.

EOF1

comments
------------------------------------------
comment_value1
comment_value2
comment_value3

   3 record(s) selected.
The question: Is there any flags that can be set while using db2 sql commands from a script to suppress printing of the column names, number of records returned, fix the size of the output records written to the flat files and be able to set inidividual column size of for each column specified in the sql statement?
For instance in oracle you can use something like, set heading off, set feedback off, set linesize 200, COL column_name format format_specifier etc.

If there are flags that can be set, how can I incorporate it in a shell script or is there a ini file that needs to be used?
Any help provided is greatly appreciated. Many thanks.
Jerardfjay
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-02-2005
Registered User
 

Join Date: Feb 2005
Location: Columbus OH
Posts: 132
use -x option

For those of you who are interested.
Use the command line option -x to suppress printing of column headers and feedback from the SQL engine other than the desired data output.

Courtesy of IBM web site. More information can be found here.

DB2 - UDB command line options

Jerardfjay
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0