• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 745
  • Last Modified:

Using select statement from input file with DB2 EXPORT

I'm successfully doing an export using the following shell script

#!/bin/ksh

db2 Connect to ALIAS user USERNAME using PASSWORD

db2 "EXPORT TO result.dat OF DEL MODIFIED BY NOCHARDEL COLDEl| select memrecno, memidnum from mpi_memhead fetch first 10 rows only"

db2 terminate

Open in new window


Rather than having my select statement where it is, I'd like to specify a file with the select statement.  My googling isn't helping :-/

Thanks in advance.
0
donnatronious
Asked:
donnatronious
1 Solution
 
Kent OlsenData Warehouse Architect / DBACommented:
Use the shell tools to substitute the file name.

#!/bin/ksh

Export_Database (
  db2 Connect to ALIAS user USERNAME using PASSWORD

  db2 "EXPORT TO $1 OF DEL MODIFIED BY NOCHARDEL COLDEl| select memrecno, memidnum from mpi_memhead fetch first 10 rows only"

  db2 terminate
)                                  

Export_Database SomeFileName.bak

#end

Open in new window



Good Luck!
Kent
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now