Invoke LOAD command?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DB_2

    Invoke LOAD command?

    Hello,

    I was trying to load a comma-separated text file to a DB2 table. I
    believe I have the syntax rigt for the LOAD command.

    My first question is, how do you actually run it? It is not a SQL
    command; so it doesn't run from the command center/SQL window. It
    looks like a utility tool but I didn't find a load.exe or db2load.exe
    file in the installation directory.

    Then I tried to run "db2 load ..." at the Windows command prompt.
    This gave me the error message saying that DB21061E Command line
    environment was not initialized. Searching for this error, I found
    that the solution was something like "db2cmd /w /c db2 load ..." which
    doesn't seem natural. But it seems like I need to do this each time,
    and then it only allows for a single line.

    How do experienced users usually run the LOAD command? Do they create
    a script file where they put their user id/passwords? Is there
    another way? Is this platform dependent?
  • Knut Stolze

    #2
    Re: Invoke LOAD command?

    DB_2 wrote:
    [color=blue]
    > Hello,
    >
    > I was trying to load a comma-separated text file to a DB2 table. I
    > believe I have the syntax rigt for the LOAD command.
    >
    > My first question is, how do you actually run it? It is not a SQL
    > command; so it doesn't run from the command center/SQL window. It
    > looks like a utility tool but I didn't find a load.exe or db2load.exe
    > file in the installation directory.
    >
    > Then I tried to run "db2 load ..." at the Windows command prompt.
    > This gave me the error message saying that DB21061E Command line
    > environment was not initialized. Searching for this error, I found
    > that the solution was something like "db2cmd /w /c db2 load ..." which
    > doesn't seem natural. But it seems like I need to do this each time,
    > and then it only allows for a single line.[/color]

    In Windows, have a look at Start->Programs->IBM DB2->Command Line
    Tools->Command Window. This will open an already initialized DB2
    environment, and you can run all DB2 commands there. So all that is left
    to do would be:

    db2 load ...

    --
    Knut Stolze
    Information Integration
    IBM Germany / University of Jena

    Comment

    • Ian

      #3
      Re: Invoke LOAD command?

      DB_2 wrote:[color=blue]
      > Hello,
      >
      > I was trying to load a comma-separated text file to a DB2 table. I
      > believe I have the syntax rigt for the LOAD command.
      >
      > My first question is, how do you actually run it? It is not a SQL
      > command; so it doesn't run from the command center/SQL window. It
      > looks like a utility tool but I didn't find a load.exe or db2load.exe
      > file in the installation directory.[/color]

      Command Center supports both SQL and DB2 Commands (LOAD, REORG,
      RUNSTATS, etc)...

      What error did you get when trying to issue a LOAD command from
      within Command Center?





      -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
      http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
      -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

      Comment

      • DB_2

        #4
        Re: Invoke LOAD command?

        Knut Stolze <stolze@de.ibm. com> wrote in message news:<ccdh41$b8 k$1@fsuj29.rz.u ni-jena.de>...[color=blue]
        > DB_2 wrote:[color=green]
        > > Then I tried to run "db2 load ..." at the Windows command prompt.
        > > This gave me the error message saying that DB21061E Command line
        > > environment was not initialized. Searching for this error, I found
        > > that the solution was something like "db2cmd /w /c db2 load ..." which
        > > doesn't seem natural. But it seems like I need to do this each time,
        > > and then it only allows for a single line.[/color]
        >
        > In Windows, have a look at Start->Programs->IBM DB2->Command Line
        > Tools->Command Window. This will open an already initialized DB2
        > environment, and you can run all DB2 commands there. So all that is left
        > to do would be:
        >
        > db2 load ...[/color]

        Thanks for the tip. I am more interested in automating this a bit.
        For example, I would like to run it via a script or a system/API call.
        Is there a way?

        Comment

        • Blair Adamache

          #5
          Re: Invoke LOAD command?

          Search on LOAD API at this site:


          DB_2 wrote:
          [color=blue]
          > Knut Stolze <stolze@de.ibm. com> wrote in message news:<ccdh41$b8 k$1@fsuj29.rz.u ni-jena.de>...
          >[color=green]
          >>DB_2 wrote:
          >>[color=darkred]
          >>>Then I tried to run "db2 load ..." at the Windows command prompt.
          >>>This gave me the error message saying that DB21061E Command line
          >>>environmen t was not initialized. Searching for this error, I found
          >>>that the solution was something like "db2cmd /w /c db2 load ..." which
          >>>doesn't seem natural. But it seems like I need to do this each time,
          >>>and then it only allows for a single line.[/color]
          >>
          >>In Windows, have a look at Start->Programs->IBM DB2->Command Line
          >>Tools->Command Window. This will open an already initialized DB2
          >>environment , and you can run all DB2 commands there. So all that is left
          >>to do would be:
          >>
          >>db2 load ...[/color]
          >
          >
          > Thanks for the tip. I am more interested in automating this a bit.
          > For example, I would like to run it via a script or a system/API call.
          > Is there a way?[/color]

          Comment

          • Buck Nuggets

            #6
            Re: Invoke LOAD command?

            deebeetwo@yahoo .com (DB_2) wrote in message news:<9b5110a1. 0407052156.758d 8c9a@posting.go ogle.com>...
            [color=blue]
            > How do experienced users usually run the LOAD command? Do they create
            > a script file where they put their user id/passwords? Is there
            > another way? Is this platform dependent?[/color]

            I only run it from within scripts: either shell scripts, or
            python/tcl/etc that run it as a shell would. Works best that way IMHO
            - easy to automate, audit, etc. I can't stand running utilities like
            this from a GUI - too difficult to test, to correct errors, reuse
            code, keep code as reference, etc.

            Normally these export, loads, etc run on the same server and rely on
            the os to authenticate their userid. Depending on how you've got
            security set up, you could also keep a userid/password in there (or in
            a separate config file) and then just carefully manage the file access
            permissions...

            I haven't spent much time with db2 on windows, but I believe you just
            need to invoke a separate command shell (db2cmd?) and it should
            otherwise work the same.

            Comment

            • DB_2

              #7
              Re: Invoke LOAD command?

              bucknuggets@yah oo.com (Buck Nuggets) wrote in message news:<66a61715. 0407061138.4d69 a886@posting.go ogle.com>...[color=blue]
              > deebeetwo@yahoo .com (DB_2) wrote in message news:<9b5110a1. 0407052156.758d 8c9a@posting.go ogle.com>...
              > I only run it from within scripts: either shell scripts, or
              > python/tcl/etc that run it as a shell would. Works best that way IMHO
              > - easy to automate, audit, etc. I can't stand running utilities like
              > this from a GUI - too difficult to test, to correct errors, reuse
              > code, keep code as reference, etc.
              >
              > Normally these export, loads, etc run on the same server and rely on
              > the os to authenticate their userid. Depending on how you've got
              > security set up, you could also keep a userid/password in there (or in
              > a separate config file) and then just carefully manage the file access
              > permissions...[/color]

              Hello,

              I am very interested in your approach of using scripts to automate the
              data loads. Do you have any scripts with specifically DB2 LOAD command
              that you can share? I am especially interested in cases where you
              provide authentication in a script file (whether it is a shell script
              or python/tcl/etc.). You can email me directly.

              TIA!

              Comment

              • Knut Stolze

                #8
                Re: Invoke LOAD command?

                DB_2 wrote:
                [color=blue]
                > Knut Stolze <stolze@de.ibm. com> wrote in message
                > news:<ccdh41$b8 k$1@fsuj29.rz.u ni-jena.de>...[color=green]
                >> DB_2 wrote:[color=darkred]
                >> > Then I tried to run "db2 load ..." at the Windows command prompt.
                >> > This gave me the error message saying that DB21061E Command line
                >> > environment was not initialized. Searching for this error, I found
                >> > that the solution was something like "db2cmd /w /c db2 load ..." which
                >> > doesn't seem natural. But it seems like I need to do this each time,
                >> > and then it only allows for a single line.[/color]
                >>
                >> In Windows, have a look at Start->Programs->IBM DB2->Command Line
                >> Tools->Command Window. This will open an already initialized DB2
                >> environment, and you can run all DB2 commands there. So all that is left
                >> to do would be:
                >>
                >> db2 load ...[/color]
                >
                > Thanks for the tip. I am more interested in automating this a bit.
                > For example, I would like to run it via a script or a system/API call.
                > Is there a way?[/color]

                You can always put this in a shell script (Unix) or batch file (Windows).
                On Windows, you can use the "db2cmd /w /c db2 ..." syntax you've shown
                above.

                As for the API, look at the DB2 reference where you will find all the
                details that you need to know about the data structures and usage.

                --
                Knut Stolze
                Information Integration
                IBM Germany / University of Jena

                Comment

                Working...