Solved

Using select statement from input file with DB2 EXPORT

Posted on 2015-01-08
1
513 Views
Last Modified: 2015-01-23
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
Comment
Question by:donnatronious
1 Comment
 
LVL 45

Accepted Solution

by:
Kdo earned 500 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now