Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2012
    Posts
    3

    Unanswered: Loading data from text file to DB2 Table

    Hello

    I am new to DB2 I am trying to load data from a text file to a DB2 table.
    My text file has comment lines.Sample text file is
    ---------------------------------------------------------
    ################################################## ###############################
    # Application properties
    ################################################## ###############################
    PROP_FILE_PATH=file:///appl/wa/
    PRINCIPAL=
    CREDENTIAL=
    ACC=
    SECURITY_PRINCIPAL=uid=fmtadmin,o=sample
    ################################################## ##############################

    ################################################## ###############################
    #Environment Properties
    ################################################## ###############################

    ---------------------------------------------------------------------------------
    I want to skip the lines starting with '#' and the delimiter is the first '='
    For example:
    I want to insert above data into a table with two fields key and value
    key value
    PROP_FILE_PATH file:///appl/wa/
    SECURITY_PRINCIPAL uid=fmtadmin,o=sample

    Could anyone Please help me

    I tried this

    LOAD FROM 'config.txt' of del insert into db2devdb.abc when (1)!='#'(key CHAR TERMINATED BY '=',value CHAR TERMINATED BY WHITESPACE)

    Thanks

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by newbiee View Post

    I tried this

    LOAD FROM 'config.txt' of del insert into db2devdb.abc when (1)!='#'(key CHAR TERMINATED BY '=',value CHAR TERMINATED BY WHITESPACE)
    Well, may be you should try something that has valid syntax. LOAD command

    I would use something like perl or awk to preprocess the input file -- the LOAD utility has very limited parsing capabilities.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    I would indeed go for a perl script to convert your config.txt into INSERT statements.
    That should be relatively straightforward for someone with basic perl skills.

    If you give more details on the precise structure of your config.txt, and of the table into which you want the data to be placed, I could try to write such a little perl program...
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  4. #4
    Join Date
    Sep 2012
    Posts
    3
    The sample text in my config.txt is :
    ################################################## ###############################
    # Application properties
    ################################################## ###############################
    PROP_FILE_PATH=file:///appl/wa/
    PRINCIPAL=
    CREDENTIAL=
    ACC=
    SECURITY_PRINCIPAL=uid=fmtadmin,o=sample
    ################################################## ##############################

    ################################################## ###############################
    #Environment Properties
    ################################################## ###############################

    I am trying to insert into a table sample with two fields key and value.
    I am able to use the unix commands to do the parsing as required but could you please let me know the problem with the following command:

    load from config.txt of del modified by coldel# insert into sample

  5. #5
    Join Date
    Sep 2012
    Posts
    3
    Thank you all my issue is reolved .

  6. #6
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    Might be nice if you posted the resolution.

Posting Permissions

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