Awk appears to disconnect my DB2 session when piping

Posted by greggannicott on Stack Overflow See other posts from Stack Overflow or by greggannicott
Published on 2009-02-04T09:43:21Z Indexed on 2010/04/25 6:03 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

Hello.

I'm attempting to run the following command in Korn Shell (ksh):

set -A INDEXES `db2 "describe indexes for table ${TABSCHEMA}.${TABNAME} show detail" | awk '{print $1"."$2}'`

What I'm attempting to achieve is place a list of the indexes over a particular table into an array which I can later iterate through.

The problem is, when I run the above command the contents of the array starts with the error message of 'SQL1024N' (which is telling me that the database connection does not exist).

However, if I remove the 'awk' at the end of the statement as so:

set -A INDEXES `db2 "describe indexes for table ${TABSCHEMA}.${TABNAME} show detail"`

it works just fine (well, to the extent its returning data. Obviously without the awk I'm not capturing the correct data).

Does anyone know why the awk is having this affect?

I appreciate there is more than one way to get this data, but it baffles me as to why this is happening.

Thanks in advance.

Greg.

© Stack Overflow or respective owner

Related posts about ksh

Related posts about db2