MERGE statement using PreparedStatement in JAVA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eonblue20
    New Member
    • May 2007
    • 1

    MERGE statement using PreparedStatement in JAVA

    Hello

    I\\\'m new to DB2 and I\\\'ve been trying to create the MERGE statement using PreparedStateme nts in Java as a requirement for a project I\\\'m working on, but I get the following message:

    DB2 SQL error: SQLCODE: -418, SQLSTATE: 42610, SQLERRMC: null

    The statements I am creating are very long but here is a short example of the the statements I am using:

    MERGE INTO schema.tableNam e USING
    ( VALUES ( ?, ?, ?, ?)) as lb ON (primaryKeyFiel d = ?)
    WHEN MATCHED THEN UPDATE
    SET field2 = ?, field3 = ?, field4 = ?
    WHEN NOT MATCHED THEN
    INSERT(primaryK eyField, field2, field3, field4)
    VALUES(?,?,?,?)

    I\\\'ve already tested that each value is assigned to the corresponding parameter.
    Do I have to use the CAST operator on every value in the SET clause? What exactly is causing the error?

    Thanks in advance. Have a good day

    Robert
Working...