ODBC SQL update Statement issue if more than 32,00

2019-09-17 02:31发布

问题:

Here is the problem: I have one giant string of xml data stored in a (BLOB)field in a table. It holds some strings 70k characters or more at times. I pull it out using an ODBC_Connection.

I can import (no problem).
I can manipulate the XML and save it back as a string (no problem).
I can save the string back into a mySQL field (no problem).

The problem comes when i try to save it back to its original field that i pulled it from. If I save the string with less than 32,000 characters, we are golden. If there are more than that many characters in the string, BAM. I get this error message.

( ! ) Warning: odbc_exec() [function.odbc-exec]: SQL error: [DataDirect][ODBC InterBase
driver][InterBase]Dynamic SQL Error, SQL error code = -104, token size exceeds limit,
SQL state 37000 in SQLExecDirect in ...\Test\index4.php on line 129 Call Stack

#   Time    Memory  Function    Location
1   0.0011  482872  {main}( )   ..\index4.php:0
2   0.1260  1033760 odbc_exec ( )   ..\index4.php:129

Here is the PHP code i am using just in case:

// Now save it back to the system
$conn=odbc_connect($DBNAME_O,$DBUSER_O,$DBPW_O);
if (!$conn)
{exit("Connection Failed: " . $conn);}
echo $tempFileXML;
$sql="UPDATE EHR_VISITS SET RECORD='$tempFileXML' WHERE EHR_VISITS_ID='1396'";
//  echo $theData;
$rs=odbc_exec($conn,$sql);
odbc_close($conn);  

Thanks for the help...

UPDATE: This is connected to an interbase database, not MS SQL. Also, I tried using a different ODBC driver, and got the same message but with a slightly higher character tolerance: 42000 instead of 37000.

HELP please....

回答1:

Have you tried passing the data in as a parameter ?

E.g:

$sql = UPDATE EHR_VISITS SET RECORD=? WHERE EHR_VISITS_ID='1396'; 
$stmt = odbc_prepare($conn, $sql); 
$rs = odbc_execute($stmt, $tempFileXML);