Re: Space-padded Strings and Stored Procedures
Posted in 2000
SELECT TRIM( fullname ) INTO ...
Best regards,
Danail
-----Original Message-----
From: Paul Harman <paul@kasterborus.demon.co.uk>
To: informix-list@iiug.org <informix-list@iiug.org>
Date: 11 '''''''' 2000 '. 15:15
Subject: Space-padded Strings and Stored Procedures
>I'm running Informix Dynamic Server Version 7.30.UC7 (straight from
>onstat!).
>
>I have a stored procedure to perform an audit trailing function. It takes
in
>an ID, performs a lookup on the appropriate table using this ID to get a
>"name", and then enters this name into the audit table, thusly:
>
>CREATE PROCEDURE valueadded(vid INT)
> DEFINE valuename VARCHAR(255);> DEFINE details VARCHAR(255);
>
> SELECT fullname INTO valuename FROM value WHERE valueid=vid;
> LET details="Added " || valuename || " value";
> INSERT INTO audit (occurred, comment) VALUES (CURRENT, details);>END PROCEDURE;
>
>My problem is that the "fullname" field in the "value" table is a char
128 -
>and thus gets padded out with spaces. This means that there is a tremendous
>amount of surplus white space before the word 'value' in the log.
>
>[Obviously this example is rather artificial, but I can't give exact code
>snippets]
>
>Is there any way of "trimming" this space? It's no problem to me when I use
>Java or Perl (the main apps running on the DB) because I can .trim() or
>s/\\s+$// respectively, but I can't find a similar mechanism to do this in
>Stored Procedures - and for performance reasons I don't want to change the
>value table to use a varchar for the fullname attribute.
>
>Anyone have any good ideas? Many thanks in advance,
>
> Paul
>
>