Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2003
    Posts
    47

    Unanswered: DB2 Import syntax

    Hi All,

    I have a table called test with columns col1,col2 and col3

    I get col3 from a file.
    while loading the data I want to pass some values to col2 and col3

    How can I do that?


    IMPORT FROM FILENAME OF ASC METHOD L (2 9) commitcount 1000 messages $LOGSDIR/$LOGNAME INSERT_UPDATE INTO test (col3)
    How can I pass col2 and col3 to import command?


    Thanks
    Shri
    p.srinivasarao

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    I don't know exactly what you want to do. You can load/import two columns with "INTO test(col2, col3)". But I guess you want something different?

    Could you describe what exactly you mean with "pass some values to col2 and col3"?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Jan 2003
    Posts
    47
    Table Name: Test
    col1 varchar(10)
    col2 varchar(10)
    col3 varchar(10)
    col4 varchar(10)


    I have a flat file having the content for col3 and col4.
    "abc","def"
    "123","ddd"

    I want to pass some values to col1 and col2. So I defined two variables
    in shell script like below

    col1=100
    col2=1000


    Now I am loading the flat file using the following command
    IMPORT FROM FILENAME OF ASC METHOD L (1 10,11 20) commitcount 1000 messages $LOGSDIR/$LOGNAME INSERT_UPDATE INTO test (col3,col4)

    Now the table contains data like this

    col1 col2 col3 col4
    abc def
    123 ddd


    During the load itself, I would like pass default values to col1 and col2, Is there any way I can acheive?


    Thanks
    Shri
    p.srinivasarao

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    1. Alter the definition of the columns in question to provide default values
    2. Modify the input file
    3. Run an UPDATE statement after the load
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    Or if you do not want to change the table structure. simply run your import on those two columns. Then run an update on the other two inserting default.
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  6. #6
    Join Date
    Jul 2008
    Posts
    1

    is there any way without altering the table/file structure

    Is there any way to insert defaults into col1, col2 without altering the table/file structure?

Posting Permissions

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