SPUG: perl - sql - text datafield

Colin Meyer cmeyer at helvella.org
Fri Oct 19 12:15:08 CDT 2001

Hi, Martin,

On Fri, Oct 19, 2001 at 09:24:17AM -0700, Martin Korb wrote:
> I am writing a cgi program which queries a database table. One of the
> columns has data-type of text (meaning it exceeds 256 bytes). I am
> trying to display the content of all the columns on a page as cells of
> a table (this is the easy part). I am just not able to display the
> content of the column whose data-type is text. I know the content is
> actually stored as a pointer to the content in the database table, but
> I am not at all sure how do get out. Do I need to loop over the
> content and just advance the pointer to point to next 256 bytes or
> what....?

When fetching LOBs (Large Objects: BLOBS, Text, etc) from a database,
there are two DBI database handle attributes to keep in mind: LongReadLen
and LongTruncOk.  

LongReadLen is an integer that represents the maximum length of long
fields to be read from the database. Note that the interpretation of
this integer can vary depending on the underlying DBD.  It might refer
to the length in bytes, or perhaps in characters.  A value of 0 means
that the DBI wont fetch long values at all.

LongTruncOk is a boolean that controls the action of the DBI when a
value longer than LongReadLen is fetched from the database. If it is
true, the value will be truncated to LongReadLen. If false, an error
will occur.

Typically these values default to 0 and false, respectively, but that
may also vary by DBD. They should always be set explicitly by code that
is dealing with long fields. For consistent behavior between different
DBDs, these attributes should be adjusted in the database handle object
before statement handles are prepared.

Have fun,

> Thanks Martin

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/

More information about the spug-list mailing list