1
votes

I have a CSV file with the following format that I'd like to load to a DB2 database with Liquibase's loadData feature:

2,92551,1,Nature of Service / Procedure,1

(Notice no quotes anywhere)

I'd like Liquibase to treat the 1st, 3rd, & 5th column as INTEGERS and the 2nd & 4th column as STRINGS.

My column definition is as follows:

columns: - column: name: uid type: NUMERIC - column: name: hcpcs_cpt_code type: STRING - column: name: mue_value type: NUMERIC - column: name: mue_edit_rationale type: STRING - column: name: metadata_uid type: NUMERIC

Liquibase us wrapping all of the columns in single quotes and causing the insert to fail:

[INFO] INSERT INTO "XXXXX".MUE_NCCI_EDIT("2", "92551", "1", "Nature of Service / Procedure", "1") VALUES(?, ?, ?, ?, ?)

resulting in

Error: com.ibm.db2.jcc.am.SqlSyntaxErrorException: "2" is not valid in the context where it is used.. SQLCODE=-206, SQLSTATE=42703, DRIVER=4.22.29

Is my CSV just plain stupid or is there a Liquibase config I'm missing?

I've tried various combinations of separator and quotechar combinations with no luck.

1
The attribute is called quotchar (without the 'e').Jens

1 Answers

1
votes

Ok, the answer, for me at least, was to add a header row to the csv file i.e.: uid,hcpcs_cpt_code,mue_value,mue_edit_rationale,metadata_uid 2,92551,1,Nature of Service / Procedure,1

This combined with the header attr. on the column definition resolved the issue: columns: - column: name: uid type: NUMERIC header: uid - column: name: hcpcs_cpt_code type: STRING header: hcpcs_cpt_code - column: name: mue_value type: NUMERIC header: mue_value - column: name: mue_edit_rationale type: STRING header: mue_edit_rationale - column: name: metadata_uid type: NUMERIC header: metadata_uid

I think the error messages/documentation could have been clearer here. I only resolved through a process of trial and error.