Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to handle Long Data type

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
Hai!

I have problem when i use long datatype its giving following error can any one help me in resolving the issue i am using perl DBI for database connection and oracle 8 as backend.

The error message is

DBD::Oracle::st fetchrow_array failed: ORA-01406: fetched column value was truncated (DBD: ORA-01406 error on field 8 of 11, ora_type 8, DBI attribute LongTruncOk not set and/or LongReadLen too small)

ThaNX
:)
Thendal
 
Thendal,

Are you setting DBI attribute's LongTruncOk and LongReadLen? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Hey thendal,
Descarte and Bunce cover this specifically in 'Programming the Perl DBI', published by OReilly. They say (paraphrased)....

The LongReadLen attribute is typically set pretty small. You must set it to allow for the max amount of data you might get back.
Code:
$dbh->{LongReadLen} = 1000 * 1024; # for a meg
$sth = $dbh->prepare(" sql stuff in here");
$sth->execute;
while.....

If the LongTruncOK attribute is off and you excede the amount expected, you will get an error. If it is on, then the data will be truncated and you can go from there.

If you are doing the kind of code, I recommend getting the book. It is clear and concise and well worth the $35.

HTH


keep the rudder amid ship and beware the odd typo
 
According to the documentation I've read the LongReadLen is often set to something SMALLER than the maximum that a normal character field can handle! To me this is just plain STUPID! What's the point of using a long field (like a text blob) if you're going to default the maximum read length to LESS that you'd get if you just used a character field? The default should be at least as long as the maximum size of a character field, if not twice that.
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Mike :-I didn't set any attribute,

goboating i brought the book programming perl DBI Oreilly publication .

I have a doubt, i don't know what is the size of input the user is going to input ,In this case how i will set the attribute if user input exceed 1000* 1024.

For time being i am using varchar datatype with 2000 maximum

Through javascript i am validating if they input more than 2000 characters i will prompt to reduce the input.

But i need to give user a flexiblity.

Any thoughts:)

 
seems like you have three immediate options:

1 - set LongTruncOK to '1' and truncate the upload - probably not what you want to do.

2 - I would suggest that the limit you put on the LOB size should be related to how you are managing you system.
Things like, how much disk space do I want one transaction to be able to take up? How much disk space do you have, overall?
-or -
What kind of stuff do I want people to be able to "poke into"/"get out of" my database? How big is that stuff, normally?... .....maybe multiply by two or three..??....

3 - If none of that is of concern,( seems like it should be of concern) then the size you allow is arbitrary - set it huge and let it ride. ( a little crude, but it would work).

HTH





keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top