Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2007
    Posts
    21

    Unanswered: export/import script

    how to export/import through script.

    Can anyone provide a sample script.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  3. #3
    Join Date
    Jan 2003
    Posts
    1,605
    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

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  5. #5
    Join Date
    Apr 2007
    Posts
    21
    db2 on AIX.

  6. #6
    Join Date
    Jan 2003
    Posts
    1,605
    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?

  7. #7
    Join Date
    Jan 2003
    Posts
    1,605
    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 02:49.

  8. #8
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    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/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •