When LongTruncOk is false, attempting to retrieve more than LongReadLen bytes 
from a column will throw that error. You should set LongReadLen.

--
Blaine  http://datacentermoving.com

-----Original Message-----
From: Moderator [mailto:[email protected]]
Sent: Monday, March 02, 2009 9:04 PM
To: [email protected]
Subject: SQL Keyword is used as Field Name. SELECT Query Problem using DBI.

Hello,

One of our tables awb_msg has the field name 'text' and when I try to use the 
DBI to do a select it prompts an error. How can I do this.

I can't change the field name as it is in a production environment and has been 
use for the past 10 years with no problems. We are using ms- sqlserver. And 
also, I have no control of changing the field name. So, changing the field name 
is not possible.

Here is my test:

This is working correctly.

--
my $sql = "SELECT seq, create_date, msg_code, send_receive FROM awb_msg where 
seq = 7989176";

it returns:

 Number of Fields: 4
7989176, 2009-03-02 01:20:45.430, FHL, R

---

But, once I add the 'text' field in the SELECT Query, Perl DBI stops with an 
error:

---
my $sql = "SELECT seq, create_date, msg_code, send_receive, text FROM awb_msg 
where seq = 7989176";

DBD::ODBC::st fetchrow_arrayref failed: [Microsoft][ODBC SQL Server 
Driver]Strin g data, right truncation (SQL-01004)(DBD: st_fetch/SQLFetch (long 
truncated DBI attribute LongTruncOk not set and/or LongReadLen too small) 
err=-1) at ./dbi.pl line 34.
DBI::db=HASH(0x10055fb8)->disconnect invalidates 1 active statement handle 
(eith er destroy statement handles or call finish on them before
disconnecting) at ./d
bi.pl line 45.

---

I have tried various ways and all returns an error:

awb_msg.text
awb_msg."text"
"awb_msg"."text"
etc.

Please guide me how I can do this.

Reply via email to