I am attempting to use the following code to generate an INSERT statement:

odbc_exec($this -> conn -> db, $this -> query) or die ($query_name . " has failed.");

where $this -> query is the following:

"cashman_transaction_insert 1,"4/14/2004 10:16:45 PM",67,N,"VX1234567890",N,0.00,0.00,0.00,1,"a:38:{s:6:'0000_1';s:3:'4x6';s:6:'0000_2';s:3:'4x6';s:6:'0000_3';s:3:'4x6';s:6:'0000_4';s:3:'4x6';s:6:'0000_5';s:3:'4x6';s:6:'0000_6';s:3:'4x6';s:6:'0000_7';s:3:'4x6';s:6:'0000_8';s:3:'4x6';s:6:'0000_9';s:3:'4x6';s:7:'0000_10';s:3:'4x6';s:7:'0000_11';s:3:'4x6';s:7:'0000_12';s:4:'8x10';s:7:'0000_13';s:3:'4x6';s:7:'0000_14';s:3:'4x6';s:7:'0000_15';s:3:'4x6';s:7:'0000_16';s:3:'4x6';s:7:'0000_20';s:3:'4x6';s:7:'0000_21';s:3:'4x6';s:7:'0000_25';s:3:'4x6';s:7:'0000_26';s:3:'4x6';s:7:'0000_29';s:4:'8x10';s:7:'0000_30';s:3:'4x6';s:7:'0000_31';s:3:'4x6';s:7:'0000_35';s:3:'4x6';s:7:'0000_36';s:3:'4x6';s:7:'0000_40';s:3:'4x6';s:7:'0000_41';s:3:'4x6';s:7:'0000_45';s:3:'4x6';s:7:'0000_46';s:3:'4x6';s:7:'0000_50';s:3:'4x6';s:7:'0000_51';s:3:'4x6';s:7:'0000_55';s:3:'4x6';s:7:'0000_56';s:3:'4x6';s:7:'0000_60';s:3:'4x6';s:7:'0000_61';s:3:'4x6';s:7:'0000_65';s:3:'4x6';s:7:'0000_66';s:3:'4x6';s:7:'0000_67';s:3:'4x6';}"

This is a call to a stored proc. As you can see, the last item is a serialized array with a lot of values. The corresponding field in the table I am attempting to insert into is a TEXT field in MS SQL 2000.

When I run the code I get the following error:

Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The identifier that starts with 'a:38:{s:6:'0000_1';s:3:'4x6';s:6:'0000_2';s:3:'4x6';s:6:'0000_3';s:3:'4x6';s:6:'0000_4';s:3:'4x6';s:6:'0000_5';s:3:'4x6';s:6:'00' is too long. Maximum length is 128., SQL state 37000 in SQLExecDirect...

I really do need to perform this INSERT statement in this manner, if at all possible.

Any suggestions?

    Your input value is exceed the max length that Text datatype can handle. Please change your datatype to varchar and set the length base on your need. The max length you can use is 8000.

      Your input value is exceed the max length that Text datatype can handle

      Hardly.

      Use ' and not " to delimit text strings in SQL. If the string contains ' escape it with a '

        Write a Reply...