SQL Error IBM DB2 with MERGE INTO and Prepared Statements

41 Views Asked by At

I changed an SQL today from very unsafe way into prepared statements. So the two variable values were replaced by "?". But finally I get this error message:

**[IBM][CLI Driver][AS] SQL0584N The statement failed because of an invalid use of the NULL keyword or the DEFAULT keyword. SQLSTATE=42608 **

the SQL:

MERGE INTO MYTABLE A 
USING (VALUES (?, ?)) 
AS B(OID,NOTIZ)
ON (A.OID = B.OID)
WHEN MATCHED THEN 
UPDATE SET NOTIZ = B.NOTIZ 
WHEN NOT MATCHED THEN 
INSERT (OID,NOTIZ) VALUES (B.OID,B.NOTIZ);

this happens independet of the values and the type of values. For example I use 123 and "hello" or anything else. At the columns NULL is not allowed but I dont try to fill NULLs here. This kind of changes work at 99,9% of my SQLs, just at MERGE INTO this problem occur. It's independet of the client or programming language. It happens as well in DB VIsualizer or by JAVA.

Who has an idea?

enter image description here

enter image description here

enter image description here

0

There are 0 best solutions below