DB2 in awk or PARSING VALUE in Shell Script

Guys,

My Motive is, There are some View names in the file with the format of SCHEMA.VIEWNAMe,

I want to read the data from file and parse it to SCHEMA and VIEWNAME and execute DB2 command to get the base Table name.

I can parse easily through AWK but i could not execute db2 commands in between AWK limit.

So need guidance on the below,

  1. Is there any option to execute db2 commands in between awk '{ execute db2_commands }'

  2. Is there any easy way the parse value sCHEMA.VIEWNAME into SCHEMA and VIEWNAME like in UNIX without using AWK.

Regards,
Nantha.Y

You could use awk to produce the SQL statements to query the database and pipe the output to the DB2 CLP, for example

awk -f script.awk inputfile | db2 +p -x

You will have to print the CONNECT TO statement in awk's BEGIN section.

1 Like