Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2013
    Location
    India
    Posts
    246

    Unanswered: db2move export - path

    Dear all,

    I am using Db2 9.7 LUW on windows.

    I am calling command

    db2move mydb export

    from inside a batch script but i am not able to give target path (where to store all IXF and MSG files) to this command.

    is there any such option on db2look ?

    regards
    sumit
    ssumit

  2. #2
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    You can create a variable (in your batch file) whose value is the fully qualified path to where you want to store the output files, and then temporarily change to that directory for the duration of the db2move , for example:

    set EXP_OUTPUT_DIR=j:\db2move\output

    pushd .
    chdir /d %EXP_OUTPUT_DIR%
    if errorlevel 1 (@echo Failed to change to output directory && @goto :EOF )
    db2move export ....
    if errorlevel 2 (@echo db2move failed && @goto :EOF )
    popd
    ...
    Last edited by db2mor; 10-15-13 at 07:25.

  3. #3
    Join Date
    Sep 2013
    Location
    India
    Posts
    246

    db2move unable to set path

    Quote Originally Posted by db2mor View Post
    You can create a variable (in your batch file) whose value is the fully qualified path to where you want to store the output files, and then temporarily change to that directory for the duration of the db2move , for example:

    set EXP_OUTPUT_DIR=j:\db2move\output

    pushd .
    chdir /d %EXP_OUTPUT_DIR%
    if errorlevel 1 (@echo Failed to change to output directory && @goto :EOF )
    db2move export ....
    if errorlevel 2 (@echo db2move failed && @goto :EOF )
    popd
    ...

    Dear all

    My windows batch file is as follows:

    db2cmd /c /w /i db2 -v -t -f "D:\db2scripts\export_script.db2" -z "D:\db2scripts\sqlres.txt"

    content of D:\db2scripts\export_script.db2 file is:

    !cd "D:/testistms";
    connect to istms;
    !db2look -d istms -e -l -x -o "D:/testistms/dbcreate.sql";
    !db2move testdb export;


    But still export content is not going to D:/testistms . export files are always created into the directory from where my batch script is launched.

    Please help.

    regards
    sumit
    ssumit

  4. #4
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    Your batch file is not valid as regards the !cd "D:/testistms" ; line - it will not do what you think.

    That's because the change-directory is only valid for the sub-shell created to run that single line only, and when that line completes the current-directory changes back to what it was before the !cd line.

    Your options include
    (a) changing the directory before running export_script.db2 or

    (b) writing an NT-batch-script that runs db2 commands (like db2look, db2move, db2 connect etc) instead of writing a db2-script that runs those db2 commands.

    Option (b) lets you create a more robust script that does error checking and reacts to errors. Your current script has no error checking.

  5. #5
    Join Date
    Sep 2013
    Location
    India
    Posts
    246

    db2move path not set

    Thanks db2mor..


    I am not aware of NT -batch scripts can u provide me a hint/link/example for the same to learn.
    ssumit

  6. #6
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    There are many books and internet pages on this topic (Windows batch files) and this kind of scripting is decades old. Use Google...

    For your simple needs a batch file like this "myexport.bat" will show some examples...

    @if “%DB2CLP%” == “” db2cmd /c /i /w %0 %* & goto :eof

    set targetdir=D:\testistms

    set dbname=istms

    db2 connect to %dbname%
    if errorlevel 1 (@echo Failed to connect to %dbname% && @goto :EOF)

    db2look -d %dbname% -e -l -x -o %targetdir%\dbcreate.sql
    if errorlevel 2 (@echo db2look failed && @goto :EOF )

    cd /d %targetdir%
    if errorlevel 1 (@echo Failed to change to %targetdir% && @goto :EOF)

    db2move istms export
    if errorlevel 1 (@echo db2move failed && @goto :EOF)

    @echo db2move completed successfully

  7. #7
    Join Date
    Sep 2013
    Location
    India
    Posts
    246

    db2move

    Thanks Db2mor... i will do the rest .
    ssumit

Posting Permissions

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