Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

closed as off topic by mdpc, Ward, Khaled, John Gardeniers, faker Dec 31 '12 at 10:09

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
might get better reception on the DBA SE. –  mdpc Dec 31 '12 at 4:00

1 Answer 1

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.