Dbms_output.put_line problem..

We have created delete script to some 150 tables using cursors suppose we r deleting with some condition and use to display the output as
dbms_output.put_line('Rows Deleted in the table distb_store_promo is '||SQL%ROWCOUNT);
its shows error like it exceeds the limit.so we made setserver output off and running the query it works fine.is any other solution to overcome this..

> is any other solution to overcome this..
Yes. Do not use DBMS_OUTPUT. It is a very primitive API - useful for the odd debug display when debugging PL/SQL code. It should not be used for anything else. In fact, any DBMS_OUTPUT code in production PL/SQL requires serious reconsideration as those calls should be wrapped in a user PL/SQL proc.
The proper and correct method would be to create a log PL/SQL procedure to log messages into an Oracle table, using autonomous transactions.

Similar Messages

  • Problem in dbms_output.put_line boolean variable

    hello guys m practicing PL/SQL when i try to exicute below code i get following error:
    DECLARE
    I BOOLEAN:=TRUE;
    BEGIN
    dbms_output.put_line(i);
    END;
    error:
    Error starting at line 1 in command:
    DECLARE
    I BOOLEAN:=TRUE;
    BEGIN
    dbms_output.put_line(i);
    END;
    Error report:
    ORA-06550: line 4, column 1:
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    user13355933 wrote:
    hello guys m practicing PL/SQL when i try to exicute below code i get following error:
    DECLARE
    I BOOLEAN:=TRUE;
    BEGIN
    dbms_output.put_line(i);
    END;
    error:
    Error starting at line 1 in command:
    DECLARE
    I BOOLEAN:=TRUE;
    BEGIN
    dbms_output.put_line(i);
    END;
    Error report:
    ORA-06550: line 4, column 1:
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:DBMS_OUTPUT.PUT_LINE only accepts strings (VARCHAR2) datatype
    what exactly do you expect to see, if in fact it worked as desired?

  • BUG : DBMS_OUTPUT.put_line and tabs in sqldeveloper 1.2.1 - build 32.00

    Hi Guys.
    I upgraded from 1.2 and it appears that dbms_output.put_line is now broken.
    Consider the following:
    begin
       dbms_output.put_line('hello world');
    end;Process:
    1. Load SQL Developer
    2. Open a connection to DB
    3. Go to DBMS Output tab
    4. Enable server output
    5. Type in the code (as above)
    6. Hit F5
    The bug/new feature:
    After hitting f5, the DBMS Output tab switches to Script output where by I am presented with "anonymous block completed". In 1.2 (and previous versions) I used to see
    anonymous block completed
    hello world
    in the Script Output tab.
    Now I have to switch back to the DBMS Output tab. My problem with this is that there is far too much clicking. Why redirect me away from the tab that is going to actually display the script output only for me to have to click back into that tab? I just don't get it.
    Regards
    Kristian Jones
    http://kristianjones.blogspot.com
    Message was edited by:
    Kris Jones

    Hi,
    I also have the problem with the new Released.
    SQL Dev 1.2.0.29.98 upgraded with Check for Updates to 1.2.1.32.00
    On Windows XP.
    I did exactly as Kris Jones post, using Run Script
    but, it seems that my SQL Developer doesn't do anything.
    The progress bar is active like processing somthing, well, it processes forever.
    I tried to cancel the process (button Cancel), but the panel shows that it is still trying to cancel the process (all buttons are disabled except Cancel), although I can do another select (use CTRL + Enter because F9 doesn't work) within the same SQL Worksheet and the panel goes back to the active panel again.
    Well, there must be something wrong with the Run Script.
    Since any query or pl/sql block seems running forever if I use Run Script.
    I try on the SQL Developer 1.2.0.29.98 (luckily, I still keep the backup, just in case) and it shows the result as wanted.
    Is there something wrong within my SQL Developer 1.2.0.32.00?
    Or there is some patches which I should download?
    Is it another bug?
    Many thanks,
    Buntoro

  • Dbms_output.put_line in this query

    I want to put a  dbms_output.put_line in this query so it will give my the property_id is checking first in the PM_EXCHANGE_PROPERTY_PRIORITY
    (its part of a more bigger procedure)
    dbms_output.put_line('RESORT ID  one=> '||rci_dep_rec.resort_id);
            with    
                base_prop as (                                
                    select /*+ MATERIALIZE */ property_id, priority
                    from   PM_EXCHANGE_PROPERTY_PRIORITY ppp
                    where  ppp.exchange_affiliation = 'RCI'
                    and    ppp.master_property_id in (select ppp2.master_property_id
                                                                 from   P_PM_PROPERTY ppp1, PM_EXCHANGE_PROPERTY_PRIORITY ppp2
                                                                 where  ppp1.rci_id_number = rci_dep_rec.resort_id
                                                                 and    ppp1.property_active = 'Y'
                                                                and    ppp1.exchange_affiliation = ppp.exchange_affiliation
                                                                 and    ppp2.property_id = ppp1.property_id)
                    union
                    select property_id, 99999
                    from   P_PM_PROPERTY ppp
                    where  ppp.rci_id_number = rci_dep_rec.resort_id
                    and    ppp.property_active = 'Y'
                    and    not exists (select 1 from PM_EXCHANGE_PROPERTY_PRIORITY ppp1 where ppp1.property_id = ppp.property_id)
                    order by 2
            select pput.pm_unit_type_id
          bulk collect into pm_unit_type_ids
           from   P_PM_UNIT_TYPE pput, S_PM_EXCHANGE_MAPPING spem, base_prop bp
           where  spem.exchange_affiliation = 'RCI'
           and    spem.resortcode = rci_dep_rec.resort_id
           and    ((spem.unitnumber = rci_dep_rec.unit_no and rci_dep_rec.resv_type = 'WEEKS')
                  or  (spem.unitnumber = rci_dep_rec.unit_type and rci_dep_rec.resv_type = 'POINTS'))
           and    rci_dep_rec.start_dt between spem.begin_date and spem.end_date
           and    pput.property_id = spem.property_id
           and    pput.pm_unit_type_active = 'Y'
           and    instr(spem.unittypecode, pput.pm_unit_type) > 0
           and    spem.property_id = bp.property_id
           ORDER BY bp.priority,pput.pm_unit_type_priority;
        end;
         dbms_output.put_line('RESORT ID => '||rci_dep_rec.resort_id);
    but im not sure where i can put ii, i have it to give my the resort_id
    i want to know which one the property_id is checking first, there is only two , one has a higher priority
    for example if i hardcoded it
    select /*+ MATERIALIZE */ property_id, priority
                    from   PM_EXCHANGE_PROPERTY_PRIORITY ppp
                    where  ppp.exchange_affiliation = 'EZY'
                    and    ppp.master_property_id in (select ppp2.master_property_id
                                                                 from   P_PM_PROPERTY ppp1, PM_EXCHANGE_PROPERTY_PRIORITY ppp2
                                                                 where  ppp1.rci_id_number = '8789'
                                                                 and    ppp1.property_active = 'Y'
                                                                and    ppp1.exchange_affiliation = 'RCI,II'
                                                                 and    ppp2.property_id = 'VDG')
            union
                    select property_id, 99999
                    from   P_PM_PROPERTY ppp
                    where  ppp.rci_id_number ='8789'
                    and    ppp.property_active = 'Y'
                    and    not exists (select 1 from PM_EXCHANGE_PROPERTY_PRIORITY ppp1 where ppp1.property_id = 'VDG')
                    order by 2 
    i would get this
       PROPERTY_ID|PRIORITY
        VDR         |1
        VDG         |2
    thanks for help or tips

    Hi Nat,
    Your question is not very clear (other wise you would have an answer from this forum by now).
    What you are showing is an SQL (which is part of bigger picture). Bigger picture is important. Is it a PL/SQL procedure or function?
    DBMS_OUTPUT.PUTLINE is a procedures call, that can be called in PL/SQL. What you have shown us is a SQL from within the PL/SQL.
    Please do NOT paste a larger piece of code.
    The place where you ave shown the DBMSOUTPUT.PUT_LINE seems correct.
    However,
    You said
    but im not sure where i can put ii, i have it to give my the resort_id
    i want to know which one the property_id is checking first, there is only two , one has a higher priority
    The sequence in which rows are processed does NOT matter in SQL and there is no such thing as "checking first". ALL the rows that satisfy the criteria. Since you have ORDER BY the rows will be returned in that order.
    Please explain what problem you are trying to solve.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    Hope this helps.
    vr,
    Sudhakar

  • DBMS_OUTPUT.PUT_LINE question

    Hi there,
    I am having problems with following statement in SQL*PLUS, for some reason the text that I have declared is not appearing instad I am only getting the "Enter Value for" question.
    Here is the code I have created:
    SQL> DECLARE
    2 START_DATE date;
    3 Y varchar2(300);
    4 BEGIN
    5 SELECT 'Enter the start date of the Report MM/DD/YYY enclosed in Single quotes' INTO
    Y FROM DUAL;
    6 DBMS_OUTPUT.PUT_LINE(Y);
    7 START_DATE := &START_DATE;
    8 END;
    9 /
    Here is the result:
    Geben Sie einen Wert für start_date ein:
    What am I doing wrong?
    Regards
    RobH

    Maybe this:
    SQL> SET serverout on
    old: DECLARE
       start_date   DATE;
       y            VARCHAR2 (300);
    BEGIN
       SELECT 'Enter the start date of the Report MM/DD/YYY enclosed in Single quotes'
         INTO y
         FROM DUAL;
       DBMS_OUTPUT.put_line (y);
       start_date := TO_DATE (&start_date, 'MM/DD/YYYY');
       DBMS_OUTPUT.put_line ('You entered: ' || start_date);
    END;
    new: DECLARE
       start_date   DATE;
       y            VARCHAR2 (300);
    BEGIN
       SELECT 'Enter the start date of the Report MM/DD/YYY enclosed in Single quotes'
         INTO y
         FROM DUAL;
       DBMS_OUTPUT.put_line (y);
       start_date := TO_DATE ('02/01/2007', 'MM/DD/YYYY');
       DBMS_OUTPUT.put_line ('You entered: ' || start_date);
    END;
    SQL> DECLARE
       start_date   DATE;
       y            VARCHAR2 (300);
    BEGIN
       SELECT 'Enter the start date of the Report MM/DD/YYY enclosed in Single quotes'
         INTO y
         FROM DUAL;
       DBMS_OUTPUT.put_line (y);
       start_date := TO_DATE ('02/01/2007', 'MM/DD/YYYY');
       DBMS_OUTPUT.put_line ('You entered: ' || start_date);
    END;
    Enter the start date of the Report MM/DD/YYY enclosed in Single quotes
    You entered: 01-FEB-07
    PL/SQL procedure successfully completed.

  • Buffer overflow in dbms_output.put_line

    If I code like this, an error happens. Do you know how can I
    resolve this problem?
    for i in 1..500
    loop
    dbms_output.put_line('Hello World');
    end loop;
    ORA-20000: ORU-10027: buffer overflow, limit of 2000 bytes
    Thx

    If you are running the PL/SQL block within SQL*Plus, use the SIZE
    option to the SET SERVEROUTPUT command:
    set serveroutput on size 7000
    show serveroutput
    begin
    for i in 1..500
    loop
    dbms_output.put_line('Hello World');
    end loop;
    end;
    -- CJ

  • Enhancement possiblity in dbms_output.put_line..!

    hey,
    I am having a strange client requirement.
    I am using dbms_output.put_line for output.But I was getting buffer flow error.
    Then i used utl_file to write log into a file but when due to some permission problem for FTP log file from unix directory to computer I can't use utl_file.
    Is there any possibility in dbms_output that if buffer flow error raise then
    2nd log file generate with new name and remaining log data written in new log file.
    My code in generally is below..
    SET BUFFER 1000000
    SET SERVEROUTPUT ON
    spool LMG_DBmigration_CP_DATA_Log.log
    Declare
    begin
    stmnts for DBMS_OUTPUT.PUT_LINE;
    stmnts for DBMS_OUTPUT.PUT_LINE;
    stmnts for DBMS_OUTPUT.PUT_LINE;
    stmnts for DBMS_OUTPUT.PUT_LINE;
    end;
    spool off
    exit;
    any idea ...?
    rgds,
    pc

    hey Saubhik,thanks for your answer.
    In my code,SET BUFFER 1000000 in 1st line.
    Is there any impact of this line on log buffering error?
    I am running my code via batch file..
    SET BUFFER 1000000
    SET SERVEROUTPUT ON
    spool LMG_Log.log
    Declare
    begin
    stmnts for DBMS_OUTPUT.PUT_LINE;
    stmnts for DBMS_OUTPUT.PUT_LINE;
    stmnts for DBMS_OUTPUT.PUT_LINE;
    stmnts for DBMS_OUTPUT.PUT_LINE;
    end;
    spool off
    exit;

  • How to spool DBMS_OUTPUT.PUT_LINE from SqlPlus?

    Hi,
    i have a stored procedure test:
    procedure test is
    begin
    dbms_output.put_line('Test');
    dbms_output.put_line('Test2');
    dbms_output.put_line('Test3');
    dbms_output.put_line('Test4');
    dbms_output.put_line('Test5');
    end;
    I start the stored procedure out of sqlplus:
    spool C:\Temp\test.spl;
    exec test;
    commit;
    spool off;
    exit;
    My problem is no Test or Test2 appeared in the spool file.
    What should i do?
    thanks a lot

    create or replace procedure hmm as
    begin
    dbms_output.put_line('Test1');
    dbms_output.put_line('Test2');
    dbms_output.put_line('Test3');
    dbms_output.put_line('Test4');
    dbms_output.put_line('Test5');
    end;
    spool C:\Temp\test.spl;
    exec hmm;
    spool off;File content is:
    Test1
    Test2
    Test3
    Test4
    Test5
    PL/SQL procedure successfully completed.

  • DBMS_OUTPUT.put_line  buffer overflow

    Hi all
    I am taking some values into a cursor and updating a table with those values, and catching the exception in the exception block
    EXCEPTION
    WHEN OTHERS
    THEN
    sqlm := SUBSTR (SQLERRM, 1, 100);
    sqlc := SQLCODE;
    DBMS_OUTPUT.put_line ( 'Error Code : '
    || sqlc
    || ' Error Message : '
    || sqlm
    || ' : aaa:: '
    || aaa_rec.recid
    Here the problem is the data which i am updating its huge(5 million records), i am getting the error for the exception block as Buffer overflow( After I set it to the buffer value to maximum i.e 1000000), how can i avoid this problem, i am not supposed to use utl file package, Can u be a little brief in ur answers
    Thnks in advance

    1000000 is not the maximum size:
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_output.htm#CIHEGBBF
    There used to be a maximum setting of 1000000 (in practice nearer 600K) in earlier versions of Oracle. Perhaps you are using one of those and forgot to mention it?
    In any case, why are you using a debugging tool for error handling?

  • Dbms_output.put_line prints a varchar2(32767) variable partially.

    Please help if anyone knows.
    I have an anonymous block that declares a variable as below:
    v_return_code varchar2(32767);
    I am appending characters that I am building in the begin end block to this variable and at the end printing it out using dbms_output
    dbms_output.put_line(v_return_code);
    I observe that the output is generated partially when I ran the block through PL/SQL developer SQL window.
    My code appends a new line char chr(10) after each new value is appended to the variable.
    I have the below settiing in the output window
    buffer size: 2000000
    Can someone please help why it prints the output partially?
    Thanks in advance.
    Girish

    Hi Frank,
    Thanks for your reply.
    I figured out that some other developer in the team had same problem before and he had then written a library function to tokenise the variable into 255 chars and then dbms_output it. So I am good now.
    Thanks for coming by and replying though.
    Regards,
    Girish

  • DBMS_OUTPUT.PUT_LINE doesn't work in Reports

    Version 1.1.2.25 Build Main 25.97
    I've tried to create a Report using the PL/SQL-DBMS_OUTPUT option and it just sends out a sinle line of text without any line throws. Copy the block of code and run it as a script and it works fine.
    Anybody else come across this problem?

    Here's the PL/SQL code for the Report....
    declare
    vowner VARCHAR2(30);
    vindex VARCHAR2(30);
    vtable VARCHAR2(30);
    CURSOR cIndex
    IS
    select OWNER, INDEX_NAME, TABLE_NAME
    from dba_indexes;
    begin
    dbms_output.enable(1000000);
    open cIndex;
    LOOP
    FETCH cIndex INTO vowner, vindex, vtable;
    EXIT WHEN cIndex%NOTFOUND;
    if (vowner = :OWNER) and (vTable like :TABLENAME)
    then
    dbms_output.put_line('alter index ' || vowner || '.' || vindex || ' nomonitoring usage;');
    end if;
    end loop;
    close cIndex;
    end;
    I've tested by setting the bind variables :OWNER to a schema and :TABLENAME to '%' to return all indexes owner by the schema.
    As you can see, I don't use \n.
    This works fine when run as a script in SQL Developer (each put_line coming out on a separate line) but not as a report.

  • I need help with DBMS_OUTPUT.PUT_LINE

    I am a student new to PL/SQL.  I am using SQL developer 3.2.20.9.  For several weeks DBMS_OUTPUT.PUT_LINE worked fine.  Now I cannot see it.  I have tried adding DBMS_OUTPUT.enabled(1000000); to my code to no avail.  When it did work the window was on my desktop, not locked to the bottom of the PL/SQL page.  I may have hit the x to close it, now I cannot get it back.  Yes, I selected "view" "DBMS Output".  I have had this problem for over a week.  Can someone help me?
    Tom

    user10199456 wrote:
    I am a student new to PL/SQL.  I am using SQL developer 3.2.20.9.  For several weeks DBMS_OUTPUT.PUT_LINE worked fine.  Now I cannot see it.  I have tried adding DBMS_OUTPUT.enabled(1000000); to my code to no avail.  When it did work the window was on my desktop, not locked to the bottom of the PL/SQL page.  I may have hit the x to close it, now I cannot get it back.  Yes, I selected "view" "DBMS Output".  I have had this problem for over a week.  Can someone help me?
    Tom
    Then as new student - DO NOT USE DBMS_OUTPUT!!
    It is the WRONG interface to use to display server data on a client. It does not write to a client display. The majority of times it is abused, as there is a misunderstanding of what it is and how it works.
    See Re: Can't get DECLARE/BEGIN to compile
    You are GROSSLY mistaken if you think that DBMS_OUTPUT plays any role in getting server data to render on the client.

  • DBMS_OUTPUT.PUT_LINE multi records from PL/SQL procedure to Java web page.

    Hello
    I will explain the scenario:
    In our java web page, we are using three text boxes to enter "Part number,Description and Aircraft type". Every time the user no need to enter all these data. The person can enter any combination of data or only one text box. Actually the output data corresponding to this input entries is from five Oracle table. If we are using a single query to take data from all the five tables, the database will hang. So I written a procedure "SEARCH1",this will accept any combination of values (for empty values we need to pass NULL to this procedure) and output data from all the five tables. When I executing this procedure in SQL editor, the execution is very fast and giving exact result. I used "dbms_output.put_line" clause for outputing multiple records in my procedure. The output variables are "Serial No, part Number, Description, Aircraft type,Part No1,Part No2,Part No3,Part No4". I want to use the same procedure "SEARCH1" for outputing data in java web page.The passing argument I can take from the text box provided in java web page. I am using jdbc thin driver to connect our java web page to Oracle 9i database.
    Note1 : If any combination of search item not available, in procedure itself I am outputing a message like "Part Number not found". Here I am using four words ("Part" is the first word,"Number" is the second,"Not" s the third, and "found" is the fourth) for outputing this message.Is it necessary to equalise number of words I am using here to the record outputing eight variable?
    Our current development work is stopped because of this issue. So any one familier in this field,plese help me to solve our issue by giving the sample code for the same scenario.
    My Email-id is : [email protected]
    I will expect yor early mail.
    With thanks
    Pramod kumar.

    Hello Avi,
    I am trying to solve this issue by using objects. But the following part of code also throwing some warning like "PLS-00302: component must be declared". Plese cross check my code and help me to solve this issue.
    drop type rectab;
    create or replace type rectype as object(PartNo varchar2(30),Description varchar2(150),AIrcraft_type varchar2(15),status_IPC varchar2(30),status_ELOG varchar2(30),status_SUPCAT varchar2(30),status_AIRODWH varchar2(30));
    create or replace type rectab as table of rectype;
    create or replace package ioStructArray as
    procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab);
    end ioStructArray;
    create or replace package body ioStructArray as
    procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab) is
    mdescription varchar2(150);
    mpartnum varchar2(30);
    mpno varchar2(30);
    mdes varchar2(150);
    mair varchar2(15);
    mstat varchar2(1);
    cursor c1 is select partnum,description,aircraft_type from master_catalog where partnum=mpno and aircraft_type=mair and description like ltrim(rtrim(mdes))||'%';
    cursor c2 is select partnum from ipc_master where partnum=mpartnum;
    cursor c3 is select partnum from fedlog_data where partnum=mpartnum;
    cursor c4 is select partnum from superparts where partnum=mpartnum;
    cursor c5 is select part_no from supplier_catalog where part_no=mpartnum;
    mpno1 varchar2(30);
    mpno2 varchar2(30);
    mpno3 varchar2(30);
    mpno4 varchar2(30);
    mpno5 varchar2(30);
    maircraft_type varchar2(15);
    mstat1 varchar2(30);
    mstat2 varchar2(30);
    mstat3 varchar2(30);
    mstat4 varchar2(30);
    begin
    mstat:='N';
    mpno:=pno;
    mdes:=pdes;
    mair:=air;
    if mpno is not null and mdes is not null and mair is not null then
    begin
    mstat:='N';
    mpno:=pno;
    mdes:=pdes;
    mair:=air;
    for i in c1 loop
    mstat:='N';
    mstat1:='N';
    mstat2:='N';
    mstat3:='N';
    mstat4:='N';
    mpno1:=i.partnum;
    mpartnum:=i.partnum;
    mdescription:=i.description;
    maircraft_type:=i.aircraft_type;
    for j in c2 loop
    mpno2:=j.partnum;
    end loop;
    for k in c3 loop
    mpno3:=k.partnum;
    end loop;
    for l in c4 loop
    mpno4:=l.partnum;
    end loop;
    for m in c5 loop
    mpno5:=m.part_no;
    end loop;
    if mpno2=mpartnum then
    mstat1:=mpno2;
    end if;
    if mpno3=mpartnum then
    mstat2:=mpno3;
    end if;
    if mpno4=mpartnum then
    mstat3:=mpno4;
    end if;
    if mpno5=mpartnum then
    mstat4:=mpno5;
    end if;
    if mpno1=mpartnum then
    mstat:='Y';
    orec.PartNo:=mpno1;
    orec.Description:=mdescription;
    orec.AIrcraft_type:=maircraft_type;
    orec.status_IPC:=mstat1;
    orec.status_ELOG:=mstat2;
    orec.status_SUPCAT:=mstat3;
    orec.STATUS_AIRODWH:=status_AIRODWH;
    end if;
    end loop;
    end;
    end if;
    end testsch2;
    end ioStructArray;
    Expecting your early reply.
    With thanks
    Pramod kumar.

  • Dbms_output.put_line not printing in inner for loop using a parameter

    I cannot get the inner loop to print output. I can run both loops independent (hardcoding a value for the inner loop) Any help is apprecicated... Listed is the code
    set serveroutput on
    DECLARE
    cursor ACCNO_CUR is
    select accession_number from didb_studies where insert_time > to_date('02-JUN-12');
    cursor PATH_CUR (p1_accno VARCHAR2) is
    select distinct l.FILE_SYSTEM || '/' ||
    substr(LPAD(s.PATIENT_DB_UID, 12, '0'),1,3) || '/' ||
    substr(LPAD(s.PATIENT_DB_UID, 12, '0'),4,3) || '/' ||
    substr(LPAD(s.PATIENT_DB_UID, 12, '0'),7,3) || '/' ||
    substr(LPAD(s.PATIENT_DB_UID, 12, '0'),10,3) || '/' ||
    s.STUDY_DB_UID || '/' || i.SERIES_DB_UID || '/'||
    i.RAW_IMAGE_DB_UID || '.img' as FULLY_QUALIFIED_IMAGE_NAME
    , l.image_size
    , i.image_need_backup
    , i.sop_class_uid
    from medistore.didb_studies s
    , medistore.didb_raw_images_table i
    , medistore.didb_image_locations l
    where s.accession_number = 'p1_accno'
    and s.study_db_uid = i.study_db_uid
    and i.raw_image_db_uid = l.raw_image_db_uid
    and l.file_system is not null and INSTR(l.file_system, '.img') = 0
    UNION
    select distinct(l.FILE_SYSTEM) as FULLY_QUALIFIED_IMAGE_NAME
    , l.image_size
    , i.image_need_backup
    , i.sop_class_uid
    from medistore.didb_studies s, medistore.didb_raw_images_table i,
    medistore.didb_image_locations l
    where s.accession_number = 'p1_accno'
    and s.study_db_uid = i.study_db_uid
    and i.raw_image_db_uid = l.raw_image_db_uid
    and l.file_system is not null and INSTR(l.file_system, '.img') > 0
    order by 1;
    BEGIN
    FOR accno_rec in accno_cur LOOP
    DBMS_OUTPUT.put_line('ACCESSION_NUMBER is: '|| accno_rec.accession_number);
    FOR path_rec in path_cur(accno_rec.accession_number) LOOP
    DBMS_OUTPUT.put_line('Inner loop accession_number is :'||accno_rec.accession_number);
    DBMS_OUTPUT.put_line('Full path is : ' || path_rec.FULLY_QUALIFIED_IMAGE_NAME);
    END LOOP;
    END LOOP;
    END;

    Maybe
    DECLARE
      cursor ACCNO_CUR is
        select accession_number
          from didb_studies
         where insert_time > to_date('02-JUN-12');
      cursor PATH_CUR (p1_accno VARCHAR2) is
        select distinct
               l.FILE_SYSTEM || '/' ||
               substr(LPAD(s.PATIENT_DB_UID, 12, '0'),1,3) || '/' ||
               substr(LPAD(s.PATIENT_DB_UID, 12, '0'),4,3) || '/' ||
               substr(LPAD(s.PATIENT_DB_UID, 12, '0'),7,3) || '/' ||
               substr(LPAD(s.PATIENT_DB_UID, 12, '0'),10,3) || '/' ||
               s.STUDY_DB_UID || '/' || i.SERIES_DB_UID || '/'||
               i.RAW_IMAGE_DB_UID || '.img' as FULLY_QUALIFIED_IMAGE_NAME,
               l.image_size,
               i.image_need_backup,
               i.sop_class_uid
          from medistore.didb_studies s,
               medistore.didb_raw_images_table i,
               medistore.didb_image_locations l
         where s.accession_number = to_number(p1_accno) /* to_char(s.accession_number) = p1_accno */
           and s.study_db_uid = i.study_db_uid
           and i.raw_image_db_uid = l.raw_image_db_uid
           and l.file_system is not null
           and INSTR(l.file_system, '.img') = 0
        UNION
        select distinct
               l.FILE_SYSTEM as FULLY_QUALIFIED_IMAGE_NAME,
               l.image_size,
               i.image_need_backup,
               i.sop_class_uid
          from medistore.didb_studies s,
               medistore.didb_raw_images_table i,
               medistore.didb_image_locations l
         where s.accession_number = to_number(p1_accno) /* to_char(s.accession_number) = p1_accno */
           and s.study_db_uid = i.study_db_uid
           and i.raw_image_db_uid = l.raw_image_db_uid
           and l.file_system is not null and INSTR(l.file_system, '.img') > 0
         order by 1;
    BEGIN
      FOR accno_rec in accno_cur
      LOOP
        DBMS_OUTPUT.put_line('ACCESSION_NUMBER is: '|| accno_rec.accession_number);
        FOR path_rec in path_cur(accno_rec.accession_number)
        LOOP
          DBMS_OUTPUT.put_line('Inner loop accession_number is :'||accno_rec.accession_number);
          DBMS_OUTPUT.put_line('Full path is : ' || path_rec.FULLY_QUALIFIED_IMAGE_NAME);
        END LOOP;
      END LOOP;
    END;Regards
    Etbin

  • How to Populate a table with DBMS_OUTPUT.put_line

    Hey Guys, it's Xev.
    Please only pleasant people reply to this.
    I have a PL/SQL Program that searches for strings and then at the end of it it prints out to DBMS_OUTPUT.put_line.
    I have the owner, the table_name, the column name and the count, then it goes to DBMS_OUTPUT.put_line
    What i want to do, is take the results of DBMS_OUTPUT.put_line and insert it into a table.
    Here is the script I am talking about, as you can see it's simple, yet for me it works.  I want to take the results of this and insert it into a table. How can i do  that??
    set serveroutput on size unlimited
    execute DBMS_OUTPUT.ENABLE (buffer_size => NULL);
    DECLARE
       FND_GOVIDS       INTEGER;
       BEGIN
    FOR t  IN (SELECT owner, table_name, column_name
                FROM all_tab_columns
                WHERE owner = upper('&SCHEMA_NAME'))
    LOOP
      BEGIN
        EXECUTE IMMEDIATE 'with a as ( select  case when REGEXP_LIKE(' || t.column_name ||
    --This searches for 8 Alpha Digits
    ',''^([[:alpha:]]{2}|[[:alpha:]]{4})?[ ]?[0-9]{8}[ ]?([[:alpha:]]{2}|[[:alpha:]]{4})?$'')
    then ''Match Found''
    else ''No Match Found'' end as output from ' || t.owner || '.' || t.table_name || ')
    select count(*) from a where a.output=''Match Found'' '
          INTO FND_GOVIDS ;
    IF FND_GOVIDS > 0         THEN
    DBMS_OUTPUT.put_line (
    t.owner
    || '.'
    || t.table_name
    || ' '
    || t.column_name
    || ' '
    || FND_GOVIDS);
      END IF;
      EXCEPTION
        WHEN OTHERS
          THEN
          DBMS_OUTPUT.put_line (
          'Generic Error '
          || t.column_name
          || ' from '
          || t.owner
          || '.'
          || t.table_name);      
          END;
       END LOOP;
    END;

    Nope, the table is empty....
    But it ran without error??!?! Wait a minute, I think i have to commit right? Since it's not straight sql, ok, that's what I am going to try..
    set serveroutput on size unlimited
    execute DBMS_OUTPUT.ENABLE (buffer_size => NULL);
    DECLARE
       FND_GOVIDS       INTEGER;
       BEGIN
    FOR t  IN (SELECT owner, table_name, column_name
                FROM all_tab_columns
                WHERE owner = upper('&SCHEMA_NAME'))
    LOOP
      BEGIN
        EXECUTE IMMEDIATE 'with a as ( select  case when REGEXP_LIKE(' || t.column_name ||
    --This searches for 6 Alpha Digits
    ',''^([[:alpha:]]|[[:alpha:]]{3})[0-9]{6}$'')
    then ''Match Found''
    else ''No Match Found'' end as output from ' || t.owner || '.' || t.table_name || ')
    select count(*) from a where a.output=''Match Found'' '
          INTO FND_GOVIDS ;
    /*Table insert for resulting */
    IF FND_GOVIDS > 0 THEN
    INSERT INTO "SMEG"."DYNAMIC_COUNTS" (T_OWNER, T_TABLE_NAME, T_COLUMN_NAME, FND_GOVIDS) VALUES
    ('t.owner','t.table_name','t.column_name','FND_GOVIDS');
      END IF;
    /* dbms_output */
    IF FND_GOVIDS > 0 THEN
    DBMS_OUTPUT.put_line (t.owner || '.' || t.table_name || ' ' || t.column_name || ' ' || FND_GOVIDS);
      END IF;
    /* Exception Handeling */
      EXCEPTION
        WHEN OTHERS
          THEN
          DBMS_OUTPUT.put_line (
          'Generic Error '
          || t.column_name
          || ' from '
          || t.owner
          || '.'
          || t.table_name);     
          END;
       END LOOP;
    END;

Maybe you are looking for

  • Mail acting weird and lost all emails yesterday

    I live in Australia using the Telstra Bigpond internet services. Bigpond is a POP server (POP3 I think) and is in the process of migrating customers to the IMAP system. I am on the POP system. I successfully, I thought, installed the Mavericks update

  • CS4: exporting text

    For CS3 I had a script that exported text from frames I'd put a scriptlabel on. The default CS4 text export function nor the text export sample script that comes with CS4 don't do the trick. Does anyone know if there is a similar script for CS4 avail

  • Nokia Lumia 925 No Display After Switch On

    When I switch my Nokia Lumia 925 off and then turn it back on again I get no display. I know its on because I can press the on/off/ button and the soft keys will vibrate when touched. I can even take a picture using the camera key, confirmed with a f

  • Bugcheck error Ox0000007f

    I was greeted with a bugcheck error this morning and my computer was rebooting. Event viewer shows a recovery from a bugcheck. The Bugcheck error: "computer has rebooted from a bugcheck. The bugcheck was: Ox0000007f (00000000000000008, 0x000000008005

  • Creating postscript files for high res printing

    I am having a lot of trouble between Adobe InDesign and Adobe Professional making a postscript file that I can send to a direct-to-plate rip. I can't get the halftone images to come out as halftones. All of the pictures come out solid. This NEVER hap