How to check a XMLTYPE table for corrupted (not invalid!) XML records ??

Hello,
I'd like to get help on the following issue, please. I need to check the XML data in a number of tables with XMLTYPE data type. Some of the data is corrupted but in terms not that the XML format is wrong but there is no XML at all in the fields but just only, for example, control characters (no tags, no anything, just corrupted data).
So, I have made a PL/SQL procedure cursor to get all the tables from a list, and then another cursor inside to browse each table for corrupted records. But can you help me how to check this? Any of the XML functions like for example: XMLIsValid, isFragment(), getrootelement(), etc. return to me an Oracle error "ORA-31011 XML parsing failed" and the procedure gets stuck on the first found bad record. But I need to continue and check all of them. Is it possible to get the ORA-31011 error with EXCEPTION, write to a logging table the corrupted record ID, and then continue?
Here is my simple procedure:
CREATE OR REPLACE PROCEDURE CHECKXML (v_schema in VARCHAR2)
IS
     v_Message     VARCHAR2(254);
     sql_stmt1     VARCHAR2(1000);
     sql_stmt2     VARCHAR2(1000);
     c1           SYS_REFCURSOR;
     c2           SYS_REFCURSOR;
     cur_tab          varchar2(100);
     cur_appl     varchar2(100);
     cur_rec     varchar2(200);
     valid_flag     number;
     criteria     VARCHAR2(20);
     tab1          VARCHAR2(20);
     tab2          VARCHAR2(20);
BEGIN
     criteria := 'XMLTYPE';
     sql_stmt1 := 'select id, path from ' || v_schema || '.stubfiles where type=:bcriteria';
     open c1 for sql_stmt1 using criteria;
     loop
     begin
          fetch c1 into cur_tab, cur_appl;
          exit when c1%notfound;
               insert into system.log_table values (sysdate, v_schema, 'next table', 'id ' || cur_tab, 'appl ' || cur_appl, '');
          sql_stmt2 := 'select t.recid, t.xmlrecord.isFragment() from ' || v_schema || '.' || cur_tab || ' t';
          open c2 for sql_stmt2;
          loop
          begin
          fetch c2 into cur_rec, valid_flag;
               exit when c2%notfound;
               insert into system.log_table values (sysdate, v_Schema, 'next record', 'id ' || cur_tab, 'recid ' || cur_rec, 'valid ' || valid_flag);
               commit;
          EXCEPTION
               WHEN OTHERS THEN v_Message := sqlerrm;
               dbms_output.put_line('Error for ' || cur_tab);
               dbms_output.put_line('-' || v_Message);
               insert into system.log_table values (sysdate, cur_tab, 'id err' || c_Row.ID,'appl err' || c_Row.path, v_Message,'');
          end;
          end loop;
          close c2;
          commit;
     end;
     end loop;
     close c1;
     commit;
END CHECKXML;
Thanks in advance
Evgeni

Hi
Why do you use a GTT? Just keep your xml in memory...
HTH
Chris

Similar Messages

  • How to check the Statistics generated for a table through DBMS_STATS.

    Hi,
    How to check the statistics generated for a Table through DBMS_STATS.GATHER_TABLE_STATS procedure ?
    Please let me know.
    Thanks !
    Regards,
    Rajasekhar

    Rajasekhar wrote:
    Hi,
    How to check the statistics generated for a Table through DBMS_STATS.GATHER_TABLE_STATS procedure ?
    Please let me know.
    Thanks !
    Regards,
    Rajasekharquery ALL_TABLES

  • URGENT: How to find out the Tables for Routines  in BW.

    Hi BW Gurus,
    How to find out the Tables for Routines  in BW.
    I have this routine id <b>45XFAEI7LKIFIRDUKQG127YWW</b> and it is in inactive state and i want to activate it.
    thanks in advance,
    points will be rewarded.
    Regards,
    Maruthi.

    Hi Maruthi,
    Check table RSUPDROUT using the routine id as input for the field CODEID. You will get the technical name of the update rule.
    Cheers,
    Praveen.

  • How to Index a XMLTYPE table

    I am using a xmltype table for parsing the xml file and then storing the tag values into someother tables.
    The table syntax
    CREATE GLOBAL TEMPORARY TABLE ATLAS.XML_PROCESS
    XML_DATA XMLTYPE
    ON COMMIT DELETE ROWS;
    At a time i will parse only one xml file. And them the content will be deleted and then i will parse another xml file.
    The parsing of the xml file is taking much CPU time and also it is taking more FETCH time. ( i have seen from the trace file)
    Do i need to create any index on this table?
    Please suggest me how can i imrove the performence.
    Thanks

    Hi
    Why do you use a GTT? Just keep your xml in memory...
    HTH
    Chris

  • How to find R/3 table  for FI and PS Datasources

    Hi,
    Can anyone tell me that how can we find SAP tables for FI and PS datasources in BI. Please provide information as it is urgent. Points will be assigned
    Thanks
    Shanthi

    Hi,
    To find DS assigned to a table.
    How to find the Datasources for the given table names ?
    How to find the Datasources for the given table names ?
    To find Tables assigned to a DS.
    USe Extractor Checker RSA3. Execute ST05 (activating SQL Trace), switch on the trace and execute the extractor checker. Once the extractor checker presents the results
    switch off trace. The clcik on Display trace and you will see all the tables that were hit by the extractor checker to
    retrieve data and present it to you.
    Note: Set the break point in the Extractor Function module.
    View the ST05 Extended Trace list. The Object name shows the Tables accessed.
    Thanks,
    JituK

  • How to check the tran code for specific activity.

    Hello friends ,
    could you please let me know how to check the tran code for specific activity . AS in table , i can check , what transaction does what ? But now i need to check the transaction for specific activity .
    E.g , For Administrator workbench , there is transcation like RSA1 .
    thanks in advance
    Regards

    Hi,
    try the TSTC table with SE16.
    Hope it helps,
    MG

  • How to  check whether any table(s) required to shrink on database

    Hi,
    How to check whether any table(s) required to shrink on database
    Regards,
    Venkat

    Venkat wrote:
    Hi,
    Thi is Oracle 10g. How to use this?. I am not using toad etc...
    I am on SQL prompt.
    Regards,
    Venkat.
    for starter
    Generate Script to Shrink Segment Advisor Recommendations [ID 1171054.1]
    Automatic Segment Advisor in Oracle 10g Release 2 (10.2) [ID 314112.1]
    10g and above SEGMENT ADVISOR [ID 242736.1]
    Cheers

  • How may I include the table for audit?

    How may I include global tables for audit? We are going to control changes.
    Do you know which table contained the list with it?
    Thanks

    Hi Marina,
    The following is the information on table log:
    You must start the SAP system with the rec/client parameter. This parameter specifies whether the SAP system logs changes to table data in all clients or only in specific clients. The parameter can have
    the following values:
    - rec/client = ALL logs all clients
    - rec/client = 000 [,...] logs the specified clients
    - rec/client = OFF turns logging off
    In the technical settings (use transaction SE13), set the Log data changes flag for those tables that you want to have logged.
    If both of these conditions are met, the database logs table changes in the DBTABPRT table. You can also check at transaction SCU3.
    Use the RSTBHIST report to obtain a list of those tables that are currently set to be logged.
    Hope it helps.
    Please award points if it is useful.
    Thakns & Regards,
    Santosh

  • HT3354 how can i use one table for reference to another

    how can i use a table for a referance to another eg when i type a word in a cell, i will like it to match the word with another table then return the information in the cell i am using

    you can use vlookup() (or any of the lookup family of functions) to locate an item based on a key value:
    Here is an example of something you can do with two tables:
    The table on the right is title "Data" and stores a list of names with age and favorite color.
    The table on the left uses the value in the first column to lookup up information in the table Data
    in the table on the left:
    B2=IFERROR(A2&" is " & VLOOKUP(A2, Data :: A:D, 2, 0)&" years old and likes the color "& VLOOKUP(A2, Data :: A:D, 3, 0), "NOT FOUND")
    I know this look complicated.  so I'll break it up into smalled pieces:
    first the "&" is called the concatenate operator and joins two strings.  like this:
    a string is a set of characters between double quotes.
    so "string 1" & "string 2" becomes "string 1string2"  or "Sam " & "Jones" becomes "Sam Jones"
    you can use cell references instead of strings directly in which case the concatenation is performed on the contents of the cells.
    so if cell A1 contains "Hi " and the cell A2 contains "There"  then A1 & A2 will result in "Hi There"
    so you could add the formula
    A3=A1 & A2
    this is short hand for select cell A3 then type everything including the A3 so that A3 contains "=A1 & A2" (omit the double quote)
    OK.  So the formula I provided concatenates several items together:
    it concatenates A2, then the string " is " then a formula, then the string " years old and likes the color " then a formula
    the two formulas (highlighted in blue) perform a lookup of the value in cell A2 in columns A thru D of the table named "Data".  If if finds the value in cell A2 in the first column of the lookup range in the table Data (column A) then it returns the value from the same row but in the second or third column.
    all that is in a function calld iserror() to trap the condition where the calue you enter in A2 does not exist in the table Data:
    You will find the Numbers users guide and function reference helpful.  You can download then from Apple here:
    http://support.apple.com/manuals/#productivitysoftware

  • How to check plan line items for plan cost at network activity level?

    Dear all,
    How to check plan line items for plan cost at network activity level? The plan cost is done in network activity in CJ20N.
    I am not able to check using CJI4 or CJI9 report.
    Kindly advise.
    Thanks and regards,
    Jessie

    Hi Jess,
    Have you checked the navigation part which is being displayed on left hand side of report S_ALR_87013565 and S_ALR_87013533.? There you have option to check transaction currency and object currency when you double click on it.
    In case if it is not being displayed under navigation. Then you can bring them on from transaction code CJE2. For eg: Report group for S_ALR_87013533 is 12KST1C. Double click on it and it will open up to do changes in report layout and many more. There you also have options to bring on transaction currency too. Similarly, you can check for other report groups as well just by checking the report description.
    But I am not sure if suits your requirements. Wait for other experts to comment on this.
    Regards,
    Amit

  • How to check a pdf uploaded for press in a website automatically ??

    how to check a pdf uploaded for press in a website automatically ??
    i am making a new website for a printer.. his client upload pdf online directly in his website, we want that in the case that the pdf is not
    as the printer need it for printing , the site automaticly after checking the pdf profile uploaded open a window and write what is wrong with this pdf
    and if possible fix what he can fix automaticly as pitstop software is doing offline.
    PLEASE YOUR HELP
    thank you in advance

    Acrobat isn't available with a server license. You might like to look into PitStop Server.

  • How to Read the internal table for the data download from the spool

    HI all,
    I have one issue regarding the spool ,we are getting the correct output as per requirement of  user but when we send the same to the user in pdf format they did notget the same.
    they are telling that the due date is missing from the pdf.
    Please advice me how to track the internal  table for the spool data converted intopdf in a readable format.
    the FM used for the above task is : 
    call function 'CONVERT_OTFSPOOLJOB_2_PDF'
    Please reply if any one worked on the same.
    Thanks in advance.
    Gaurav,

    Hi Wang,
    Please let me know how you solved your question.
    Points will be rewarded.
    Thanks,
    Arun.

  • How do i find the tablet for taking notes in school

    how do i find the tablet for taking notes in school on macbookpro

    Tablet?  Do you mean like a notepad or notebook?
    TextEdit is included as a part of Mac OS X.  There are plenty of other word processor programs available- Microsoft Word, Apple's Pages, OpenOffice, to name a few

  • How Can I obtain the tables of one schema and the record size???

    How Can I obtain the tables of one schema and the record size???
    Example:
    TableName Record Size
    Tabla1 12500
    Tabla2 7800
    Tabla3 2046

    This is not an OWB question, but you can obtain bda-type information on tables by using the system view dba_tables.
    Regards:
    Igor

  • What is table for results field in results recording

    Dear all,
    Please tell me the  table for the results in results recording .
    Thanx in advance.
    Regards
    Srinivas

    Hi,
    QAMR                             Characteristic results during inspection processing
                                                                                    QASE                             Results table for the sample unit                                                                               
    QASR                             Sample results for inspection characteristics                                                                               
    Regards
    Mangal

Maybe you are looking for