Subject TIB_ColumnText and strings that are too long
Author Martijn Tonies
Hi,

I'm using a TIB_DSQL component and parameters to insert data into a table.

I have a VARCHAR(20) defined in the database.

Now I'm assigning a value of length 60 to it.

It did not generate an error.

So, I started looking through IBO-source. It seems that TIB_ColumnText
only moves the "sqllen" characters into the buffer:

procedure TIB_ColumnText.SetValue( const NewValue: string );
var
tmpVal: string;
strLen: integer;
begin
tmpVal := NewValue;
SysBeforeModify;
case CharCase of
ccUpper: tmpVal := AnsiUpperCase( tmpVal );
ccLower: tmpVal := AnsiLowerCase( tmpVal );
end;
if not Row.IsKeyFields then
ApplyTrimming( tmpVal, Trimming );
strLen := Length( tmpVal );
FillChar( FNewColumnBuffer^, DataSize, FPadChar );
if ( strLen = 0 ) and FBlankIsNull then
SysSetIsNull( true )
else
begin
SysSetIsNull( false );

/* here!! */

if strLen > SQLLen then
strLen := SQLLen;
Move( tmpVal[1], FNewColumnBuffer^, strLen );
end;
SysAfterModify;
end;

If the string is too long, it will only copy "SQLLen" number of
characters...

All fine and dandy, but I WANT it to return an error. How else would I know
that my data
has been cut off?

Any ideas?

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com