At 07:10 p.m. 4/06/2015, [email protected] [firebird-support] wrote:

>Hello,
>
>I need to produce delimited text output from my stored procedure, for example:
>
>23;65;some text;
>
>The thing is that semicolon ";" might appear in one of the delimited fields 
>and this will cause some bugs on the client side. So I want to change this 
>character to a less common one. I've decided to use ASCII 7 - a "Bell" 
>character. 
>
>I am afraid that usage like this:
>
>DECLARE V_OUTPUT VARCHAR(1024);
>DECLARE V_PARAM VARCHAR(32);
>...
>
>V_OUTPUT = V_OUTPUT || ASCII_CHAR(7) || V_PARAM;
>
>will slow down my query because I will be doing a lot of concatenations. 
>Correct me if I am wrong but I think that even if I put this code into stored 
>procedure, ASCII_CHAR(7) will not be resolved at compile time and will be 
>called over and over again?
>
>Is there other way to put my character directly into the query? For semicolon 
>that was easy:
>
>V_OUTPUT = V_OUTPUT || ';' || V_PARAM;
>
>but how to do this with a Bell character?

Just call the function once, in the declarations.

In the proc header:
declare v_delimiter char = ascii_char(7);

For the output:
V_OUTPUT = V_OUTPUT || v_delimiter || V_PARAM;

Helen

Reply via email to