Does SQL Plus recognize any type of newline character from DBMS_OUTPUT?

I am building a complex string inside a procedure and displaying with dbms_output.put_line. It works fine in SQL Developer but when I use it in SQL Plus it comes out goofy. It's been narrowed down to me using CHR(10) where I want line breaks. Is it possible to display a "formatted" varchar2 in SQL Plus as I'm expecting them? I even tried using .put with no luck.
Using:
Oracle 10.2.0.4.0
SQL Plus 10.2.0.1 / 9.2.something
Here's a small example:
set serverout on
set linesize 10
declare
  lv_string varchar2(32767);
begin
  for x in 1..5
  loop
    lv_string := lv_string || 'I AM LINE ' || to_char(x) || chr(10);
  end loop;
  dbms_output.put_line(lv_string);
end;
Expected Output (What I'm getting in SQL Developer):
I AM LINE 1
I AM LINE 2
I AM LINE 3
I AM LINE 4
I AM LINE 5
Actual Output (SQL Plus):
I AM LINE
1
I AM
LINE 2
I
AM LINE
3
I AM
LINE 4
I
AM LINE 5Right now I'm using a workaround, but would like to use a character (or combination of character) that SQL Plus will play nice with...if there are any.
declare
  lv_string     varchar2(32767);
  lv_start      pls_integer;
  lv_end        pls_integer := 0;
  c_newl        constant varchar2(1) := chr(10);
begin
  for x in 1..200
  loop
    lv_string := lv_string || 'I AM LINE ' || to_char(x) || c_newl;
  end loop;
  loop
    lv_start := lv_end + 1;
    lv_end := instr(lv_string, c_newl, lv_start);
    exit when lv_end <= lv_start;
    dbms_output.put_line(substr(lv_string, lv_start, lv_end- lv_start));
  end loop;
end;

Hi,
you need to increase your linesize:
SQL> declare
  2    lv_string varchar2(32767);
  3  begin
  4    for x in 1..5
  5    loop
  6      lv_string := lv_string || 'I AM LINE ' || to_char(x) || chr(10);
  7    end loop;
  8    dbms_output.put_line(lv_string);
  9  end;
10  /
I AM LINE
1
I AM
LINE 2
I
AM LINE
3
I AM
LINE 4
I
AM LINE 5
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
SQL> set lines 255
SQL> declare
  2     lv_string varchar2(32767);
  3   begin
  4     for x in 1..5
  5     loop
  6       lv_string := lv_string || 'I AM LINE ' || to_char(x) || chr(10);
  7     end loop;
  8     dbms_output.put_line(lv_string);
  9   end;
10   /
I AM LINE 1
I AM LINE 2
I AM LINE 3
I AM LINE 4
I AM LINE 5
PL/SQL procedure successfully completed.

Similar Messages

  • Does SQL Developer have any way to run the SQL*PLUS COPY FROM command?

    set arraysize 100;
    set copycommit 100;
    COPY FROM SCOTT/TIGER@OtherDBinstance -
    CREATE COMPANY -
    USING SELECT * from COMPANY;

    Thanks. I have been using the create table ABC as select * from ABC@otherdb but this often runs into temp segment issues for very large tables. The SQL*PLUS version allows me to have the copy commit save after each xxxxx lines and this seems to be able to handle any size table. Can copy commit be used from SQL Developer?

  • Why does SQL*Plus split query result?

    My result is:
    ENAME DEPTNO SAL RUNNING_TOTAL DEPARTMENT_TOTAL SEQ
    CLARK 10 2450 2450 2450 1
    KING 10 5000 7450 7450 2
    MILLER 10 1300 8750 8750 3
    ADAMS 20 1100 9850 1100 1
    FORD 20 3000 12850 4100 2
    JONES 20 2975 15825 7075 3
    SCOTT 20 3000 18825 10075 4
    SMITH 20 800 19625 10875 5
    ALLEN 30 1600 21225 1600 1
    BLAKE 30 2850 24075 4450 2
    JAMES 30 950 25025 5400 3
    ENAME DEPTNO SAL RUNNING_TOTAL DEPARTMENT_TOTAL SEQ
    MARTIN 30 1250 26275 6650 4
    TURNER 30 1500 27775 8150 5
    WARD 30 1250 29025 9400 6
    14 rows selected.
    It is very annoying and I wonder if there is a way to tell SQL*Plus not to split this result into 2 sub-results.

    user8931607 wrote:
    It is very annoying and I wonder if there is a way to tell SQL*Plus not to split this result into 2 sub-results.Well, then you should RTFM. Discover SQL*Plus PAGESIZE property:
    SQL> select ename from emp
      2  /
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    ENAME
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> set pagesize 100
    SQL> select ename from emp
      2  /
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> SY.

  • How to remove a newline character from a column

    hi all...
    i have a column in a table in which some of the datas contain a newline character at their last.
    i need to remove those newline characters.
    for example.... a data is
    'abcd
    (notice the end of the quotation).....i need to get the data as...'abcd'
    plss help me...
    thanks in advance..

    thanks for ur reply...
    i got your point..but here what you have done is....u have inserted a particular character set in between 'abcd' and 'xyz' and afetr that just replaced those character set by null....
    but in my case the problem is a bit different...
    the datas are already present and what i have to do is to remove the newline spaces from the end of the datas.
    select replace(column_name,'<what shall i put here>',null) from table_name;
    in your example...that is 'chr(10)'...but in my case its a newline character....

  • Does applecare+(plus) offer any deals on upgrading phones when paying the 49$ to replace an accidently damaged phone? If so please give details and possible prices. iPhone 4 to iPhone 5

    Water damaged phone, volume stuck going up and camera does not turn on. I am covered by applecare+, but just wondering if i can get any deals or if it's possible to upgrade the replacement phone for a fee?

    "So just to clear up, they wouldn't give me a reduction on buying an iphone 5 if i were to give them my iphone 4+49$+whatever the iphone 5 costs with a reduction?"
    Correct.
    You will ge tthe exact same model. 
    If you want a different model, then you would have to purchase like anyone else. 

  • How does SQL*PLUS read script files

    Hello!
    well, it is possible to start sqlplus with an sql script file:
    sqlplus user/pass@srv @my_script.sqlok, so what happens if I delete the file my_script.sql ?
    My script here is about 1 GB big! sqlplus was half way done when I deleted the file.
    Is the sqlplus going to stop with an error? Or just hang?
    I copied the my_script.sql file now to the folder again and I think that sqlplus is still working fine. But can I be sure, that all statements in the script have been processed?
    Thanks in advance!

    Results are OS dependent which you declined to share with us.
    I suspect *NIX & not Windoze.
    On Windoze, you can not delete open file.
    On *NIX open file does not actually get deleted until fclose() is called.
    All in all, you are OK.

  • Does the 6033E have any type of short circuit protection on the 5v line?

    This is not a problem, but seeking information to correspond to a design consideration between my test platform and UUT.

    The 5 V line on your board is fused. The KnowledgeBase below lists the type of fuse used on the 6033E:
    http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/e1f4d5736d91a625862560b6005bf81f?OpenDocument
    Regards,
    Erin

  • The contained field name "ADTAGR" does not exist in any of the database tab

    hı all
    how can l  solved thıs problem
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
    not caught in
    procedure "PUT_QMFECAT" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    An Open SQL clause was specified dynamically. The contained field name
    "ADTAGR" does not exist in any of the database tables from the FROM clause.
    Information on where terminated
        Termination occurred in the ABAP program "SAPDBZQNQ" - in "PUT_QMFECAT".
        The main program was "ZQMR_BILDIRIM ".
        In the source code you have the termination point in line 732
        of the (Include) program "SAPDBZQNQ".
    Error occurred during batch input processing
        The termination is caused because exception "CX_SY_DYNAMIC_OSQL_SEMANTICS"
         occurred in
        procedure "PUT_QMFECAT" "(FORM)", but it was neither handled locally nor
         declared
        in the RAISING clause of its signature.
        The procedure is in program "SAPDBZQNQ "; its source code begins in line
        715 of the (Include program "SAPDBZQNQ ".
    FORM put_qmfecat.
      DATA: l_tab_fields  TYPE  rsfs_tab_fields.
      DATA: l_ds_clauses  TYPE  rsds_where.
    Dynamische Feldselektion
      MOVE 'QMFECAT_C' TO l_tab_fields-tablename.
      READ TABLE select_fields WITH KEY l_tab_fields-tablename
                                    INTO l_tab_fields.
      IF sy-subrc <> c_rc00.
        CLEAR l_tab_fields.
      ENDIF.
    Dynamische Selektionskriterien
      MOVE 'QMFECAT' TO l_ds_clauses-tablename.
      READ TABLE dyn_sel-clauses WITH KEY l_ds_clauses-tablename
                                 INTO l_ds_clauses.
    DB-Zugriff
      >>>>> SELECT (l_tab_fields-fields) FROM qmfe
      INTO CORRESPONDING FIELDS OF TABLE qmfecat_tab
       WHERE qmnum  =  rqmqmel-qmnum
       AND kzloesch =  space
       AND (l_ds_clauses-where_tab)
       ORDER BY PRIMARY KEY.
    regard sinan
    Edited by: eyup_sinan on Jan 6, 2012 3:21 PM
    Edited by: eyup_sinan on Jan 6, 2012 3:30 PM

    You seem to have made a copy of the standard program. You'll have to make sure that you are handling this field correctly in your code.
    Rob

  • Connecting to 9i Lite DBMS via SQL*Plus?

    Finally got the install to run successfully. However, I can't make an ODBC connection to the database with SQL*Plus. Any ideas (other than going back to 8i Lite)?

    Have you created a User Data Source to your Oracle Lite database throught the Microsoft ODBC Administrator? If so, then through sql*plus- you should be able to test connectivity.
    Goto a dos command window and type sqlplus system/manager@odbc:your_database_name;
    Where your_database_name is the name of the OBDC Data Source name that you have created.
    Hope this helps.
    null

  • How to start/stop process flow from sql*plus?

    Hi,
    i know how to start a process flow via sqlplus_exec_template.sql, but i cannot find any information on how to stop (and rollback) a working flow from sql*plus. Any help would be appreciated.
    Greetings
    Christoph
    Message was edited by:
    ctrierweiler

    Hi,
    I've had a go.
    How should I interpret the results of list_requests:
    owner_owr@ORKDEV01> @list_requests
    ====================
    DEPLOYMENTS
    ====================
    Audit ID Status Name Date Owner
    2706 READY Deployment Fri Nov 11-NOV-05 10:49:59 OWNER_OWR
    11 10:46:37 CET 2
    005
    ====================
    DEPLOYMENT UNITS
    ====================
    Audit ID Status Name Date Owner
    2707 READY Unit0 11-NOV-05 10:49:59 OWNER_OWR
    ====================
    EXECUTIONS
    ====================
    Er zijn geen rijen geselecteerd.
    owner_owr@ORKDEV01>
    Whilst a process flow is executing the last query will list executions, all of which have status BUSY:
    owner_owr@ORKDEV01> @list_requests
    ====================
    DEPLOYMENTS
    ====================
    Audit ID Status Name Date Owner
    2706 READY Deployment Fri Nov 11-NOV-05 10:49:59 OWNER_OWR
    11 10:46:37 CET 2
    005
    ====================
    DEPLOYMENT UNITS
    ====================
    Audit ID Status Name Date Owner
    2707 READY Unit0 11-NOV-05 10:49:59 OWNER_OWR
    ====================
    EXECUTIONS
    ====================
    Audit ID Status Name Date Owner
    394512 BUSY PF_ONB01 04-MEI-06 09:11:12 OWNER_OWX
    395328 BUSY ONB:FULL_PREPARE 04-MEI-06 09:11:55 OWNER_OWR
    395324 BUSY PF_ONB01:ONB 04-MEI-06 09:11:55 OWNER_OWR
    owner_owr@ORKDEV01>
    As an aside, I will attempt to get rid of the READY deployment and deployment unit using deactive_deployment.sql
    Now, if I attempt to use deactivate_execution.sql on any of the executions with status BUSY I get:
    owner_owr@ORKDEV01> @deactivate_execution
    Voer waarde voor 1 in: 396136
    declare
    FOUT in regel 1:
    .ORA-20003: The object is not in a valid state for the requested operation
    ORA-06512: at "OWNER_OWR.WB_RTI_EXCEPTIONS", line 94
    ORA-06512: at "OWNER_OWR.WB_RTI_EXECUTION", line 774
    ORA-06512: at "OWNER_OWR.WB_RT_EXECUTION", line 90
    ORA-06512: at line 4
    owner_owr@ORKDEV01>
    So all the seems to remain is to use abort_exec_request.sql
    This does the job, but the script itself hangs.
    I think it has to do with the l_stream_id not being checked again after the initial IF. I think it should probably be part of the loop condition as it is again reset in the do_acks inside the loop.
    Cheers & thanks,
    Colin

  • Connecting Oracle using SQL Plus in command window through LDAP settings?

    Hi
    Just like to know if it is possible to connect Oracle using SQL Plus with connection type as LDAP.
    Generally we connect to Oracle in cmd window as
    username/password@DBServiceName
    Similarly is it possible to connect Oracle using SQL plus cmd window using LDAP configuration settings.
    Eg:-
    If my LDAP server is oid:123:456
    Context is: cn=OracleContext,dc=abcdefgh,dc=com
    DBService is: xyz
    Regards
    jc

    Specify the -L command line option to SQL*Plus, i.e.:
    sqlplus -L username/password@db @blah.sql
    (this will prevent the second prompt for username/password if the initial login is unsuccessful for any reason, like an invalid password).

  • Explain plan results are different in SQL Developer than SQL Plus

    My Environment:
    SQL Developer 1.0.0.15.27
    Platform where SQL Developer is running: Windows XP 2002 SP2
    Oracle Database and Client 9.2.0.7
    Optimizer_mode: FIRST_ROWS
    I have the following SQL statement:
    SELECT a1.comp_id
    FROM temp_au_company a0, au_company a1
    WHERE :b2 = a0.temp_emp_code
    AND a0.comp_id = a1.comp_id
    AND a0.sls_terr_code != a1.sls_terr_code
    AND a1.last_mdfy_date > :b1
    When I run an Explain in SQL Developer I get the following access path (which is the one I really want):
    SELECT STATEMENT                          TABLE ACCESS(BY INDEX ROWID) FEDLINK.AU_COMPANY          NESTED LOOPS                                   INDEX(RANGE SCAN)
    FEDLINK.UX2_TEMP_AU_COMPANY
              INDEX(RANGE SCAN) FEDLINK.PX1_COMPANY
    However, when I execute the statement with sql_trace turned on and use tkprof to generate the actual access path, the statement executes as follows (which is WAY more expensive):
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 1 3.58 6.68 28136 29232 0 0
    total 3 3.58 6.69 28136 29232 0 0
    Misses in library cache during parse: 1
    Optimizer goal: FIRST_ROWS
    Parsing user id: 979 (FEDLINK) (recursive depth: 1)
    Rows Row Source Operation
    0 NESTED LOOPS
    0 TABLE ACCESS FULL AU_COMPANY
    0 INDEX RANGE SCAN UX2_TEMP_AU_COMPANY (object id 49783)
    Notice the FULL access of au_company.
    I understand that SQL Developer has nothing to do with why the statement executed the way it did, but why is the Explain in SQL Developer different than the actual execution plan?
    Added note....when I run the explain in SQL Plus it is the same as the actual execution. Here is the explain from SQL Plus:
    explain plan for SELECT a1.comp_id
    FROM temp_au_company a0, au_company a1
    WHERE '1' = a0.temp_emp_code
    AND a0.comp_id = a1.comp_id
    AND a0.sls_terr_code != a1.sls_terr_code
    AND a1.last_mdfy_date > '01-MAY-2006';
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 2 | 76 | 2597 |
    | 1 | NESTED LOOPS | | 2 | 76 | 2597 |
    | 2 | TABLE ACCESS FULL | AU_COMPANY | 2 | 42 | 2595 |
    | 3 | INDEX RANGE SCAN | UX2_TEMP_AU_COMPANY | 1 | 17 | 2
    Thanks,
    Brenda

    The explain is different (full scan of au_company in SQL Plus / index access in SQL Developer) even when I use variables in SQL Plus. Here is the output for SQL Plus using variables instead of literals:
    SQL> variable b1 varchar2
    SQL> variable b2 char
    SQL> explain plan for SELECT a1.comp_id
    2 FROM temp_au_company a0, au_company a1
    3 WHERE :b2 = a0.temp_emp_code
    4 AND a0.comp_id = a1.comp_id
    5 AND a0.sls_terr_code != a1.sls_terr_code
    6 AND a1.last_mdfy_date > :b1
    7 /
    Explained.
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 3184 | 118K| 2995 |
    | 1 | HASH JOIN | | 3184 | 118K| 2995 |
    | 2 | INDEX RANGE SCAN | UX2_TEMP_AU_COMPANY | 3187 | 54179 | 3 |
    | 3 | TABLE ACCESS FULL | AU_COMPANY | 24009 | 492K| 2983 |
    Any other ideas? They should be the same.
    Brenda

  • SQL*PLUS 32 Bit Client needed for Windows 64 Bit

    Hi,
    I have got a 64 Bit Windows OS and an Oracle 11.
    With 32 Bit Applications ( Crystal Reports) I can not run SQL NET Thick, SQL NET Thin and JDBC.
    Oracle 32 Bit Installation is Missing.
    Oracles "Instant Client Downloads for Microsoft Windows (32-bit)" will not do it.
    http://www.oracle.com/technetwork/topics/winsoft-085727.html
    What else to use ?
    Thank You
    Martin Sautter

    Martin.Sautter wrote:
    Hi,
    i used:
    instantclient-basic-nt-11.2.0.2.0.zip (32BitClient)
    instantclient-sqlplus-nt-11.2.0.2.0.zip.
    I did not find an "old", "classic" SQL*PLUs client.What does that mean exactly, classic client?
    Did you unzip the ic sqlplus .zip (the one listed) in the same dir as ic basic?
    After dezipping waht than ?
    No installer, nothing ...That's the beauty of Instant Client, just unzip or move a few files, set PATH if needed, and you have client libraries all "installed" and ready.
    >
    You can give advice ?Generally, required lib files are (n Windows) oci.dll, oraociicusN.dll or oraocieiN.dll (N= e.g. 11). Then for Sql*plus add orasqlplusicN.dll and the .exe from ic-sqlplus package.
    C:\Users\Test\Ora-IClite>dir
    Volume in drive C is OS
    Volume Serial Number is 6E8F-186A
    Directory of C:\Users\Test\Ora-IClite
    2011-12-16  09:30    <DIR>          .
    2011-12-16  09:30    <DIR>          ..
    2011-08-31  11:39                38 ldap.ora
    2011-07-30  12:21           683 008 oci.dll
    2011-07-30  12:21        44 153 856 oraociicus11.dll
    2011-07-30  12:21         1 501 696 Orasqlplusic11.dll
    2011-07-30  12:21           869 376 sqlplus.exe
    C:\Users\Test\Ora-IClite>.\sqlplus user@'localhost/xe'
    SQL*Plus: Release 11.2.0.2.0 Production on Fri Dec 16 09:34:13 2011
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Enter password:Edited by: orafad on Dec 16, 2011 9:35 AM

  • How to exit from SQL*Plus based on the return value of a SQL select stment?

    Hi
    I have a SQL script executed from SQL*Plus. I would like to know if SQL*Plus
    supports any kind of branching or exiting from script execution based on a
    returned value of a SQL select statement. I am on 9i.
    Regards,
    Tamas Szecsy

    in sqlplus, you have whenever
    ex:
    whenever sqlerror exit failure
    insert into ...
    -- if this fails, then you will be out
    insert into ...
    -- if this fails, then you will be out
    whenever sqlerror continue
    insert into ...
    -- if this fails, this continues
    insert into ...and you have PL/SQL
    declare x number;
    begin
    select count(*) into x from emp;
    if (x=14) then null; end if;
    end;
    /note that you can mix those in some case
    -- exit if there is no row in emp
    whenever sqlerror exit 1
    var dummy number
    exec select count(*) into :dummy from emp having count(*)!=0

  • Need to find out View definition by SQL PLUS

    Hi,
    I have a view VW_XXX, I want to know by which table this view has created. But need to use only SQL PLUS not any tool.
    Please let me know how cani see the full definitio of the view by SQL PLUS.
    Regs,
    brij

    Yes, it will work for both 9i and 10g. Just run the commands, and you will get the output.
    These are not "Dangerous Commands!!!"
    Regards
    Girish Sharma
    Edited by: Girish Sharma on Dec 26, 2011 5:19 PM
    To solve these issues Oracle9i has introduced the DBMS_METADATA package which can be used to retrieve object definitions as DDL or XML. There are a number of ways to use the API, but I suspect the majority of people will only ever use the following functions.
    Source:http://www.oracle-base.com/articles/9i/MetadataAPI.php
    Edited by: Girish Sharma on Dec 26, 2011 5:36 PM
    And here it is doc link :
    http://docs.oracle.com/cd/A91202_01/901_doc/appdev.901/a89852/d_meta11.htm#1024701

Maybe you are looking for

  • X-Fi Extreme Music Driver-Setup crashes under Win 7 64Bit

    Hi there, im using: -Windows 7 Home Premium 64Bit OEM -Asus P5WDH Deluxe -X-Fi Extreme Music Today i tried to install the Windows 7 drivers from the Creative support side, both the newest and the Beta one. But for both, when Setup is saying "Installi

  • Retrieve images from DB and attach them to email through javamail

    Hi, I'm trying to use javamail to send emails containing text and images (HTML mail), if I use a physical file in my computer as the image source and use FileDataSource everything works just fine. The problem is that the images in my app are stored i

  • Default open dwg files in Illustrator CS6

    I frequently use dwg files in Adobe Illustrator, so I set dwg files default program to Illustrator CS5. We recently upgraded to CS6 and when I opened it, it didn't update the default program. I tried using the "open with" menu. Illustrator CS6 doesn'

  • Raise event to trigger process chain

    I have to raise the event to trigger the process chain, but I don't have authorizations to sm64, se37 to triger form fm bp_event_raise, can any body please help me in triggering the process chain. [email protected]

  • Bridge mode setup

    I have an AX that I have connected to my wireless network for printer and airtunes. It is set to "join a wireless network" and works fine for this. I recently tried to plug a Dell computer into it's ethernet port to use it's internet. The Dell doesn'