0

i am looking for a db2 method to import a .csv file (IMPORT.CSV) like this:

2020-01-01;1.234.567,12345

in the a DB2 table MY_TABLE:

CREATE TABLE
    MY_TABLE
    (
        DTRIF DATE,
        SALDO DECIMAL(18,5)
    );

i tried "INGEST" method:

INGEST FROM FILE IMPORT.CSV FORMAT DELIMITED
  (
      $data date,
      $decimale char(18)
   ) 
   INSERT INTO MY_TABLE(dtrif,saldo)
      VALUES( 
        $data, 
        CAST(REPLACE(REPLACE($decimale, '.', ''), ',', '.') AS DECIMAL(18,5))
   );

but the result is:

    DTRIF      SALDO
2020-01-01 12345.00000 

why?

1

1 Answer 1

0

The following works correctly for me (other variations are possible) with Db2-LUW v11.1.4.5:

INGEST FROM FILE ... FORMAT DELIMITED BY ';'
  (
      $data date,
      $decimale char
  )
   INSERT INTO ... (dtrif,saldo)
      VALUES( $data
            , CAST(REPLACE(REPLACE($decimale, '.', ''), ',', '.') AS DECIMAL(18,5)));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.