Subject | Re: Removing trailing spaces from varchar |
---|---|
Author | Adam |
Post date | 2005-07-30T04:47:59Z |
--- In firebird-support@yahoogroups.com, "Alan McDonald" <alan@m...>
wrote:
DECLARE EXTERNAL FUNCTION rtrim
CSTRING(255)
RETURNS CSTRING(255) FREE_IT
ENTRY_POINT 'IB_UDF_rtrim' MODULE_NAME 'ib_udf';
A simple
BEFORE INSERT OR UPDATE
trigger could have the single line
NEW.ID = rtrim(NEW.ID);
But consider using generators and bigint for primary key fields. I
imagine quite a lot of confusion could happen if the client program
thinks it knows the real primary key but in reality you have changed
it. It may end up with a foreign key violation when it tries to use
the string it thinks is the PK in another table.
Adam
wrote:
> >preferably
> > Hi, is there a way to remove trailing spaces from a varchar,
> > using a trigger?Even easier, IB_UDF is included in the default firebird install
> >
> > For example:
> >
> > ID = 'XYZ ';
> >
> > should be converted to: ID = 'XYZ';
> >
> > Are there any functions for doing this?
> >
> > Thanks
> >
>
> F_STRIPSTRING works for me. It's in the FreeUDFLib
> Alan
DECLARE EXTERNAL FUNCTION rtrim
CSTRING(255)
RETURNS CSTRING(255) FREE_IT
ENTRY_POINT 'IB_UDF_rtrim' MODULE_NAME 'ib_udf';
A simple
BEFORE INSERT OR UPDATE
trigger could have the single line
NEW.ID = rtrim(NEW.ID);
But consider using generators and bigint for primary key fields. I
imagine quite a lot of confusion could happen if the client program
thinks it knows the real primary key but in reality you have changed
it. It may end up with a foreign key violation when it tries to use
the string it thinks is the PK in another table.
Adam