flags to suppress column output, # of rows selected in db2 sql in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting flags to suppress column output, # of rows selected in db2 sql in UNIX
# 1  
Old 10-27-2005
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 Smilie Smilie
# 2  
Old 11-02-2005
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 Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

DB2 Query -Convert multi values from column to rows

Hi Team I am using DB2 artisan tool and struck to handle multi values present in columns that are comma(,) separated. I want to convert those column values in separate rows . For example : Column 1 Column2 Jan,Feb Hold,Sell,Buy Expected Result Column1 ... (3 Replies)
Discussion started by: Perlbaby
3 Replies

2. Shell Programming and Scripting

Combine multiple rows based on selected column keys

Hello I want to collapse a file with multiple rows into consolidated lines of entries based on selected columns as the 'key'. Example: 1 2 3 Abc def ghi 1 2 3 jkl mno p qrts 6 9 0 mno def Abc 7 8 4 Abc mno mno abc 7 8 9 mno mno abc 7 8 9 mno j k So if columns 1, 2 and 3 are... (6 Replies)
Discussion started by: linuxlearner123
6 Replies

3. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

4. Shell Programming and Scripting

Capture rows for a column in file from delete sql -Oracle

Hi, This may not be the right forum but i am hoping someone knows an answer to this. I have to capture rows for a column that was deleted. How can i do that without having to write a select query? delete from myschema.mytable where currentdatetimestamp > columnDate this should delete 5... (4 Replies)
Discussion started by: jakSun8
4 Replies

5. Shell Programming and Scripting

awk command to print only selected rows in a particular column specified by column name

Dear All, I have a data file input.csv like below. (Only five column shown here for example.) Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 3,2,4,5,6 5,3,5,5,6 From this I want the below output Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 where the second column... (4 Replies)
Discussion started by: ks_reddy
4 Replies

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

7. Shell Programming and Scripting

sql output from multiple rows and columns as variables in a script

This is for an Oracle journal import. I was using a pl/sql package and oracle API's. Oracle added invoker rights to their API's and now my package won't run. I didn't want to use their API's anyway. The only reason i was using pl/sql and the API's (just a package) was to utilize a cursor. How... (2 Replies)
Discussion started by: lmu
2 Replies

8. UNIX for Dummies Questions & Answers

how to capture no. of rows updated in update sql in unix db2

hi, i am a new user in unix..and we have unix db2. i want to capture the no. of rows updated by a update db2 sql statement and redirect into a log file. I've seen db2 -m...but not sure how the syntax should be. The update sql that I'm going to run is from a file... Can you please share... (1 Reply)
Discussion started by: j_rymbei
1 Replies

9. Shell Programming and Scripting

running db2 sql and exporting output from ksh scipt

Hi there, I am trying to write a shell script as root on AIX 5.3 where I change user to db2inst1, connect to our db2 database, run a sql select query and export the result of the query to a file. The code I have so far is as follows:- #!/usr/bin/ksh su - db2inst1 -c "db2 connect to... (0 Replies)
Discussion started by: candlino
0 Replies

10. Shell Programming and Scripting

Run SQL queries in DB2 and output to file

Hi, I new to Unix and scripting. Following is my requirement. Can someone tell me whether its possible or not. Also please let me know how to proceed further if this is possible. List of queries are stored in a file. For example, I have to run a query like this: Select * from &XYZ where... (0 Replies)
Discussion started by: simhasuri
0 Replies
Login or Register to Ask a Question