Re: LPAD and RPAD fails ?
Posted in 2004
Ph. Chantry wrote:
> Good morning/evening,
>
> Using dbaccess 9.40, the LPAD and RPAD SQL funcion gives strange results:
>
> SQL script:
> create temp table f1(chr char(4), vch varchar(4))WITH NO LOG;
> insert into f1 values("1","1");
> select chr, lpad(chr,4,'0') lpad_c, rpad(chr,4,'0') rpad_c,
> vch, lpad(vch,4,'0') lpad_v, rpad(vch,4,'0') rpad_v
> from f1;>
> Result:
> chr lpad_c rpad_c vch lpad_v rpad_v
> 1 1 1 1 0001 1000
>
>
> The functions only work with VARCHAR columns ?
> They also work with INTEGER columns, or constant strings.
>
> Any idea ?
>
> Thank you,
> Philippe
>
>
>
Hi Chantry,
It works for CHAR as well, but there is no room
for padding because CHAR is already padded with
spaces during select.
So, you need to use TRIM function for CHAR columns
before LPAD or RPAD.
Best regards,
--
Mladen Jovanovski
Phone: +389 2 244 1140
Mobile: +389 75 400 309
COSMOFON - Mobile Telecommunications Services - A.D. Skopje
_______________________________________________________________
This e-mail (including any attachments) is confidential and may be protected by legal privilege. If you are not the intended recipient, you should not copy it, re-transmit it, use it or disclose its contents, but should return it to the sender immediately and delete your copy from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. COSMOFON A.D. Skopje shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its receipt or damage to your system.
sending to informix-list