Solved

Using select statement from input file with DB2 EXPORT

Posted on 2015-01-08
1
588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 40540141
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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 …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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