0

I have the following situation,

in my database table I have a column for storing xml data. When I try to insert data into this table by using Insert query, I am getting string is too large exception.

I tried keeping the type as XML and VACHAR(32000), I get the same exception.

Can anyone help me with this?

UPDATE

This is the error I am getting while inserting.

The string constant beginning with "'<!--Sample XML file generated by XMLSpy v2013 sp1 (http://www.altova." is too long.. SQLCODE=-102, SQLSTATE=54002, DRIVER=3.59.81
6
  • The limit should be 2gb. Are you inserting directly into the database or are you using some kind of application? The application might be truncating it. Commented Apr 29, 2013 at 14:46
  • Im trying to insert it directly using query. Commented Apr 29, 2013 at 14:49
  • Is this DB2 for i, LUW, or z/OS? Commented Apr 29, 2013 at 20:09
  • Im using DB2 Control center on Windows. Commented Apr 30, 2013 at 7:48
  • What is the SQL code? Commented Apr 30, 2013 at 8:06

3 Answers 3

1

The XMLPARSE function is useful for converting text strings into DB2's XML data type. Have you tried wrapping your XML text with a call to XMLPARSE?

If your XML document is in a file, there's a UDF you can add that makes it easier to pull the file contents directly into an XML column.

Sign up to request clarification or add additional context in comments.

Comments

0

you can set the size of each column in your table. Try changing the default size(which is not max size) to an appropriate one.

  • Also when you try to query directly using SQL command line, the DBMS has to create a large string constant form its string pool that can hold your XML(which in this case, is very large and hence String cannot be created). If you query the same programmatically though, it works.
  • If the same error persists or if DBMS throws Data Integrity error, then try changing the data structure to a bigger one like CLOB(most likely in this case) or BLOB(in case of images and multi media).

Comments

0

It's a bit silly but the answer is use the XMLPARSE and segment your XML string in 32K chunks and prepend a CLOB statement to override the string size limitation

XMLPARSE ( DOCUMENT 
CLOB('<?xml version="1.0"?>') ||
'<aLotOfVeryBigXmlData32kPart1 ......
' ||
'<aLotOfVeryBigXmlData32kPart2 ......
' ||
... etc ...
'<aLotOfVeryBigXmlData32kPartN ......
' ) 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.