简体   繁体   中英

Db2 sqlcode -20186

I am trying to run a simple insert statement in db2 but getting invalid statement:

my sql :

insert into schema1.table1 select * from schema2.table1

Error:

SQLCODE = -20186, ERROR: A CLAUSE SPECIFIED FOR THE DYNAMIC SQL; STATEMENT BEING PROCESSED IS NOT VALID

I had gone through ibm knowledge center and found this page .

I understand db2 allows 3 forms of insert: There are three forms of this statement:

  1. The INSERT via VALUES form is used to insert a single row into the table or view using the values provided or referenced.

  2. The INSERT via SELECT form is used to insert one or more rows into the table or view using values from other tables, or views, or both.

  3. The INSERT via FOR n ROWS form is used to insert multiple rows into the table or view using values provided or referenced.

My question is why db2 is looking for "for n rows" clause in my query.

Note: this query is being sent through SSGODBC.

可能想尝试并明确声明列。

INSERT INTO Schema1.table1 (col1,col2,...) SELECT col1,col2,... FROM Schema2.table2 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM