Subject | Re: CR/LF in select |
---|---|
Author | peter_jacobi.rm |
Post date | 2003-08-13T19:16:54Z |
Hi Julien,
(Before answering your questions I must state, that
I believe this problem most often occurs in
SQL quizzes, as in the real world it is more likely
to be handled by the front end app.)
A related problem was just discussed in the thread
starting here:
http://groups.yahoo.com/group/firebird-support/message/28441?threaded=1
In effect two solutions were proposed, either
needing either a UDF or an additional character set:
Solution 1:
SQL> select
ADDRESS || ascii_char(13) || ascii_char(10) ||
CITY || ascii_char(13) || ascii_char(10) ||
ZIP_CODE from MYTABLE;
Solution 2:
SQL> select
ADDRESS || _LIKEJAVA'\u000D\u000A' ||
CITY || _LIKEJAVA'\u000D\u000A' ||
ZIP_CODE from MYTABLE;
If you are working with connection character set NONE
(shudder!), an additional cast is required:
SQL> select
ADDRESS ||
cast (_LIKEJAVA'\u000D\u000A' AS char(2) character set DOS437) ||
CITY ||
cast (_LIKEJAVA'\u000D\u000A' AS char(2) character set DOS437) ||
ZIP_CODE from MYTABLE;
You can beautify this a bit by:
SQL> create table crlf (crlf char(2) character set DOS437);
SQL> insert into crlf values (_LIKEJAVA'\u000D\u000A');
SQL> select
ADDRESS || crlf ||
CITY || crlf ||
ZIP_CODE from MYTABLE,crlf;
Regards,
Peter Jacobi
(Before answering your questions I must state, that
I believe this problem most often occurs in
SQL quizzes, as in the real world it is more likely
to be handled by the front end app.)
A related problem was just discussed in the thread
starting here:
http://groups.yahoo.com/group/firebird-support/message/28441?threaded=1
In effect two solutions were proposed, either
needing either a UDF or an additional character set:
Solution 1:
SQL> select
ADDRESS || ascii_char(13) || ascii_char(10) ||
CITY || ascii_char(13) || ascii_char(10) ||
ZIP_CODE from MYTABLE;
Solution 2:
SQL> select
ADDRESS || _LIKEJAVA'\u000D\u000A' ||
CITY || _LIKEJAVA'\u000D\u000A' ||
ZIP_CODE from MYTABLE;
If you are working with connection character set NONE
(shudder!), an additional cast is required:
SQL> select
ADDRESS ||
cast (_LIKEJAVA'\u000D\u000A' AS char(2) character set DOS437) ||
CITY ||
cast (_LIKEJAVA'\u000D\u000A' AS char(2) character set DOS437) ||
ZIP_CODE from MYTABLE;
You can beautify this a bit by:
SQL> create table crlf (crlf char(2) character set DOS437);
SQL> insert into crlf values (_LIKEJAVA'\u000D\u000A');
SQL> select
ADDRESS || crlf ||
CITY || crlf ||
ZIP_CODE from MYTABLE,crlf;
Regards,
Peter Jacobi