Search code examples
sqlbatch-filedb2db2-luw

Batch: trimming an output of a sql file processed in batch


Batch:

db2 -stwl%LOG% -f %SQL_DIR%\test.sql > %DATA_ROOT%\%NAME%.txt

SQL: pretty long so i won't post it here, its a huge select query that gives this output:

1                                                                                                                                                                                                                             

-----------------------------------------------------------------------------

A testline for example  <--these are the only lines i want to output            
and another one      <-- these are the only lines i want to output                                                           



  2 Satz/Sätze ausgewählt.

Is there a way to minimize the output into the txt file to just the 2 lines i marked above? (without using some extra perl/other external code)

maybe something like another character in the db2 call to just print the 2 rows


Solution

  • You might want to take a look at db2batch and its output options.

    • Performance option should be 0 (zero)
    • Query option should be on

    Take a look at the db2batch manual for details.