1

I have created a CLOB(50000) field in a DB2 table, and verified it has correctly created with

DB2 DESCRIBE TABLE dbname

...however I received the following error message even when only attempting to insert a 40,000 character string into the field:

 [IBM][CLI Driver][DB2/LINUXX8664] SQL0102N  The string constant beginning with
 "'''Testing Long Notes! Testing Long Notes! Testing Long Notes! Testing" is too long.  
 SQLSTATE=54002 SQLCODE=-102

'Testing Long Notes!' is just the string I repeated over and over in the HTML field in order to build the 40,000 string length. PHP script then processes the posted HTML form and attempts the SQL INSERT which is resulting in the error.

What am I missing here? Is there some other place a maximum field size is set that overrides the CLOB(50000) setting? Perhaps a configuration item to control field sizes?

I am relatively new to DB2 after a client required conversion from MySQL.

dabayl
  • 302
  • 5
  • 12

1 Answers1

4

You need to use prepared statements instead of concatenating the values into the query yourself. This also applies to MySQL as a good practice -- prepared statements protect you against SQL injection.

DB2 will refuse to handle a raw query longer than 32,000 characters.

Leo
  • 983
  • 7
  • 21
  • 39