Subject Re: [firebird-support] white character variable
Author Helen Borrie
At 12:34 PM 9/09/2007, you wrote:
>Hi, i have a problem to generate variable containing white character
>string. Ex if my variable P_SIZE has 8 for value, i need to have in the
>V_ZONE variable ' ' but now i receive '' . What i do wrong or
>how can i solve my problem?
>
>Thanks
>
>Here's my proc:
>
>P_SIZE INTEGER;
>declare variable V_LG Integer;
>declare variable V_ZONE Varchar(2000);
>
> V_ZONE = '';
> V_LG = 1 ;
> WHILE (V_LG <= :P_SIZE) DO BEGIN
> V_ZONE = V_ZONE || ' ' ;
> V_LG = V_LG + 1;
> END

VZONE is a VARCHAR type. That means that trailing white space is not
stored. Appending whitespace to an empty string *variable* does
create a chain of blanks of the intended length but, when you post it
alone to a varchar field in a database table, or try to return its
value to your application as a varchar output parameter, the trailing
blanks are stripped and you get an empty string.

Leading and infixed whitespace in a varchar *is* significant, so, as
long as you concatenate the white space characters between two
non-whitespace characters, they will stick when you pass them to output.

It's vague why you might try to do this on the server side...if you
explain what you want to achieve, someone might come up with a bright
idea for you.

./heLen