Help with counting XML elements and converting from MS SQL 2008 to ORACLE

Hello,
My ORACLE DB version is:
('Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production');
('PL/SQL Release 11.2.0.2.0 - Production');
('CORE     11.2.0.2.0     Production');
('TNS for Linux: Version 11.2.0.2.0 - Production');
('NLSRTL Version 11.2.0.2.0 - Production');
I'm trying to convert the below SQL Server 2008 query to work on Oracle. It's important to note that the XMLData column type is CLOB.
Query 1)
-- Number of validations
select br.rulename, CAST(( CAST(br.XMLData as XML)).query('count(//Validation/Expressions/Expression)') as nvarchar(50)) as "Number of //Validation/Expressions/Expression"
from AsBusinessRules br
where
DATALENGTH(br.XMLData)>10
and CAST(( CAST(br.XMLData as XML)).query('count(//Validation/Expressions/Expression)') as nvarchar(50)) not like '0'
Any help is greatly appreciated.

Hi,
You can try one of these :
select br.rulename
     , count(*) as "Num. of Expression"
from AsBusinessRules br
   , xmltable(
       '//Validation/Expressions/Expression'
       passing xmltype(br.XMLData)
     ) x
where length(br.XMLData) > 10
group by br.rulename
having count(*) != 0
;or,
select br.rulename
     , xmlcast(
         xmlquery(
           'count(//Validation/Expressions/Expression)'
           passing xmltype(br.XMLData)
           returning content
         as number
       ) as "Num. of Expression"
from AsBusinessRules br
where length(br.XMLData) > 10
and xmlcast(
      xmlquery(
        'count(//Validation/Expressions/Expression)'
        passing xmltype(br.XMLData)
        returning content
      as number
    ) != 0
It's important to note that the XMLData column type is CLOB.Could you consider migrating the column to XMLType datatype?
Given your version, it would be binary XML by default and therefore a lot more performant with XQueries, compared to a simple CLOB storage.

Similar Messages

  • How do I migrate views from MS SQL 2008 to Oracle 11g through SQL Developer

    Is there any way to migrate the views from MS SQL 2008 to Oracle 11g through SQL Developer? Please give me some detail steps. Thanks for your help.
    Kevin

    Hi Kevin,
    user13531850 wrote:
    Hi Turloch,
    When I use migrate to oracle, I got a problem, the migrate tool create a new schema for me in my case (AZTECA_KSMMS), it migrates all the stuffs under that schema (AZTECA_KSMMS). However my application need the all the Oracle data under schema AZTECA instead of AZTECA_KSMMS. Is there any way to specify specific schema (AZTECA) for target oracle database? Schema remapping is available:
    First Capture (separately) then during right click convert on the captured model there is a Specify the conversion options with a Object Naming tab where the schema (and other) name changes are editable.
    I have not used this recently.
    Also during the migration process, when I choose repository, there is a check box for truncate to reset repository to empty state, Do I need to check that truncate Check Box so the repository will be cleared from last migration?The repository can hold multple migration attempts. Check truncate to get rid of previous attempts information. This cleans up the repository - not the destination database.
    There are also online database and offline database options during the migration process, what are the difference between these two choices? After I migrated to Oracle, all my views has a red cross icon next to it. Does that mean the view migration is failed or not? Please give me your comments. Thanks for your help.offline: for big (amount of data) databases with simple data types,
    uses bcp + files + scripts + sqlldr.
    online: for small (amount of data) databases (easier),
    uses (Java) jdbc.
    The view is likely to be broken - recompiling it may help.
    The Oracle schema is created using a .sql file - see under generated in the directory you gave originally in the wizard. There is a .out file that contains the result of running this script including any errors. During conversion there are also likely to be warnings displayed on the UI.
    There may be a single issue that is causing multiple issues - if viewa depends on functionb, and functionb is broken, viewa will also fail.
    >
    Kevin-Turloch
    SQLDeveloper Team

  • Help with backing up files and opening from disk image.

    I am trying to back up my hard drive so that I can send my PowerBook in for repair. I used disk utility from my Panther install discs to create a disk image of my HD.
    The disk image was created successfully and mounts perfectly on my HD. I can open it and open all of my files from the disk image just fine when it is mounted on my PowerBook.
    However, when I take it to a different Mac, things start getting sketchy. I can open Word files just fine, but Excel files claim they are read-only and cannot open. I checked the permission back on my PowerBook to see what was up, and the files were read/write for the owner and read-only for groups and others, but they should still open as read-only files right? I even checked the permissions on the Word files to see if there was a difference, but there was no difference.
    I can take the external HD back to my PowerBook, remount it, and open everything fine, but then on the other Mac it is a no go.
    I need to back this up for when it is out on repair, but I need to know that the files will open in case I need to restore my disk.
    Can anyone help??
    BTW, I couldn't find the best forum to post this in, if there is a better one please direct me there...

    solution:
    I went into the Apple Store nearby today to send my PowerBook off for repair for a screen issue, and in the process got help with my backing up issue.
    It seems all one needs to do is copy the file from the external hard drive to the internal drive.
    It was that simple.
    Jason

  • Help with making files viewable and playable from other accounts on leopard

    i recently got an imac (20in 2.4) and i want to play music on my account that is on my dads acccount...i looked it up and it said to click file and then 'get info' then you can make it 'view' or 'view and read' i do that and it still doesnt work...it keeps saying i dont have enough access privleges. please help

    Where did you look this up? (link please)

  • How to replicate data from MS SQL Server  to Oracle

    Hi,
    Can someone please help me on how to replicate data from MS SQL Server to Oracle 8i database.

    Dear,
    I'm a student.
    I do simple replication on Oracle 8.0.5 successfully. (one master site and one snapshot site). I only use the SQL*Plus and Schema Manager to do.
    But when I do advance replication (multimaster replication) I meet many problem. So I don't get the result.
    Do you show me the technology to do that ?
    Thanks !

  • Help with count and sum query

    Hi I am using oracle 10g. Trying to aggregate duplicate count records. I have so far:
    SELECT 'ST' LEDGER,
    CASE
    WHEN c.Category = 'E' THEN 'Headcount Exempt'
    ELSE 'Headcount Non-Exempt'
    END
    ACCOUNTS,
    CASE WHEN a.COMPANY = 'ZEE' THEN 'OH' ELSE 'NA' END MARKET,
    'MARCH_12' AS PERIOD,
    COUNT (a.empl_id) head_count
    FROM essbase.employee_pubinfo a
    LEFT OUTER JOIN MMS_DIST_COPY b
    ON a.cost_ctr = TRIM (b.bu)
    INNER JOIN MMS_GL_PAY_GROUPS c
    ON a.pay_group = c.group_code
    WHERE a.employee_status IN ('A', 'L', 'P', 'S')
    AND FISCAL_YEAR = '2012'
    AND FISCAL_MONTH = 'MARCH'
    GROUP BY a.company,
    b.district,
    a.cost_ctr,
    c.category,
    a.fiscal_month,
    a.fiscal_year;
    which gives me same rows with different head_counts. I am trying to combine the same rows as a total (one record). Do I use a subquery?

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    user610131 wrote:
    ... which gives me same rows with different head_counts.If they have different head_counts, then the rows are not the same.
    I am trying to combine the same rows as a total (one record). Do I use a subquery?Maybe. It's more likely that you need a different GROUP BY clause, since the GROUP BY clause determines how many rows of output there will be. I'll be able to say more after you post the sample data, results, and explanation.
    You may want both a sub-query and a different GROUP BY clause. For example:
    WITH    got_group_by_columns     AS
         SELECT  a.empl_id
         ,     CASE
                        WHEN  c.category = 'E'
                  THEN  'Headcount Exempt'
                        ELSE  'Headcount Non-Exempt'
                END          AS accounts
         ,       CASE
                        WHEN a.company = 'ZEE'
                        THEN 'OH'
                        ELSE 'NA'
                END          AS market
         FROM              essbase.employee_pubinfo a
         LEFT OUTER JOIN  mms_dist_copy             b  ON   a.cost_ctr     = TRIM (b.bu)
         INNER JOIN       mms_gl_pay_groups        c  ON   a.pay_group      = c.group_code
         WHERE     a.employee_status     IN ('A', 'L', 'P', 'S')
         AND        fiscal_year           = '2012'
         AND        fiscal_month          = 'MARCH'
    SELECT    'ST'               AS ledger
    ,       accounts
    ,       market
    ,       'MARCH_12'          AS period
    ,       COUNT (empl_id)       AS head_count
    FROM       got_group_by_columns
    GROUP BY  accounts
    ,            market
    ;But that's just a wild guess.
    You said you wanted "Help with count and sum". I see the COUNT, but what do you want with SUM? No doubt this will be clearer after you post the sample data and results.
    Edited by: Frank Kulash on Apr 4, 2012 5:31 PM

  • Js load xml element - style match from another file

    Hi all
    I got a ID file with a placed xml file, all styles are prepaired.
    Now I would like to load the xml element <-> style match from a given template file, where I prepaired all the matches.
    I would imagine this is a bit like loading the styles or the swatches from another file, but have not found any code samples yet.
    Can anybody help?
    Thanks
    Romano

    js for Structure; XML; Map Tags to Styles...
    I don't think that is what I am looking for and I feel I must asked this question in an unclear way...
    so I started a new discussen with the above heading.
    Thank you anyway.
    Romano

  • Need help with Adobe Premiere Elements 2

    I can drag a large high rez jpeg into timeline. Then when I click to playback....it gets more pixelated. That's a bad beginning. Then, when I go to export it, I've tried several extensions. All look bad during playback on YouTube. This should be pretty simple. High quality jpeg, but is fuzzy in movie. What's going wrong?

    hi Bill -
    ok fine. I have PSDs too. I tried what you said.
    I put a PSD right beside a JPEG in the timeline. I rendered it (which I
    didn't know to do because the instructions don't even mention it. The
    instructions are terrible. Seems it leaves out a lot of info.)
    So, then I click PLAY on my monitor. I see no difference between the PSD
    and the JPEG yet. So, if I want to put this on YouTube, what's the best way
    exactly, without gettting too technical?  It looks like I have the choice
    between Exporting in Mpeg or Quicktime or Windows Media. I think youtube
    likes wmv.
    From: Bill Hunt <[email protected]>
    To: Tommy Midyette <[email protected]>
    Date: 6/3/2010 10:01:24 AM
    Subject: need help with Adobe Premiere Elements 2
    >
    When you drag the stills to the Timeline, there should be a red line
    above them. Press Enter to Render the Timeline.
     
    Do not know the particulars of PrE 2, but in later versions, you can
    Rt-click on the Program Monitor, and choose Magnification = 100%, rather
    than Fit. You might have to resize your Program Monitor, but check at 100%.
     
    Also remember a few points:
     
    1.) You are looking at a DVD-quality image now, and that was designed
    with low-rez CRT TV's in mind, and NOT hi-rez computer monitors. DVD vs
    hi-rez sources and displays is probably less than what VHS vs DVD was, not
    that long ago.
    2.) You are looking at an emulation, a preview
    3.) Your images have already been compressed to JPEG once, loosing
    quality. That is why I always work in PSD, especially if there has already
    been one JPEG compression, whether in camera, or in the image processing
    stage. I keep JPEG either out of my workflow, or as limited, as is
    possible. Some do not see the quality loss with JPEG compression, but I do,
    and if I can create images that are as good as it gets, I know that my
    clients will be happy.
     
    Good luck,
     
    Hunt
    >

  • I need to find all XML elements and add a line break to the text of each of them

    I need to find all XML elements and add a line break to the text of each of them.
    Is this possible with a script?

    I need to go from this ...
    to this...
    but looking for the XML elements (not paragraphs) and then adding text ...
    Thanks for your attention !!!

  • Help with opening Adobe Reader and downloading updates

    I can not open Adobe .pdf files any longer (this started yesterday, prior to that I could open adobe files).
    When I double click a .pdf file I get this notice on my screen: Windows cannot access the specified device path or file. You may not have the appropriate permission to access file.
    So I went to the Adobe download site to download a new copy of Adobe.  When I start the download I get this on the screen:  The instruction at "0x0e3a0068" referenced memory at "0x0e3a0068."  The memory could not be written.  Then two options are listed: click OK to terminate or cancel to debug.  So I click on cancel and I get this on my screen: Internet Explorer has closed this webpage to help protect your computer.   A malfunctioning or malicious addon has caused I.E. to close this webpage.
    I don't have AVG running, I do have avast but I've disabled it.  I ran Registry Mechanic and an I.E. erasure program but nothing helps.
    I have gone into I.E. and reduced the security level to its lowest state but no joy.
    So, any ideas or suggestions on what's the problem and how to overcome it would be appreciated.  Thanks, in advance, for your reply.  Jim R.

    Hi Mike..tried that as well but no joy.  A friend of mine was looking at it all and noticed that it was an I.E. thing as far as not letting me redownload the reader so I went to Mozilla Firefox and I could download a new version but....whenever I attempt to open a .pdf file I get that message, "Windows can not open the specified device, path or file. You man not have the appropriate permissions to access the item." 
    Damn...this is irritating as I need to get to some of thos files as I need them for a Journal I'm working on as editor-in-chief. 
    It all worked just fine last Saturday but starting Monday when I was on my flight out to D.C.  no joy. 
    Sigh...Jim R.
    Jim R.
    Date: Tue, 1 Dec 2009 14:50:27 -0700
    From: [email protected]
    To: [email protected]
    Subject: Help with opening Adobe Reader and downloading updates
    Under the help menu, there is an option to repair the installation of reader. Did you try that?
    >

  • Last night as I was setting up the pin I got distracted and entered the wrong one, now I can't access my phone as I don't know what I entered. Is there anyway around this or do I have to wipe my phone and sign in with my Apple ID and restore from icloud??

    Last night as I was setting up the pin I got distracted and entered the wrong one, now I can't access my phone as I don't know what I entered. Is there anyway around this or do I have to wipe my phone and sign in with my Apple ID and restore from icloud??
    I can't ask for help on chat as I'm away from home and don't have the box with me, and obviously can't get the serial number in my phone as I've locked myself out!!
    Any help will be much appreciated!!

    https://support.apple.com/kb/ht1212

  • Need help with my iPhone 5 and my Macbook Pro.

    Need help with my iPhone 5 and my Macbook Pro.  I was purchased some music on itunes at my mac. Some reason I deleted those music from both on Mac and iPhone 5.  Today, I went to my iPhone iTunes store inside of iCloud to redownload my puchased. But those song won't able to sync back to my iTunes library on my Mac.  Can anyone help me with that ??....
    iPhone 5, iOS 6.0.1

    You've posted to the iTunes Match forum, which your question does not appear to be related to. You'll get better support responses by posting to either the iTunes for Mac or iTunes for Windows forum. Which ever is more appropriate for your situation.

  • [JS-CS4] - How to read the XML Element and its Attributes

    Dear All,
      I have the doubt regarding: reading the xmlElement and its attributes.
    Here I droping the xml script
    //============= Start ======================//
    var myDoc = app.activeDocument;
    var Fpath = File("../Projects/Entity_map.xml");
      if (Fpath.exists)
       Fpath.open("r");
       var Cont= Fpath.read();
      var roots = new XML(Cont);
      var myEveryName = new Array();
      var myEveryContent = new Array();
      var myEveryAttributes = new Array();
      traverse(roots);
    //$.writeln(myEveryName);
    //$.writeln(myEveryContent);
    $.writeln(myEveryAttributes.length);
    for(var i=0; i<myEveryAttributes.length; i++)
      $.writeln(myEveryAttributes[i]);
    function traverse(tree) {
        myEveryName.push(tree.name());
    myEveryContent.push(tree.text());
      myEveryAttributes.push(tree.getAttribute);
    // you get the contents by using .text() insted of .name()
        if(tree.elements().length() > 0) {
            for(var i=0; i<tree.elements().length(); i++) {
                traverse(tree.elements()[i]);
    //============== End =====================//
    and the XML Structure is
    //===============XML =====================//
    <?xml version="1.0" encoding="UTF-8"?>< Entity_Convertion>
    < Entitys char="Ç" GID="173"/></ 
    Entity_Convertion>
    //===============End ====================//
    Here I'm getting the XML Elements and its contents, but not xmlAttributes.
    Please any one can help me, then I will appreciate...
    Thanks & Regards
    T.R.Harihara SudhaN

    Dear All,
      I have the doubt regarding: reading the xmlElement and its attributes.
    Here I droping the xml script
    //============= Start ======================//
    var myDoc = app.activeDocument;
    var Fpath = File("../Projects/Entity_map.xml");
      if (Fpath.exists)
       Fpath.open("r");
       var Cont= Fpath.read();
      var roots = new XML(Cont);
      var myEveryName = new Array();
      var myEveryContent = new Array();
      var myEveryAttributes = new Array();
      traverse(roots);
    //$.writeln(myEveryName);
    //$.writeln(myEveryContent);
    $.writeln(myEveryAttributes.length);
    for(var i=0; i<myEveryAttributes.length; i++)
      $.writeln(myEveryAttributes[i]);
    function traverse(tree) {
        myEveryName.push(tree.name());
    myEveryContent.push(tree.text());
      myEveryAttributes.push(tree.getAttribute);
    // you get the contents by using .text() insted of .name()
        if(tree.elements().length() > 0) {
            for(var i=0; i<tree.elements().length(); i++) {
                traverse(tree.elements()[i]);
    //============== End =====================//
    and the XML Structure is
    //===============XML =====================//
    <?xml version="1.0" encoding="UTF-8"?>< Entity_Convertion>
    < Entitys char="Ç" GID="173"/></ 
    Entity_Convertion>
    //===============End ====================//
    Here I'm getting the XML Elements and its contents, but not xmlAttributes.
    Please any one can help me, then I will appreciate...
    Thanks & Regards
    T.R.Harihara SudhaN

  • Please help with the FOR loop and the array..

    I was trying to place some words in the Movie Clip
    "TextPanel" and set a
    random position to each of them.
    But it's not working.
    1) I created a Movie Clip "word" and inside that MC I created
    a text field
    and gave it an identifier "textFiled".
    2) The linkage name for Movie Clip "word" I set to "word".
    3) In the actionscript I created an Array called "aWords".
    4) Then I created a FOR loop that should
    place (attach) Movie Clips "word0", "word1", "word2" and
    "word3" to the
    movie clip TextPanel, and set the textField text for each of
    them to the
    text from the Array.
    But the script attaches 4 Movie Clips with a name
    "Undefined", instead of 4
    different names (from the Array).
    What is wrong with this script?
    var aWords:Array = [apple,banana,orange,mango];
    for(i=0;i<aWords.length;i++){
    var v = TextPanel.attachMovie("word","word"+i,i);
    v.textFiled.text = aWords
    v._x = randomNumber(0,Stage.width);
    v._y = randomNumber(0,Stage.height);
    Thanks in advance

    But in my Post I already wrote v.textFiled.text = aWords
    so I don't understand what were you correcting..
    And one more:
    I have tested it by changing the
    v.textFiled.text = aWords; to v.textFiled.text = "some
    word";
    and it's working fine.
    So there is something wrong with the Array element, and I
    don't know why..
    "aniebel" <[email protected]> wrote in
    message
    news:ft2d5k$lld$[email protected]..
    > Change:
    > v.textFiled.text = aWords;
    >
    > to:
    > v.textFiled.text = aWords
    >
    > It needs to know which element inside the array you want
    to place in the
    > textfield (or textfiled) :)
    >
    > If that doesn't work, double check that your instance
    name is correct
    > inside
    > of "word".
    >

  • How to move some xml element and its content to a new frame

    Hi All,
    How to move some xml element and its content to a new frame.

    Hi Chinnadk,
    Sorry my code its comment some lines. Now only I check the forum thread, you just try one more time.
    #target InDesign;
    #include "/Program Files (x86)/Adobe/Adobe InDesign CS5.5/Scripts/XML Rules/glue code.jsx"
    var myDoc = app.activeDocument;
    //____________________ XML RULE SET
    var myRuleSet = new Array (new margintag);
    with(myDoc){
        var elements = xmlElements;
        __processRuleSet(elements.item(0), myRuleSet);
    function margintag(){
        this.name = "margintag";
        //this.xpath = "//margintag[@type='mn2']";
        this.xpath = "//margintag";
        this.apply = function(myElement, myRuleProcessor){
            with(myElement){
                app.select(myElement);
                try{
                    var myPrePara = app.selection[0].paragraphs[-1].parentTextFrames[0].paragraphs.previousItem(app.selection[0].paragraphs[-1]);
                    if(myPrePara.characters[-1].contents=="\r"){
                        myPrePara.characters[-1].remove();
                    var myTextframe = myElement.placeIntoInlineFrame(["7p9","6p"]);
                    myTextframe.appliedObjectStyle= myDoc.objectStyles.item("MN1");
                    myTextframe.fit(FitOptions.FRAME_TO_CONTENT);
                    myTextframe.parentStory.paragraphs.everyItem().appliedParagraphStyle = app.activeDocument.paragraphStyles.itemByName("MN1");
                    }catch(e){}
                app.selection = null;
            return true;
    thx,
    csm_phil

Maybe you are looking for

  • F110 - Customer is contained in proposal 06/20/2014 DAFT1 no editing

    Hello SAP Experts I have 2 set of invoices with 2 different due dates Aug/15/2014 and AUG/20/2014 I have executed APP for a set of due date Aug/15/2014 on and before, now the process is at proposal stage and waiting for release the payment run. Now I

  • Transaction in TaskFlow and locking

    Hello I'm using JDeveloper 11g 11.1.2.1.0 I came across strange (in my opinion) behaviour of the transaction option inside taskFlow: if taskFlow's transaction option set as something other than "<No Controller Transaction>" (for example, "Use Existin

  • How can we generate the reports in html or text file formats?

    Hi, Is there any package that can help in creating HTMLDB reports in .txt files or .html files? (Similar to TEXT_IO in Oracle Forms) How can we generate the reports in html or text file formats from HTMLDB? Thanks in Advance Renjith

  • How to use Update Statement in ODI Procedure

    Hi, How can I use an update statement inside an ODI procedure. Thanks

  • Problem with loading file with SQL loader

    i am getting a problem with loading a file with SQL loader. The loading is getting terminated after around 2000 rows whereas there are around 2700000 rows in the file. The file is like 919879086475,11/17/2004,11/20/2004 919879698625,11/17/2004,11/17/