If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > export/import script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-07, 19:34
usc usc is offline
Registered User
 
Join Date: Apr 2007
Posts: 21
export/import script

how to export/import through script.

Can anyone provide a sample script.
Reply With Quote
  #2 (permalink)  
Old 04-14-07, 09:04
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Scripting is pretty much identical to do things on the shell prompt:
Code:
#!/bin/sh

db2 "export ..."
db2 "import ..."
Of course, the question is which platform you are using because Windows requires a few more preparations.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 04-15-07, 10:52
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Quote:
Originally Posted by stolze
Windows requires a few more preparations.
Not entirely true! On Windows there can also be only ONE! file to execute SQLs from. Please see the script sections of this forum, where I have published solution. Look for topic Execute SQLs from files only with one batch file - DB2 on Windows
Reply With Quote
  #4 (permalink)  
Old 04-21-07, 04:56
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
My point was that you need to start a db2cmd prompt on Windows. On Unix, all you have to do is to source the db2profile (which is usually done via .profile upon login automatically).
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 04-23-07, 12:19
usc usc is offline
Registered User
 
Join Date: Apr 2007
Posts: 21
db2 on AIX.
Reply With Quote
  #6 (permalink)  
Old 04-24-07, 01:40
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Quote:
Originally Posted by stolze
My point was that you need to start a db2cmd prompt on Windows. On Unix, all you have to do is to source the db2profile (which is usually done via .profile upon login automatically).
I agree with you. On Windows there is little more tweaky, but my script can reduce complexity.

By the way, this difference between Linux/Unix and Windows script execution I little bit hate, because I can't use only one solution to have both systems up and running by scripts. Why doesn't IBM eliminate the need of this db2cmd starting for each script on Windows? Why is there not the same solution like on Linux/Unix?
Reply With Quote
  #7 (permalink)  
Old 04-24-07, 01:46
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Quote:
Originally Posted by usc
db2 on AIX.
use Stolce suggestion.

BTW, I use if logic in script to control if command executed successfully (Unix script):
Code:
db2 connect to sample
if [[ ($? -eq 0 )  || ($? -eq 1) ]]; then
     Echo "Connection to database not possible."
else echo "Connection to database completed successfuly";fi
Note: each DB2 command after execution returns status to system variable "$?". If variable is 0 there it is OK. If variable is 1 there is warning. Any other value there is error.

Hope this helps,
Grofaty

Last edited by grofaty; 04-24-07 at 01:49.
Reply With Quote
  #8 (permalink)  
Old 04-24-07, 02:29
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by grofaty
Why doesn't IBM eliminate the need of this db2cmd starting for each script on Windows?
Actually, it's not as bad as it seems: it suffices to set the environment variable DB2CLP to the same value as that from a running db2cmd window. From then on, you can do exactly the same as on unix (e.g., using a Cygwin bash window).
I guess this could be automated (i.e., scripted) in one way or the other, say by issuing db2cmd in the background and capturing the DB2CLP setting, but I did not yet bother to do so.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On