Subject Re: [firebird-support] size of the field
Author Helen Borrie
At 11:15 PM 10/03/2004 +0000, you wrote:
>Hi,
> Is there a strlen statement in FireBird SQL to get the size of a
>field? For example...
>
>If i do "INSERT INTO TABLE1( field1 ) VALUES( "ABC" );

That is not valid SQL. You must use single quotes for delimiting strings.


>then is something like
>
>SELECT strlen(field) from TABLE1; ?

There is an UDF strlen() (and also substrlen()) for getting the number of
characters in an actual item of data.

If you need to determine the defined size of a column, you would have to
query the system tables RDB$RELATION_FIELDS and RDB$FIELDS. For metadata
info on the system tables, see the IB 6 Language Reference. As a comment,
you would have to have some serious justification for using SQL to check
length limits for every insert or update query. This would be very
costly. It is much cheaper to do input size validations on the client; or
simply to handle overflow exceptions.

/heLen