Re: Stored Procedures and clipping strings
Posted in 1997
Galt von Holten wrote:
>
> Hello world
>
> i am trying to conncat two char-variables within a stored procedure.
> the operator || works fine, but:
> informix chars are space terminated and the conncatenation operator
> does not clip (skip all ending spaces) the strings.
>
> example:
>
> DEFINE a, b CHAR(10);
> DEFINE c CHAR(20);
>
> LET a = "x";
> LET b = "y";
> LET c = a || b;
>
> The variable c has now the values "x y ".
> I would like to have c = "xy ".
>
> HOW CAN I DO THIS ???
> //////
> ------------------------------ooo-O-O-ooo----------------------------
> Galt von Holten U Tel.: +49 421 / 20 20 446
> messerknecht meister informationssysteme Fax: +49 421 / 20 20 288
> Linzer Str. 3-5, D-28359 Bremen E-Mail: gvh@mds-hb.de
> ---------------------------------------------------------------------
Galt,
try the trim function, which is very versatile. See page 1-707 of the
Guide to SQL-Syntax (Version 7.2). Here's an example of SPL using it:
create procedure display_names()
returning char(31); define fn like customer.fname;
define ln like customer.lname;
define full_name char(31);
foreach select fname, lname
into fn, ln
from customer
let full_name = trim(fn) || " " || trim(ln);
return full_name with resume;
end foreach;
end procedure;
--
-- Jake (Wishes he were more trim)
. .
_..-'( )`-.._
./'. '||\\\\. }\\_/{ .//||` .`\\.
./'.|'.'||||\\\\|.. )o o( ..|//||||`.`|.`\\.
./'..|'.|| |||||\\`````` \\'@'/ ''''''/||||| ||.`|..`\\.
./'.||'.|||| ||||||||||||. | .|||||||||||| ||||.`||.`\\.
/'|||'.|||||| ||||||||||||{ | }|||||||||||| ||||||.`|||`\\
'.|||'.||||||| ||||||||||||{ | }|||||||||||| |||||||.`|||.`
'.||| ||||||||| |/' ``\\||`` | ''||/'' `\\| ||||||||| |||.`
|/' \\./' `\\./ \\!|\\ /|!/ \\./' `\\./ `\\|
V V V }' `\\ /' `{ V V V
\\ \\ \\ V / / /
+-----------------------------------------------------------+
| Impeccable Logic: A thought process which successfully |
| resists chicken bites |
+-----------------------------------------------------------+