admin管理员组文章数量:1394138
I am using Python with the ibm_db library (version 3.2.6) to load data from a CSV file into a DB2 table. The following query is used for the data insertion process:
INSERT INTO DWHD1.USERS
SELECT * FROM external 'USERS.csv'
USING (
CCSID 923
DELIMITER '~'
MAXERRORS 1
CTRLCHARS 'ON'
FILLRECORD 'TRUE'
REMOTESOURCE 'JDBC'
TIMESTAMP_FORMAT 'YYYY-MM-DD HH24:MI:SS'
ESCAPECHAR '\'
NULLVALUE ''
LOGDIR '/tmp'
SKIPROWS 1
TRIMBLANKS 'BOTH'
)
However, when executing this query using ibm_db, I encounter the following error:
ibm_db_dbi.ProgrammingError: ibm_db_dbi::ProgrammingError: Statement Execute Failed:
[IBM][CLI Driver][DB2/LINUXX8664] SQL0104N An unexpected token "TRIMBLANKS" was found following "SKIPROWS 1".
Expected tokens may include: "TRIM_NULLS".
SQLSTATE=42601 SQLCODE=-104
I have already reviewed the official IBM documentation on external table creation IBM DB2 Documentation, and according to it, TRIMBLANKS is a valid argument. However, the error persists.
Additional Details:
- I am using the icr.io/db2_community/db2 Docker image.
- I have tried modifying the query in various ways, but the error continues to occur.
- db2level output:
DB21085I This instance or install (instance name, where applicable:
"db2inst1") uses "64" bits and DB2 code release "SQL12011" with level
identifier "02020110".
Informational tokens are "DB2 v12.1.1.0", "s2412161033", "DYN2412161033AMD64",
and Fix Pack "0".
Product is installed at "/opt/ibm/db2/V12.1".
Could someone help me understand why this error occurs and how to resolve the issue? Specifically, is there an issue with the use of TRIMBLANKS, or might the problem be related to the DB2 version or the Docker image?
Thank you in advance for your help!
I am using Python with the ibm_db library (version 3.2.6) to load data from a CSV file into a DB2 table. The following query is used for the data insertion process:
INSERT INTO DWHD1.USERS
SELECT * FROM external 'USERS.csv'
USING (
CCSID 923
DELIMITER '~'
MAXERRORS 1
CTRLCHARS 'ON'
FILLRECORD 'TRUE'
REMOTESOURCE 'JDBC'
TIMESTAMP_FORMAT 'YYYY-MM-DD HH24:MI:SS'
ESCAPECHAR '\'
NULLVALUE ''
LOGDIR '/tmp'
SKIPROWS 1
TRIMBLANKS 'BOTH'
)
However, when executing this query using ibm_db, I encounter the following error:
ibm_db_dbi.ProgrammingError: ibm_db_dbi::ProgrammingError: Statement Execute Failed:
[IBM][CLI Driver][DB2/LINUXX8664] SQL0104N An unexpected token "TRIMBLANKS" was found following "SKIPROWS 1".
Expected tokens may include: "TRIM_NULLS".
SQLSTATE=42601 SQLCODE=-104
I have already reviewed the official IBM documentation on external table creation IBM DB2 Documentation, and according to it, TRIMBLANKS is a valid argument. However, the error persists.
Additional Details:
- I am using the icr.io/db2_community/db2 Docker image.
- I have tried modifying the query in various ways, but the error continues to occur.
- db2level output:
DB21085I This instance or install (instance name, where applicable:
"db2inst1") uses "64" bits and DB2 code release "SQL12011" with level
identifier "02020110".
Informational tokens are "DB2 v12.1.1.0", "s2412161033", "DYN2412161033AMD64",
and Fix Pack "0".
Product is installed at "/opt/ibm/db2/V12.1".
Could someone help me understand why this error occurs and how to resolve the issue? Specifically, is there an issue with the use of TRIMBLANKS, or might the problem be related to the DB2 version or the Docker image?
Thank you in advance for your help!
Share Improve this question edited Mar 13 at 10:54 Ryuuk asked Mar 12 at 15:35 RyuukRyuuk 1011 gold badge3 silver badges14 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 0Don't put `BOTH` in quotes in your TRIMBLANKS option.
Good:
TRIMBLANKS BOTH
Bad:
TRIMBLANKS 'BOTH'
The same goes for the CTRLCHARS, FILERECORD, REMOTESOURCE options as well.
本文标签: sqlError with TRIMBLANKS argument when loading CSV data into DB2 using ibmdb in PythonStack Overflow
版权声明:本文标题:sql - Error with TRIMBLANKS argument when loading CSV data into DB2 using ibm_db in Python - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744743982a2622778.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
db2level
command (which is in ~/sqllib/bin directory of the instance-owner home directory). ALSO, if your target table uses VARCHAR (not CHAR(...)) then you may not need TRIMBLANKS . – mao Commented Mar 13 at 10:37