![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
While writing a query to do some editting i wanted to use CHR(10) to have a query do some formatting. It seems that whenever it is used, it adds an extra newline at the end of the line. SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual CONNECT BY LEVEL < 4) |
#3
| |||
| |||
|
|
Brian Tkatch wrote: While writing a query to do some editting i wanted to use CHR(10) to have a query do some formatting. It seems that whenever it is used, it adds an extra newline at the end of the line. SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual CONNECT BY LEVEL < 4) No - your display simply is not wide enough. Why don't you check out all possible settings in SQL*Plus? the one you want is SET LINES[ize] -- Regards, Frank van Bortel Top-posting is one way to shut me up... |
#4
| |||
| |||
|
|
Brian Tkatch wrote: While writing a query to do some editting i wanted to use CHR(10) to have a query do some formatting. It seems that whenever it is used, it adds an extra newline at the end of the line. SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual CONNECT BY LEVEL < 4) No - your display simply is not wide enough. |
|
Why don't you check out all possible settings in SQL*Plus? the one you want is SET LINES[ize] |
#5
| |||
| |||
|
|
On Nov 21, 12:48 pm, Frank van Bortel <frank.van.bor... (AT) gmail (DOT) com wrote: Brian Tkatch wrote: While writing a query to do some editting i wanted to use CHR(10) to have a query do some formatting. It seems that whenever it is used, it adds an extra newline at the end of the line. SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual CONNECT BY LEVEL < 4) No - your display simply is not wide enough. Why don't you check out all possible settings in SQL*Plus? the one you want is SET LINES[ize] -- Regards, Frank van Bortel Top-posting is one way to shut me up... I return the same results that you posted, using 10.2.0.3.0 on AIX: SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual 2 CONNECT BY LEVEL < 4); A B -- ----------------------------------------- 1 1 2 2 3 3 no matter how long my linesize. Also the method of introducing the chr(10) into the text matters not: SQL> variable lf varchar2 SQL> exec :lf := chr(10); PL/SQL procedure successfully completed. SQL> select rownum a, :lf||rownum b 2 from dual 3 connect by level < 4; A B |
#6
| |||
| |||
|
|
On Wed, 21 Nov 2007 11:40:24 -0800 (PST), "fitzjarr... (AT) cox (DOT) net" fitzjarr... (AT) cox (DOT) net> wrote: On Nov 21, 12:48 pm, Frank van Bortel <frank.van.bor... (AT) gmail (DOT) com wrote: Brian Tkatch wrote: While writing a query to do some editting i wanted to use CHR(10) to have a query do some formatting. It seems that whenever it is used, it adds an extra newline at the end of the line. SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual CONNECT BY LEVEL < 4) No - your display simply is not wide enough. Why don't you check out all possible settings in SQL*Plus? the one you want is SET LINES[ize] -- Regards, Frank van Bortel Top-posting is one way to shut me up... I return the same results that you posted, using 10.2.0.3.0 on AIX: SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual 2 CONNECT BY LEVEL < 4); A B -- ----------------------------------------- 1 1 2 2 3 3 no matter how long my linesize. Also the method of introducing the chr(10) into the text matters not: SQL> variable lf varchar2 SQL> exec :lf := chr(10); PL/SQL procedure successfully completed. SQL> select rownum a, :lf||rownum b 2 from dual 3 connect by level < 4; A B Thank you. I came up with it originally in a CASE statement, to create CREATE VIEW statements. I worked around it by opening Word, and doing a replace on ",^p^p". Though, i am quite curious why this is happening. And thanx for the example in PL/SQL. B. |
#7
| |||
| |||
|
|
On Nov 21, 12:48 pm, Frank van Bortel <frank.van.bor... (AT) gmail (DOT) com wrote: Brian Tkatch wrote: While writing a query to do some editting i wanted to use CHR(10) to have a query do some formatting. It seems that whenever it is used, it adds an extra newline at the end of the line. SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual CONNECT BY LEVEL < 4) No - your display simply is not wide enough. Why don't you check out all possible settings in SQL*Plus? the one you want is SET LINES[ize] -- Regards, Frank van Bortel I return the same results that you posted, using 10.2.0.3.0 on AIX: SQL> SELECT RowNum A, CHR(10) || RowNum B FROM (SELECT * FROM Dual 2 CONNECT BY LEVEL < 4); A B -- ----------------------------------------- 1 1 2 2 3 3 no matter how long my linesize. Also the method of introducing the chr(10) into the text matters not: SQL> variable lf varchar2 SQL> exec :lf := chr(10); PL/SQL procedure successfully completed. SQL> select rownum a, :lf||rownum b 2 from dual 3 connect by level < 4; A B -- ------------------------------------------------------------------------ 1 1 2 2 3 3 SQL I find no explanation of this behaviour on the web, thus I am at a loss to explain it. |
#8
| ||||||
| ||||||
|
|
On 21 nov, 20:53, Brian Tkatch <N/A> wrote: On Wed, 21 Nov 2007 11:40:24 -0800 (PST), "fitzjarr... (AT) cox (DOT) net" SNIP You normally would not create views "on the fly"... |
|
Apart from that - there's no need for carriage returns in DDL, |

|
but if you really want them, just embed the carriage return in the statement: SQL> select 'hello 2 world' from dual; 'HELLOWORLD' ------------ hello world |
|
And yes- there's an extra space before Hello on line 2. |

|
| CHR(10) || 'AS' | CHR(10) || ' SELECT' | CHR(10) END | CHR(09) || Columns.Column_Name | RPAD(CHR(09), (Tabs - FLOOR(LENGTH(Column_Name) / 8)) + 1, CHR(09)) | INITCAP(SUBSTR(Columns.Column_Name, 8, LENGTH(Columns.Column_Name) - 9)) | CASE WHEN Columns.Column_Id = Info.Total_Columns THEN |
|
| CHR(10) || CHR(09) || Columns.Table_Name || ';' | CHR(10) || CHR(10) | 'CREATE OR REPLACE SYNONYM V' | SUBSTR(Columns.Table_Name, 5, 3) | ' FOR ' || INITCAP(SUBSTR(Columns.Table_Name, 9)) || ';' |
#9
| |||
| |||
|
|
On Thu, 22 Nov 2007 04:32:22 -0800 (PST), Frank van Bortel frank.van.bortel (AT) gmail (DOT) com> wrote: On 21 nov, 20:53, Brian Tkatch <N/A> wrote: On Wed, 21 Nov 2007 11:40:24 -0800 (PST), "fitzjarr... (AT) cox (DOT) net" SNIP You normally would not create views "on the fly"... True. But i don't see what that has to do with anything. I did not mean to sound like i was complaining how i want something to work. I am asking why it works the way that it does. |
|
Apart from that - there's no need for carriage returns in DDL, There is, if i want it to look pretty. ![]() |
#10
| |||
| |||
|
|
Brian Tkatch wrote: On Thu, 22 Nov 2007 04:32:22 -0800 (PST), Frank van Bortel frank.van.bortel (AT) gmail (DOT) com> wrote: On 21 nov, 20:53, Brian Tkatch <N/A> wrote: On Wed, 21 Nov 2007 11:40:24 -0800 (PST), "fitzjarr... (AT) cox (DOT) net" SNIP You normally would not create views "on the fly"... True. But i don't see what that has to do with anything. I did not mean to sound like i was complaining how i want something to work. I am asking why it works the way that it does. It is quite often an indication of (bad) SQL Server habits being ported to Oracle. Oracle does things differently; it's better to start with that in mind. Creating objects on the fly is something that should not be permitted in any environment, even SQL Server. For SQL Server, temporary tables may be an exception. |
|
I just wanted to point that out... There's one exception, I can think of - when delivering an update (or install) script for maintenance purposes. Apart from that - there's no need for carriage returns in DDL, There is, if i want it to look pretty. ![]() Well - who's going to see the code? It was my understanding the code being generated was to be executed, using dynamic SQL? [snip!] |
![]() |
| Thread Tools | |
| Display Modes | |
| |