Parse XML in PL/SQL need help

Hi All,
I'm new to PL/SQL. I need to call a web service from within the PL/SQL and then need to parse the response XML. I was able to call the web service and now I have returned SOAP response XML in CLOB. I searched on google for way to parse this XML and create some kind of list or array or collection with all the values so that later on that collection or array can be used in displaying the data or storing the data, but I couldn't found the right information, rather I got very confused.
Please help me in parsing this XML and creating some kind collection or array for later use.
Thanks
XML is
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<getMemberResponse effectiveDate="1970-10-01" endDate="2010-12-31" xmlns="http://abc.org/schema/Member/GetMember/V1">
<responseHeader xmlns="http://abc.org/schema/common/v1">
<serviceVersion>2.0.1</serviceVersion>
<actionRequested AR="QUERY" xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/common/v1" xmlns:v12="http://abc.org/schema/common/v1">
<v11:transactionName>GetMemberRequest</v11:transactionName>
</actionRequested>
<requestResults>
<resultStatus>Success</resultStatus>
<resultCodes>
<resultCode TYPE="HIPAA">00000</resultCode>
<resultCode TYPE="LEGACY">00000</resultCode>
<resultCode TYPE="SDI">00000</resultCode>
</resultCodes>
<resultMessage>Success</resultMessage>
</requestResults>
<accounting xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/datatypes/v1" xmlns:v12="http://abc.org/schema/common/v1">
<transactionId>ec3542e7-3191-430c-bd69-69dd5d18bf75</transactionId>
<v12:timeStamp>2011-05-23T11:52:22</v12:timeStamp>
</accounting>
</responseHeader>
<requestID>ec3542e7-3191-430c-bd69-69dd5d18bf75</requestID>
<memberDetails xmlns:v1="http://abc.org/schema/Member/V1" xmlns:v11="http://abc.org/schema/datatypes/v1" xmlns:v12="http://abc.org/schema/common/v1">
<v1:ids>
<v1:id memberIdType="SSN">00000000</v1:id>
<v1:id memberIdType="PARTYID">111111</v1:id>
<v1:id memberIdType="PARTYNUMBER">222222</v1:id>
</v1:ids>
<v1:demographics>
<v1:memberDemographicType effDate="2010-05-09" maintType="UPDATE">
<v1:name>
<v1:nameDetails>
<v11:firstName>Keith</v11:firstName>
<v11:middleName>M</v11:middleName>
<v11:lastNames>
<v11:lastName>
<v11:name>Thompson</v11:name>
</v11:lastName>
</v11:lastNames>
<v11:formattedName>Keith M Thompson</v11:formattedName>
</v1:nameDetails>
<v1:createDate>2010-05-09T14:23:17</v1:createDate>
<v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
</v1:name>
<v1:birthDate>1954-12-24</v1:birthDate>
<v1:genderTypeCode>Male</v1:genderTypeCode>
<v1:createDate>2010-05-09T14:23:17</v1:createDate>
<v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
</v1:memberDemographicType>
</v1:demographics>
<v1:originalContractEffDate>2010-04-01</v1:originalContractEffDate>
<v1:addresses>
<v1:address maintType="QUERY">
<v1:location addresseeType="MEMBER" effDate="1901-01-01" endDate="9999-12-31" locationUseType="HOME" primaryPerType="Y">
<v11:addressLines>
<v11:addressLine>BAY VIEW AVENUE</v11:addressLine>
</v11:addressLines>
<v11:cityName>PLYMOUTH</v11:cityName>
<v11:stateCode>TX</v11:stateCode>
<v11:postalCode>58654</v11:postalCode>
</v1:location>
<v1:createDate>2011-05-23T11:52:22</v1:createDate>
<v1:updateDate>2011-05-23T11:52:22</v1:updateDate>
</v1:address>
<v1:address maintType="QUERY">
<v1:location addresseeType="SUBSCRIBER" effDate="1901-01-01" endDate="9999-12-31" locationUseType="HOME" primaryPerType="Y">
<v11:addressLines>
<v11:addressLine>AY VIEW AVENUE</v11:addressLine>
</v11:addressLines>
<v11:cityName>PLYMOUTH</v11:cityName>
<v11:stateCode>TX</v11:stateCode>
<v11:postalCode>58654</v11:postalCode>
</v1:location>
<v1:createDate>2011-05-23T11:52:22</v1:createDate>
<v1:updateDate>2011-05-23T11:52:22</v1:updateDate>
</v1:address>
</v1:addresses>
<v1:policies>
<v1:policy effDate="2010-04-01" maintType="ADD" type="MEMBER">
<v1:ids>
<v1:id type="MEMBERID">CPIT000456</v1:id>
<v1:id type="POLICY">CPIT</v1:id>
</v1:ids>
<v1:contractType>F</v1:contractType>
<v1:dependentType>01</v1:dependentType>
<v1:offerings>
<v1:offering offeredBy="abc" offeringIdType="INSURANCE_TYPE" selected="Y">
<v1:offeringId>IV</v1:offeringId>
</v1:offering>
<v1:offering effDate="2010-04-01" maintType="ADD" offeredBy="abc" offeringIdType="BOC" selected="Y">
<v1:offeringId>GK</v1:offeringId>
<v1:recordInfo>
<v1:internalRecId>82326287</v1:internalRecId>
</v1:recordInfo>
<v1:createDate>2010-05-09T14:23:17</v1:createDate>
<v1:updateDate>2010-05-09T14:23:17</v1:updateDate>
</v1:offering>
</v1:offerings>
<v1:customer>
<v1:relation type="EMPLOYMENT">
<v1:customer>
<v1:id idType="ACCOUNTID">C11204</v1:id>
<v1:id idType="DIVISION">0208290000</v1:id>
<v1:customerName>BC Group</v1:customerName>
</v1:customer>
</v1:relation>
</v1:customer>
<v1:physicianRelations>
<v1:physicianRelation effDate="2010-04-01" endDate="9999-12-31" type="PCP">
<v1:ids>
<v1:id type="NPI">0</v1:id>
<v1:id type="AFFILIATIONID">1313 0025</v1:id>
<v1:id type="PROVIDERID">1313</v1:id>
<v1:id type="TIN">0</v1:id>
</v1:ids>
<v1:recordInfo>
<v1:internalRecId>98151812</v1:internalRecId>
</v1:recordInfo>
<v1:createDate>2010-10-23T01:10:13</v1:createDate>
<v1:updateDate>2010-10-23T01:10:13</v1:updateDate>
</v1:physicianRelation>
</v1:physicianRelations>
<v1:maintainReasonCode>AC</v1:maintainReasonCode>
<v1:recordInfo>
<v1:internalRecId>82326286</v1:internalRecId>
</v1:recordInfo>
<v1:createDate>2010-05-09T14:23:17</v1:createDate>
<v1:updateDate>2010-05-09T14:23:17</v1:updateDate>
</v1:policy>
<v1:policy effDate="2010-04-01" maintType="QUERY" type="SUBSCRIBER">
<v1:ids>
<v1:id type="POLICY">CPIT</v1:id>
</v1:ids>
<v1:hashCode>82326284</v1:hashCode>
<v1:contractType>F</v1:contractType>
<v1:maritalStatus>UNKNOWN</v1:maritalStatus>
<v1:offerings>
<v1:offering effDate="2010-04-01" maintType="QUERY" offeredBy="abc" offeringIdType="INSURANCE_TYPE" selected="Y">
<v1:offeringId>IV</v1:offeringId>
<v1:recordInfo>
<v1:internalRecId>82326285</v1:internalRecId>
</v1:recordInfo>
<v1:createDate>2010-05-09T14:23:17</v1:createDate>
<v1:updateDate>2011-01-20T04:53:52</v1:updateDate>
</v1:offering>
</v1:offerings>
<v1:customer>
<v1:relation type="EMPLOYMENT">
<v1:customer>
<v1:id idType="ACCOUNTID">C11204</v1:id>
<v1:id idType="DIVISION">0208290000</v1:id>
<v1:customerName>BC Group</v1:customerName>
</v1:customer>
</v1:relation>
</v1:customer>
<v1:maintainReasonCode>AC</v1:maintainReasonCode>
<v1:recordInfo>
<v1:internalRecId>82326284</v1:internalRecId>
</v1:recordInfo>
<v1:createDate>2010-05-09T14:23:17</v1:createDate>
<v1:updateDate>2011-01-20T04:53:52</v1:updateDate>
</v1:policy>
</v1:policies>
<v1:recordInfo>
<v1:internalRecId>8364745</v1:internalRecId>
<v1:objectVersionNo>1</v1:objectVersionNo>
</v1:recordInfo>
<v1:restrictedMemberIndicator>N</v1:restrictedMemberIndicator>
<v1:createDate>2010-05-09T14:23:17</v1:createDate>
<v1:updateDate>2010-08-08T02:40:24</v1:updateDate>
</memberDetails>
</getMemberResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Hi A_Non,
Thanks so much for giving me the hint about that "text()" in XPath.
I have new question for you with same XML I'm parsing right now.
I have extracted a part(Policies) of whole XML and put it in one XMLTYPE variable. Below is that part XML.
My question is I need to look only into that policy which is active right now. In the <policy> tag there are two attributes "effDate" and "endDate". "effDate" tag will always be there for every policy and for all inactive policies also "endDate" will be there always. Problem is with the active ones, "endDate" may or may not be there. If "endDate" is there so it will be greater than or equal to sysdate and if it is not there that means it is open ended. I need to fetch only that policy which is active right now and if there is no tag as such that means member is not active as of today.
If "endDate" attribute is there then I think below XPath will work, but I'm not sure about how to handle when "endDate" attribute is not there.
/d:policies/d:policy[@type="MEMBER" and number(translate(@effDate,"-",""))<=number(translate("'||l_currDate||'","-","")) and number(translate(@endDate,"-",""))>=number(translate("'||l_currDate||'","-",""))]I have Oracle 10.1.0.4, in this in XPath comparison operators are not working so I'm using XPath functions.
Here is the XML
<v1:policies>
   <v1:policy effDate="1999-05-01" endDate="1999-12-31" maintType="ADD" type="MEMBER">
       <v1:ids>
           <v1:id type="MEMBERID">SDF000414600</v1:id>
           <v1:id type="POLICY">SDF0004146</v1:id>
       </v1:ids>
       <v1:contractType>F</v1:contractType>
       <v1:dependentType>01</v1:dependentType>
       <v1:offerings>
           <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
               <v1:offeringId>IH</v1:offeringId>
           </v1:offering>
           <v1:offering effDate="1999-05-01" endDate="1999-12-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
               <v1:offeringId>HA</v1:offeringId>
               <v1:recordInfo>
                  <v1:internalRecId>39077481</v1:internalRecId>
               </v1:recordInfo>
               <v1:createDate>2010-05-01T01:27:04</v1:createDate>
               <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
           </v1:offering>
       </v1:offerings>
       <v1:customer>
           <v1:relation type="EMPLOYMENT">
               <v1:customer>
                  <v1:id idType="ACCOUNTID">AS35423</v1:id>
                  <v1:id idType="DIVISION">0621730000</v1:id>
                  <v1:customerName>Medical Associates</v1:customerName>
               </v1:customer>
           </v1:relation>
       </v1:customer>
       <v1:physicianRelations>
           <v1:physicianRelation effDate="1999-05-01" endDate="1999-12-31" type="PCP">
               <v1:ids>
                  <v1:id type="NPI">0</v1:id>
                  <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                  <v1:id type="PROVIDERID">231231</v1:id>
                  <v1:id type="TIN">0</v1:id>
               </v1:ids>
               <v1:recordInfo>
                  <v1:internalRecId>87796651</v1:internalRecId>
               </v1:recordInfo>
               <v1:createDate>2010-10-22T21:56:44</v1:createDate>
               <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
           </v1:physicianRelation>
       </v1:physicianRelations>
       <v1:maintainReasonCode>MD</v1:maintainReasonCode>
       <v1:recordInfo>
           <v1:internalRecId>39077480</v1:internalRecId>
       </v1:recordInfo>
       <v1:createDate>2010-05-01T01:27:04</v1:createDate>
       <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
   </v1:policy>
   <v1:policy effDate="2000-01-01" endDate="2000-12-31" maintType="ADD" type="MEMBER">
       <v1:ids>
           <v1:id type="MEMBERID">SDF000414600</v1:id>
           <v1:id type="POLICY">SDF0004146</v1:id>
       </v1:ids>
       <v1:contractType>F</v1:contractType>
       <v1:dependentType>01</v1:dependentType>
       <v1:offerings>
           <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
               <v1:offeringId>IH</v1:offeringId>
           </v1:offering>
           <v1:offering effDate="2000-01-01" endDate="2000-12-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
               <v1:offeringId>HA</v1:offeringId>
               <v1:recordInfo>
                  <v1:internalRecId>39077483</v1:internalRecId>
               </v1:recordInfo>
               <v1:createDate>2010-05-01T01:27:04</v1:createDate>
               <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
           </v1:offering>
       </v1:offerings>
       <v1:customer>
           <v1:relation type="EMPLOYMENT">
               <v1:customer>
                  <v1:id idType="ACCOUNTID">C35423</v1:id>
                  <v1:id idType="DIVISION">0621730000</v1:id>
                  <v1:customerName>Medical Associates</v1:customerName>
               </v1:customer>
           </v1:relation>
       </v1:customer>
       <v1:physicianRelations>
           <v1:physicianRelation effDate="2000-01-01" endDate="2000-12-31" type="PCP">
               <v1:ids>
                  <v1:id type="NPI">0</v1:id>
                  <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                  <v1:id type="PROVIDERID">3213213</v1:id>
                  <v1:id type="TIN">0</v1:id>
               </v1:ids>
               <v1:recordInfo>
                  <v1:internalRecId>87796652</v1:internalRecId>
               </v1:recordInfo>
               <v1:createDate>2010-10-22T21:56:44</v1:createDate>
               <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
           </v1:physicianRelation>
       </v1:physicianRelations>
       <v1:maintainReasonCode>MD</v1:maintainReasonCode>
       <v1:recordInfo>
           <v1:internalRecId>39077482</v1:internalRecId>
       </v1:recordInfo>
       <v1:createDate>2010-05-01T01:27:04</v1:createDate>
       <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
   </v1:policy>
   <v1:policy effDate="2001-01-01" maintType="ADD" type="MEMBER">
       <v1:ids>
           <v1:id type="MEMBERID">SDF000414600</v1:id>
           <v1:id type="POLICY">SDF0004146</v1:id>
       </v1:ids>
       <v1:contractType>F</v1:contractType>
       <v1:dependentType>01</v1:dependentType>
       <v1:offerings>
           <v1:offering offeredBy="ABC" offeringIdType="INSURANCE_TYPE" selected="Y">
               <v1:offeringId>IH</v1:offeringId>
           </v1:offering>
           <v1:offering effDate="2001-01-01" endDate="2001-03-31" maintType="ADD" offeredBy="ABC" offeringIdType="BOC" selected="Y">
               <v1:offeringId>HC</v1:offeringId>
               <v1:recordInfo>
                  <v1:internalRecId>39077485</v1:internalRecId>
               </v1:recordInfo>
               <v1:createDate>2010-05-01T01:27:04</v1:createDate>
               <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
           </v1:offering>
       </v1:offerings>
       <v1:customer>
           <v1:relation type="EMPLOYMENT">
               <v1:customer>
                  <v1:id idType="ACCOUNTID">C35423</v1:id>
                  <v1:id idType="DIVISION">0621730000</v1:id>
                  <v1:customerName>Medical Associates</v1:customerName>
               </v1:customer>
           </v1:relation>
       </v1:customer>
       <v1:physicianRelations>
           <v1:physicianRelation effDate="2001-01-01" endDate="2001-03-31" type="PCP">
               <v1:ids>
                  <v1:id type="NPI">0</v1:id>
                  <v1:id type="AFFILIATIONID">66759       0014</v1:id>
                  <v1:id type="PROVIDERID">61232132</v1:id>
                  <v1:id type="TIN">0</v1:id>
               </v1:ids>
               <v1:recordInfo>
                  <v1:internalRecId>87796653</v1:internalRecId>
               </v1:recordInfo>
               <v1:createDate>2010-10-22T21:56:44</v1:createDate>
               <v1:updateDate>2010-10-22T21:56:44</v1:updateDate>
           </v1:physicianRelation>
       </v1:physicianRelations>
       <v1:maintainReasonCode>LE</v1:maintainReasonCode>
       <v1:recordInfo>
           <v1:internalRecId>39077484</v1:internalRecId>
       </v1:recordInfo>
       <v1:createDate>2010-05-01T01:27:04</v1:createDate>
       <v1:updateDate>2010-05-01T01:27:04</v1:updateDate>
   </v1:policy>
</v1:policies>Thanks

Similar Messages

  • How to parsing xml data in sql statement??

    Hi friends, I have a table which contain column as clob ,stores in xml format, for example my column contain xml data like this
    <Employees xmlns="http://TargetNamespace.com/read_emp">
       <C1>106</C1>
       <C2>Harish</C2>
       <C3>1998-05-12</C3>
       <C4>HR</C4>
       <C5>1600</C5>
       <C6>10</C6>
    </Employees>
      Then how to extract the data in above xml column data using SQL statement...

    Duplicate post
    How to parsing xml data in sql statement??

  • Parse XML in PL/SQL

    I need help with parsing xml data in PL/SQL. I was able to read the attribute name & values but not able to read the element text.Any help is greatly appreciated.Following is the anonymous block and the desired output -
    Declare
    nl xmldom.DOMNodeList;
    len1 number;
    len2 number;
    n xmldom.DOMNode;
    e xmldom.DOMElement;
    nnm xmldom.DOMNamedNodeMap;
    attrname varchar2(100);
    attrval varchar2(100);
    doc xmldom.DOMDocument;
    p xmlparser.Parser;
    in_xml clob;
    begin
    -- get all elements
    p := xmlparser.newParser;
    in_xml := '<?xml version="1.0" encoding="utf-8"?>
    <Issue>
    <T_ISSUE_TITLE ID = "1">Test Issue</T_ISSUE_TITLE>
    <T_ISSUE_DESC ID = "2">Update Test Issue</T_ISSUE_DESC>
    <STATUS ID = "3">2</STATUS>
    <ISSUE_SD ID = "4">07/09/10</ISSUE_SD>
    <ISSUE_ED ID = "5">09/09/10</ISSUE_ED>
    <CREATE_DT ID = "6">07/09/10</CREATE_DT>
    <CREATE_USER_ID ID = "7">John</CREATE_USER_ID>
    <LST_UPD_USER_ID ID = "8">John</LST_UPD_USER_ID>
    </Issue>';
    xmlparser.parseClob(p,in_xml);
    doc :=xmlparser.getDocument(p);
    nl := xmldom.getElementsByTagName(doc, '*');
    len1 := xmldom.getLength(nl);
    -- loop through elements
    for j in 0..len1-1 loop
    n := xmldom.item(nl, j);
    e := xmldom.makeElement(n);
    dbms_output.put_line(xmldom.getTagName(e) || ':');
    -- get all attributes of element
    nnm := xmldom.getAttributes(n);
    len2 := xmldom.getLength(nnm);
    if (xmldom.isNull(nnm) = FALSE) then
    len2 := xmldom.getLength(nnm);
    -- loop through attributes
    for i in 0..len2-1 loop
    n := xmldom.item(nnm, i);
    --dbms_output.put_line(n);
    attrname := xmldom.getNodeName(n);
    attrval := xmldom.getNodeValue(n);
    dbms_output.put_line(' ' || attrname || ' = ' || attrval);
    end loop;
    end if;
    end loop;
    end;
    /** Output
    Issue:
    T_ISSUE_TITLE:
    ID = 1, Test Issue
    T_ISSUE_DESC:
    ID = 2, Update Test Issue
    STATUS:
    ID = 3, 2
    ISSUE_SD:
    ID = 4, 07/09/10
    ISSUE_ED:
    ID = 5, 09/09/10
    CREATE_DT:
    ID = 6, 07/09/10
    CREATE_USER_ID:
    ID = 7, John
    LST_UPD_USER_ID:
    ID = 8, John
    Thank You.

    Use dbms_xslprocessor.valueOf and dbms_xmldom.getnodevalue to get the value of node
    eg: l_doc is paresed XML doc with nodes as partdetails and part
    declare
      l_n       dbms_xmldom.DOMNode;
      l_nl      dbms_xmldom.DOMNodeList;
    l_partname varchar2(100);
    begin
    ---parsing code--
    l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part');
    FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
      l_n := dbms_xmldom.item(l_nl, cur_emp);
      dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname);
    dbms_output.put_line(l_partname);
    end loop;
    end;Edited by: SBH on Jul 13, 2010 11:06 AM

  • Can't download an xml file to desktop - Need help

    Hello, I need to save an xml file to my desktop. Each time I try, the xml file saves as a Final Cut Pro icon. When I try to open or upload the xml file - Final Cut automatically opens (which I don't want) and it is unable to show/translate the xml. How can I get my imac to download and upload xml properly?
    I need to do this so that I can use the bulk mail "Dazzle" function on Endicia for online postage. Help please and thanks so much.

    Sean Moor wrote:
    Okay, for Endicia to open the xml file it has to be in a format such as my_file.xml but when I try to put it onto my desktop, the .xml file defaults to a Text Edit file for example my_file.xml.txt
    Just highlight the file, hit the "return" key, and you can edit the file's name. Just highlight ".txt" and delete it. You'll should get a prompt asking you if you really want to change the extension to "xml" from "txt". Just click on the "Use xml" button. That should change the extension.
    You can also edit the extension in the "Get Info" inspector in the Finder. Just highlight your file and use the "command"-"i" key combo or choose "Get Info" from the Finder's File menu.
    You shouldn't need Office to work with XML files. They're just text files. In fact, a great app for working with XML files is free: TextWrangler is really good for editing XML files...
    charlie

  • ABAP to XML conversion...need help for XSTL coding

    Hi,
    I am trying to convert ABAP internal table to XML format. I am using CALL TRANSFORMATION command. But i am not getting the exact conversion of my internal table data as i am lagging in perfection of XSLT coding that i have to maintain(in call transformation command).
    I am passing the data with internal table which has deep structuring( 2 other internal tables(table types) inside it).
    i am facing issue in writing the XSLT format coding(Tcode:XSLT_TOOL). I need some help on this.
    Thanks,
    Mahidhar.

    Hi,
    Can you please share the XSLT program that you have created and also your ABAP structure that is going to hold the data.
    Thanks,
    Aanand.

  • New to PL/SQL needs help?

    I am new to PL/SQL and i want to write a procedure to display the fields returned by the select statement by the procedure to display on the Web Page.
    Here i have written a small procedure to display fields on the web page.
    Create or Replace procedure Try(id number) is
    Begin
    select ename,empno,job,sal from emp where empno=id;
    end Try;
    Can i call this procedure instead of writting the SQL Code in Java for displaying the ename,empno,job,sal.

    I am new to PL/SQL and i want to write a procedure to
    display the fields returned by the select statement
    by the procedure to display on the Web Page.
    Here i have written a small procedure to display
    fields on the web page.
    Create or Replace procedure Try(id number) is
    Begin
    select ename,empno,job,sal from emp where empno=id;
    end Try;
    Can i call this procedure instead of writting the SQL
    Code in Java for displaying the ename,empno,job,sal.Nice and helpful, guys.
    Presumably you have a Java procedure that will call this procedure and display on the webpage. So you need to return the values to the Java. There are many ways to do this - you could have 1 OUT parameter for each column, or return a record, or a refcursor.
    Ideally, you'll get a PL/SQL developer to handle that end, or go on a course yourself.

  • XML in java..need help with it

    hi, ive been programming in java for quite some time now. now im learning how to integrate it with XML. I am learning XML right now. I am trying to deveop a program, using java and XML which can store contacts of a few person(using XML) and then retrieve the contact of a certain person when asked (using java).
    I have defined the scema in a file name: contactlist-schema
    and the corrsponding XML file is named: contactlist.xml
    I have created a java program to traverse the contactlist.xml file (document = builder.parse(new File("contactlist.xml")))
    it compiles successfully, but when I try to execute it, it gives me this msg:
    Parse error: Element type "contactlist" is not declared.
    Can somebody pleeeaaase help me with this problem

    i am using DOM, the schema is:
    <?xml version = "1.0"?>
    <!DOCTYPE contactlist-schema>
    <Schema xmlns = "urn:schemas-microsoft-com:xml-data"
         xmlns:dt = "urn:schemas-microsoft-com:datatypes">
    <ElementType name = "contactlist" model = "closed">
         <element type = "contact" minOccurs = "0" maxOccurs = "*"/>
    </ElementType>
    <ElementType name = "contact" model = "closed">
         <element type = "name" minOccurs = "0" maxOccurs = "*"/>
    </ElementType>
    <ElementType name = "name" model = "closed">
         <AttributeType name = "tel" dt:type = "string"/>
         <attribute type = "tel"/>
         <AttributeType name = "email" dt:type = "string"/>
         <attribute type = "email"/>
    </ElementType>
    </Schema>
    the corresponding xml file is:
    <?xml version = "1.0"?>
    <!DOCTYPE contactlist>
    <contactlist xmlns = "x-schema:contactlist-schema.xml">
         <contact>
              <name>
                   Sarah
                   <tel> 0161-786-8611 </tel>
                   <email> [email protected] </email>
              </name>
         </contact>
         <contact>
              <name>
                   Anne
                   <tel> 0781-787-8956 </tel>
                   <email> [email protected] </email>
              </name>
         </contact>
         <contact>
              <name>
                   Zac
                   <tel> 0795-123-4567 </tel>
                   <email> [email protected] </email>
              </name>
         </contact>
         <contact>
              <name>
                   Lena
                   <tel> 0414-456-1234 </tel>
                   <email> [email protected] </email>
              </name>
         </contact>
         <contact>
              <name>
                   Lin
                   <tel> 0786-025-6974 </tel>
                   <email> [email protected] </email>
              </name>
         </contact>
         <contact>
              <name>
                   Emma
                   <tel> 0161-881-1234 </tel>
                   <email> [email protected] </email>
              </name>
         </contact>
    </contactlist>

  • SQL: Need help putting single quote around string

    I want to put single quotes around string in my output.
    I am running the following command as a test:
    select ' ' hello ' ' from dual;
    My expectation is to get 'hello' (Single quote around hello)
    However I am getting the following error:
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected
    When I do SHOW ALL at my SQL command prompt, the escape is set as follows:
    escape "\" (hex 5c)
    I even tried: select '\'hello\'' from dual;
    I get back: select ''hello'' from dual
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected

    Hi,
    user521525 wrote:
    I want to put single quotes around string in my output.
    I am running the following command as a test:
    select ' ' hello ' ' from dual;
    My expectation is to get 'hello' (Single quote around hello)You probably read that you can get a single-quote within a string literal by using two of them in a row.
    That's true, but they really have to be in a row (no spaces in between), and you still need the single-quotes at the beiginning and end of the literal.
    So what you want is
    SELECT  '''hello'''
    FROM    dual;Starting in Oracle 10, you can also use Q-notation, For example:
    SELECT  Q'['hello']'
    FROM    dual;

  • Merge Two SQL - need help

    Hi All,
    Need some tips - like i have two different process runing with just only a SQL query on each.
    The both the process SQL Query is 90% similar Rather the Second sql has extra two columns
    and few filterning conditions is different which is Marked in bold. My question is there any way that
    i can write a single SQL statement that works for my both process. The Difference between the
    Query 1 and Query 2 have marked in Bold/underlined.
    Query 1
    SELECT SUBCON.MEME_CK,MEMBER_ID,LINE_NUMBER,RECIPIENT_NUMBER,MEMBER_LAST_NAME,MEMBER_FIRST_NAME,MEMBER_MIDDLE_INIT,MEMBER_SSN,MEMBER_DOB,
           MEMBER_ADDRESS_1,MEMBER_ADDRESS_2,MEMBER_CITY,MEMBER_STATE,MEMBER_ZIP_CODE,MEMBER_COUNTY_CODE,MEMBER_SEX,MEMBER_PHONE_NUMBER,
           HH_LAST_NAME,HH_FIRST_NAME,RELATIONSHIP_CODE,PCP_ID_NUMBER,PCP_NAME,PCP_PHONE_NUMBER,PCP_ADDRESS_1,PCP_ADDRESS_2,PCP_CITY,
           PCP_STATE,PCP_ZIP_CODE,PCP_COUNTY_CODE,PCP_EFFECTIVE_DATE,PCD_ID_NUMBER,PCD_NAME,PCD_PHONE_NUMBER,PCD_ADDRESS_1,
           PCD_ADDRESS_2,PCD_CITY,PCD_STATE,PCD_ZIP_CODE,PCD_COUNTY_CODE,PCD_EFFECTIVE_DATE,GROUP_EFF_DATE,GROUP_TERM_DATE,
           GROUP_NUMBER,PROGRAM_STATUS_CODE,LANGUAGE_INDICATOR,VISION_IMP_IND,HEARING_IMP_IND,SPECIAL_NEEDS_FLAG,ELIG_EFF_DATE,
           ELIG_TERM_DATE,BEN_GROUP_NO,BEN_GROUP_EFF_DT,MEDICARE_IND,TPL_RX_PAYER,TPL_RX_PAYER_EFF_DT,TPL_RX_PAYER_NAME,INSURANCE_CODE,
           POLICY_NUMBER,TYPE_OF_COVERAGE,LOB,COUNTY_STATE_RECORD,STATE_RECORD_NUMBER,GROUP_CODE,REV_CATEGORY_CODE,AQ_IND,MECD_CSCS_ID,
           MECB_EFF_DT,MCRE_ID,MECB_TERM_DT,rtrim(SBAD_PHONE) as "SBAD_PHONE"
    FROM      EXT_MEGD_SBCN_ELG_DLY SUBCON,
              CMC_MECD_MEDICAID MECD,
              CMC_SBAD_ADDR SBAD,
              CMC_MEME_MEMBER MEME
    WHERE     SUBCON.MEME_CK = MECD.MEME_CK
    AND        DATEDIFF(mm,MEMBER_DOB, DATEADD(mm,  1,GETDATE())) < 25_
    AND        Right(MECD_MCTR_AIDC,2) not in ('31', '33')
    AND        MECD_MCTR_AIDC Not in ('PC36','J36')
    AND        SUBCON.MEME_CK = MEME.MEME_CK
    AND        MEME.SBSB_CK *= SBAD.SBSB_CK
    AND        SBAD.SBAD_TYPE = "1"
    AND        SBAD.SBAD_PHONE <> " "
    AND        SBAD.SBAD_PHONE <> "0000000000"
    AND        CHAR_LENGTH(RTRIM(SBAD_PHONE)) < 11Query 2
    SELECT SUBCON.MEME_CK,MEMBER_ID,LINE_NUMBER,RECIPIENT_NUMBER,MEMBER_LAST_NAME,MEMBER_FIRST_NAME, MEMBER_MIDDLE_INIT,MEMBER_SSN,MEMBER_DOB,
           MEMBER_ADDRESS_1,MEMBER_ADDRESS_2,MEMBER_CITY,MEMBER_STATE,MEMBER_ZIP_CODE,MEMBER_COUNTY_CODE,MEMBER_SEX,MEMBER_PHONE_NUMBER,
           HH_LAST_NAME,HH_FIRST_NAME,RELATIONSHIP_CODE,PCP_ID_NUMBER,PCP_NAME,PCP_PHONE_NUMBER,PCP_ADDRESS_1,PCP_ADDRESS_2,PCP_CITY,
           PCP_STATE,PCP_ZIP_CODE,PCP_COUNTY_CODE,PCP_EFFECTIVE_DATE,PCD_ID_NUMBER,PCD_NAME,PCD_PHONE_NUMBER,PCD_ADDRESS_1,PCD_ADDRESS_2,
           PCD_CITY,PCD_STATE,PCD_ZIP_CODE,PCD_COUNTY_CODE,PCD_EFFECTIVE_DATE,GROUP_EFF_DATE,GROUP_TERM_DATE,GROUP_NUMBER,PROGRAM_STATUS_CODE,
           LANGUAGE_INDICATOR,VISION_IMP_IND,HEARING_IMP_IND,SPECIAL_NEEDS_FLAG,ELIG_EFF_DATE,ELIG_TERM_DATE,BEN_GROUP_NO,BEN_GROUP_EFF_DT,
           MEDICARE_IND,TPL_RX_PAYER,TPL_RX_PAYER_EFF_DT,TPL_RX_PAYER_NAME,INSURANCE_CODE,POLICY_NUMBER,TYPE_OF_COVERAGE,LOB,COUNTY_STATE_RECORD,
           STATE_RECORD_NUMBER,GROUP_CODE,REV_CATEGORY_CODE,AQ_IND,MECD_CSCS_ID,MECB_EFF_DT,MCRE_ID,MECB_TERM_DT,RTRIM(SBAD_PHONE) as "SBAD_PHONE",
           PRCF_MCTR_SPEC,PRAD_FAX
    FROM      EXT_MEGD_SBCN_ELG_DLY SUBCON,
              CMC_MECD_MEDICAID MECD,
              CMC_SBAD_ADDR SBAD,
              CMC_MEME_MEMBER MEME,
              CMC_PRPR_PROV    PRPR,_
              CMC_PRAD_ADDRESS PRAD_
    WHERE     SUBCON.MEME_CK = MECD.MEME_CK
    AND        Right(MECD_MCTR_AIDC,2) not in ('31', '33')
    AND        MECD_MCTR_AIDC Not in ('PC36','J36')
    AND        SUBCON.MEME_CK = MEME.MEME_CK
    AND        SUBCON.PCP_ID_NUMBER  = PRPR.PRPR_ID*_
    AND        SUBCON.PCP_ID_NUMBER  = PRAD.PRAD_ID*_
    AND        PRAD.PRAD_TYPE = 'PRI'_
    AND        (CONVERT(CHAR(10),GETDATE(),101))  BETWEEN PRAD.PRAD_EFF_DT AND PRAD.PRAD_TERM_DTAND        MEME.SBSB_CK *= SBAD.SBSB_CK_AND        SBAD_TYPE = "1"
    AND        SBAD_PHONE <> " "
    AND        SBAD_PHONE <> "0000000000"
    AND        CHAR_LENGTH(RTRIM(SBAD_PHONE)) < 11Any suggestions Welcome.
    Edited by: USER_X on May 18, 2009 11:03 AM

    Hi,
    The simplest thing, and perhaps the fastest, is to do a UNION, as Someoneelse suggested.
    See [this thread|http://forums.oracle.com/forums/message.jspa?messageID=3430965#3430965] for an example.
    Depending on your data, you could do an Outer Join of the two tables that are only in Query 2 to the other tables.
    The WHERE clause would look something like this:
    WHERE     SUBCON.MEME_CK = MECD.MEME_CK
    AND        Right(MECD_MCTR_AIDC,2) not in ('31', '33')
    AND        MECD_MCTR_AIDC Not in ('PC36','J36')
    AND        SUBCON.MEME_CK = MEME.MEME_CK
    AND        SBAD_PHONE  " "
    AND        SBAD_PHONE  "0000000000"
    AND        CHAR_LENGTH(RTRIM(SBAD_PHONE)) < 11
    AND        (     DATEDIFF (mm, MEMBER_DOB, DATEADD(mm,  1,GETDATE())) < 25     -- Extra condition from Query 1
            OR  (                                                                    -- Extra conditions from Query 2
                       SUBCON.PCP_ID_NUMBER   = PRPR.PRPR_ID
              AND   SUBCON.PCP_ID_NUMBER   = PRAD.PRAD_ID
              AND   PRAD.PRAD_TYPE          = 'PRI'_
              AND   (CONVERT(CHAR(10),GETDATE(),101))  BETWEEN PRAD.PRAD_EFF_DT
                                              AND      PRAD.PRAD_TERM_DT
              AND   MEME.SBSB_CK           = SBAD.SBSB_CK
              AND   SBAD_TYPE               = 1
            )Since all the tables in the Outer Join are referenced in the conditions from Query 2, this has the effect of making that an Inner Join unless the extra conditions from Query 1 were met.
    iIn the SELECT claue, use a CASE expression for each column that occurs only in Query 2 that repeats all the extra conditions for Query 2:
    ,       CASE
              WHEN  SUBCON.PCP_ID_NUMBER   = PRPR.PRPR_ID
              AND   SUBCON.PCP_ID_NUMBER   = PRAD.PRAD_ID
              AND   PRAD.PRAD_TYPE          = 'PRI'_
              AND   (CONVERT(CHAR(10),GETDATE(),101))  BETWEEN PRAD.PRAD_EFF_DT
                                              AND      PRAD.PRAD_TERM_DT
              AND   MEME.SBSB_CK           = SBAD.SBSB_CK
              AND   SBAD_TYPE               = 1
              THEN  PRCF_MCTR_SPEC
           END     AS PRCF_MCTR_SPECThat column will be NULL if the extra conditions from Query 2 are not met.
    Instead of computing all those extra conditions over and over again, you may want to compute them once for all in a sub-query:
    SELECT  ...
    ,       CASE
              WHEN  SUBCON.PCP_ID_NUMBER   = PRPR.PRPR_ID
              AND   SUBCON.PCP_ID_NUMBER   = PRAD.PRAD_ID
              AND   PRAD.PRAD_TYPE          = 'PRI'_
              AND   (CONVERT(CHAR(10),GETDATE(),101))  BETWEEN PRAD.PRAD_EFF_DT
                                              AND      PRAD.PRAD_TERM_DT
              AND   MEME.SBSB_CK           = SBAD.SBSB_CK
              AND   SBAD_TYPE               = 1
              THEN  1
                                    ELSE  0
           END     AS query_2_extraThen, in the main querry, you can use use that column:
    WHERE     ...
    AND        (     DATEDIFF (mm, MEMBER_DOB, DATEADD(mm,  1,GETDATE())) < 25     -- Extra condition from Query 1
            OR     query_2_extra = 1                                              -- Extra conditions from Query 2
            )

  • XML tools for Java (need help getting started)

    Hi,
    I have been using Java for some time. However, I am new to XML and the tools Java has available to utilize such data.
    What packages, classes, etc are available to read and write XML data?
    Thank you in advance. Happy holidays.
    Cheers,
    Christopher

    I've been using a third-party library called JDOM for well over two years and I highly recommend it for your XML processing needs. It recently reached its first productions release and is available for download at http://www.jdom.org.
    Shaun

  • XML Huge database files, NEED HELP !!!

    Hello to the community.
    We need to store about ONE MILLION XML FILES inside the database.
    BUT we need to use all functionality of XML Structure to look for
    information inside these files (CONTAINS).
    My question is:
    What is the best way to store them:
    like XML files inside CLOB ?
    or fragment the files inside tables ?
    Using ConText Option ?
    Using CONTAINS functions ?
    Is ConText Option supports CONTAINS function ?!?
    We have many queries with text searching...
    What is the best way to store this so we have best velocity to
    acces to the info ?
    Thanks to answer soon
    MasterPh
    null

    Let me try and answer your question. First the CONTAINS
    operator in Intermedia Text (formerly Context) will allow you to
    search for data between tags of an XML document stored as a
    CLOB. Whether you should distribute your XML documents across
    tables is largely a function of how you want the data searched
    retrieved. Currently the XML search function operates within a
    column and thus if you want the entire doc back it would be best
    to store it as a whole. Once iFS is released you will be able
    to distribute the doc across tables and return it as a whole or
    in parts.
    Chack out http://www.oracle.com/database/options/ifs.htm and
    http://www.oracle.com/database/options/intermedia.htm for more
    details.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Philippe Thomassigny (guest) wrote:
    : Hello to the community.
    : We need to store about ONE MILLION XML FILES inside the
    database.
    : BUT we need to use all functionality of XML Structure to look
    for
    : information inside these files (CONTAINS).
    : My question is:
    : What is the best way to store them:
    : like XML files inside CLOB ?
    : or fragment the files inside tables ?
    : Using ConText Option ?
    : Using CONTAINS functions ?
    : Is ConText Option supports CONTAINS function ?!?
    : We have many queries with text searching...
    : What is the best way to store this so we have best velocity to
    : acces to the info ?
    : Thanks to answer soon
    : MasterPh
    null

  • Concantenate SQL, need help

    I have a Table where columns 8, 9, 10, 11, and 12 need to be concatenated into a single column CUST_ADDRESS. I've already added the new column to the end of the Table.
    column 8 is: ADDRESS
    column 9 is: ADDRESS 2
    column 10 is: CITY
    column 11 is: STATE
    column 12 is: ZIP-CODE
    ADDRESS( )ADDRESS 2( )CITY(, )STATE( )ZIP
    I've done some research already and I think I found something that will work. The only problem is that I only need the 5 columns to be concatenated, there is 23 columns total in the Table. Also (this is not a big deal), but not sure if it would be possible to also use a ", " between the CITY and STATE and the rest can use a SPACE in the concatenation.
    Help would be appreciated, thanks!
    def Delimiter=" "
    SELECT
    ID,
    SUBSTR(MAX(REPLACE(
    SYS_CONNECT_BY_PATH(STRVAL, '/')
    ,'/','&Delimiter')),2) Concatenated_String
    FROM (
    select A.*,
    row_number() OVER (Partition by ID order by ID) ROW#
    from TMP_TEST A)
    START WITH ROW#=1
    CONNECT BY PRIOR ID=ID AND PRIOR row# = row# -1
    GROUP BY ID;

    Hi,
    How about:
    UPDATE  table_x
    SET     cust_address =  address
            || ' ' ||    address_2
            || ' ' ||     city
            || ',' ||     state
            || ' ' ||     zip_code;this will append the delimiters, even if some of the columns are NULL. For example, if only zip_code is actually present, cust_address will be something like ' , 27607' (starting with 2 spaces, a comma, and then another space).
    If you don't like that, try the following variation, which will omit any delimiter if the item immediately after it is NULL:
    UPDATE  table_x
    SET     cust_address =  address
            || NVL2 (address_2,     ' ' || address_2,     NULL)
            || NVL2 (city,     ' ' || city,          NULL)
            || NVL2 (state,     ',' ||     state,          NULL)
            || NVL2 (zip_code),     ' ' ||     zip_code,     NULL);

  • Beginning PL/sql Need help

    I have around 120 slightly different text files. I was hoping to be able to read
    Specific data from each then design a re-useable process to import into an oracle table.
    Can anybody advise me of the most appropriate method? If there is some example code
    That can help me that would be magnificent. Thank you in advance.
    Neil

    SqlLdr is a utility that enables you to load data into tables.
    Examples:
    Loading variable length
    LOAD DATA
    INFILE *
    INTO TABLE dept
    FIELDS TERMINATED BY , OPTIONALLY ENCLOSED BY "
    (deptno, dname, loc)
    BEGINDATA
    12,RESEARCH,"SARATOGA"
    10,"ACCOUNTING",CLEVELAND
    11,"ART",SALEM
    13,FINANCE,"BOSTON"
    loading a fixed format file
    LOAD DATA
    INFILE ulcase2.dat
    INTO TABLE emp
    (empno POSITION(01:04) INTEGER EXTERNAL,
    ename POSITION(06:15) CHAR,
    job POSITION(17:25) CHAR,
    mgr POSITION(27:30) INTEGER EXTERNAL,
    sal POSITION(32:39) DECIMAL EXTERNAL,
    comm POSITION(41:48) DECIMAL EXTERNAL,
    deptno POSITION(50:51) INTEGER EXTERNAL)
    Loading a Delimited, free format
    LOAD DATA
    INFILE *
    APPEND
    INTO TABLE emp
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY "
    (empno, ename, job, mgr,
    hiredate DATE(20) "DD-Month-YYYY",
    sal, comm, deptno CHAR TERMINATED BY :,
    projno,
    loadseq SEQUENCE(MAX,1))
    BEGINDATA
    7782, "Clark", "Manager", 7839, 09-June-1981, 2572.50,, 10:101
    7839, "King", "President", , 17-November-1981,5500.00,,10:102
    7934, "Miller", "Clerk", 7782, 23-January-1982, 920.00,, 10:102

  • Sql-need help very complex query

    Hi all,
    I have a big SELECT statement hen i run it,it gives ORA-22813 error.
    Ora-22813:- The Collection value from one of the inner sub queries has exceeded the system limits and hence this error.
    It would be really great if you all could please help me in re-writing the inner join SELECTS in any other way so that we can process large amout of data.
    SELECT * FROM (SELECT
    mcat.CATALOG_ITEM_ID,
    mcat.CATALOG_ITEM_NAME ,
    mcat.DESCRIPTION,
    mcat.CATALOG_ITEM_TYPE,
    mcat.DELIVERY_METHOD,
    XMLElement("TRAINING_PLAN",XMLAttributes( TP.TPLAN_ID as "id" ),
    XMLELEMENT("COMPLETE_QUANTITY", TP.COMPLETE_QUANTITY),
    XMLELEMENT("COMPLETE_UNIT", TP.COMPLETE_UNIT),
    XMLElement("TOTAL_CREDITS", TP.numberOfCredits ),
    XMLELEMENT("IS_CREDIT_BASED", TP.IS_CREDIT_BASED),
    XMLELEMENT("IS_FOR_CERT", TP.IS_FOR_CERT),
    XMLELEMENT("ACCREDIT_ORG_NAME", TP.ACCRED_ORG_NAME),
    XMLELEMENT("ACCREDIT_ORG_ID", TP.accredit_org_id ),
    XMLElement("OBJECTIVE_LIST", TP.OBJECTIVE_LIST )
    ).extract('/').getClobVal() AS PLAN_LIST
    FROM
    student_master_catalog mcat
    INNER JOIN
    (SELECT stu_tp.TPLAN_ID,
    stu_tp.COMPLETE_QUANTITY,
    stu_tp.COMPLETE_UNIT,
    stu_tp.TPLAN_XML_DATA.extract('//numberOfCredits/text()').getStringVal() as numberOfCredits,
    stu_tp.IS_CREDIT_BASED,
    stu_tp.IS_FOR_CERT,
    stu_oa.ACCRED_ORG_NAME,
    stu_tp.TPLAN_XML_DATA.extract('//accreditingOrg/text()').getStringVal() as accredit_org_id,
    objective_list.OBJECTIVE_LIST
    FROM
    student_training_catalog stu_tp
    LEFT OUTER JOIN
    stu_accrediting_org stu_oa on stu_tp.TPLAN_XML_DATA.extract('//accreditingOrg/text()').getStringVal() = stu_oa.ACCRED_ORG_ID
    INNER JOIN
    (SELECT *
    FROM
    (SELECT
    stu_tpo.TPLAN_ID AS OBJECTIVE_TPLAN_ID,
    XMLAgg(
    XMLElement("OBJECTIVE",
    XMLElement("OBJECTIVE_ID",stu_tpo.T_OBJECTIVE_ID ),
    XMLElement("OBJECTIVE_NAME",stu_to.T_OBJECTIVE_NAME ),
    XMLElement("OBJECTIVE_REQUIRED_CREDITS_OR_ACTIVITIES",stu_tpo.REQUIRED_CREDITS ),
    XMLElement("ITEM_ORDER", stu_tpo.ITEM_ORDER ),
    XMLElement("ACTIVITY_LIST", activity_list.ACTIVITY_LIST )
    ) as OBJECTIVE_LIST
    FROM
    stu_TP_OBJECTIVE stu_tpo
    INNER JOIN
    stu_TRAINING_OBJECTIVE stu_to ON stu_tpo.T_OBJECTIVE_ID = stu_to.T_OBJECTIVE_ID
    INNER JOIN
    (SELECT *
    FROM
    (SELECT stu_toa.T_OBJECTIVE_ID AS ACTIVITY_TOBJ_ID, XMLAgg(
    XMLElement("ACTIVITY",
    XMLElement("ACTIVITY_ID",stu_toa.ACTIVITY_ID ),
    XMLElement("CATALOG_ID",COALESCE(stu_c.CATALOG_ID, COALESCE( stu_e.CATALOG_ID, stu_t.CATALOG_ID ) ) ),
    XMLElement("CATALOG_ITEM_ID",COALESCE(stu_c.CATALOG_ITEM_ID, COALESCE( stu_e.CATALOG_ITEM_ID, stu_t.CATALOG_ITEM_ID ) ) ),
    XMLElement("DELIVERY_METHOD",COALESCE(stu_c.DELIVERY_METHOD, COALESCE( stu_e.DELIVERY_METHOD, stu_t.DELIVERY_METHOD ) ) ),
    XMLElement("ACTIVITY_NAME",COALESCE(stu_c.COURSE_NAME, COALESCE( stu_e.EVENT_NAME, stu_t.TEST_NAME ) ) ),
    XMLElement("ACTIVITY_TYPE",initcap( stu_toa.ACTIVITY_TYPE ) ),
    XMLElement("IS_REQUIRED",stu_toa.IS_REQUIRED ),
    XMLElement("IS_PREFERRED",stu_toa.IS_PREFERRED ),
    XMLElement("NUMBER_OF_CREDITS",stu_lac.CREDIT_HOURS),
    XMLElement("ITEM_ORDER", stu_toa.ITEM_ORDER )
    )) as ACTIVITY_LIST
    FROM stu_TRAIN_OBJ_ACTIVITY stu_toa
    LEFT OUTER JOIN
    SELECT distinct lac.LEARNING_ACTIVITY_ID, lac.CREDIT_HOURS
    FROM student_training_catalog tp
    INNER JOIN stu_TP_OBJECTIVE tpo on tp.TPLAN_ID = tpo.TPLAN_ID
    INNER JOIN stu_TRAIN_OBJ_ACTIVITY toa on tpo.T_OBJECTIVE_ID = toa.T_OBJECTIVE_ID
    INNER JOIN stu_LEARNINGACTIVITY_CREDITS lac on lac.LEARNING_ACTIVITY_ID = toa.ACTIVITY_ID and tp.TPLAN_XML_DATA.extract                  ('//accreditingOrg/text()').getStringVal() = lac.ACC_ORG_ID
    where tp.tplan_id ='************'*
    ) stu_lac ON stu_lac.LEARNING_ACTIVITY_ID = stu_toa.ACTIVITY_ID        ------>This Select returns correct no. of rows
    This below SELECT inside the LEFT OUTER JOIN is the Problem.it returns too much because 3 tables are joined directly without any value qualification.
    LEFT OUTER JOIN
    ( SELECT ch.COURSE_HISTORY_ID, stu_c.COURSE_NAME, mca.catalog_item_id, mca.catalog_id, mca.delivery_method
    FROM stu_COURSE stu_c
    LEFT OUTER JOIN stu_course_history ch on stu_c.course_id = ch.ch_course_id -
    If i can qualify here with ch.ch_course_id = stu_toa.ACTIVITY_ID   (stu_toa.ACTIVITY_ID from the above select with correct no.  of   rows )
    Here,i get erros because i cant access outside values inside a left outer join
    LEFT OUTER JOIN student_master_catalog mca on ch.course_history_id = mca.catalog_item_id
    ) stu_c ON stu_c.COURSE_HISTORY_ID = stu_toa.ACTIVITY_ID
    LEFT OUTER JOIN
    (SELECT stu_e.EVENT_ID, stu_e.EVENT_NAME, mca.catalog_item_id, mca.catalog_id, mca.delivery_method FROM stu_EVENTS stu_e LEFT OUTER JOIN student_master_catalog mca on stu_e.event_Id = mca.catalog_item_id ) stu_e ON stu_e.EVENT_ID = stu_toa.ACTIVITY_ID
    LEFT OUTER JOIN
    (SELECT stu_t.TEST_HISTORY_ID, stu_t.TEST_NAME, mca.catalog_item_id, mca.catalog_id, mca.delivery_method FROM stu_TEST_HISTORY stu_t LEFT OUTER JOIN student_master_catalog mca on stu_t.test_history_id = mca.catalog_item_id) stu_t ON stu_t.test_history_id = stu_toa.ACTIVITY_ID
    GROUP BY stu_toa.T_OBJECTIVE_ID) ) activity_list ON activity_list.ACTIVITY_TOBJ_ID = stu_tpo.T_OBJECTIVE_ID
    GROUP BY stu_tpo.TPLAN_ID) ) objective_list ON objective_list.OBJECTIVE_TPLAN_ID = stu_tp.TPLAN_ID
    )TP ON TP.TPLAN_ID = mcat.CATALOG_ITEM_ID
    WHERE
    mcat.CATALOG_ITEM_ID = '*****************' and mcat.CATALOG_ORG_ID = '********')
    Edited by: user10817659 on Jan 16, 2009 12:49 PM
    Edited by: user10817659 on Jan 16, 2009 12:51 PM
    Edited by: user10817659 on Jan 16, 2009 12:52 PM
    Edited by: user10817659 on Jan 16, 2009 12:54 PM

    SELECT distinct lac.LEARNING_ACTIVITY_ID, lac.CREDIT_HOURS
    FROM student_training_catalog tp
    INNER JOIN stu_TP_OBJECTIVE tpo on tp.TPLAN_ID = tpo.TPLAN_ID
    INNER JOIN stu_TRAIN_OBJ_ACTIVITY toa on tpo.T_OBJECTIVE_ID = toa.T_OBJECTIVE_ID
    INNER JOIN stu_LEARNINGACTIVITY_CREDITS lac on lac.LEARNING_ACTIVITY_ID = toa.ACTIVITY_ID and tp.TPLAN_XML_DATA.extract ('//accreditingOrg/text()').getStringVal() = lac.ACC_ORG_ID
    where tp.tplan_id ='************'*
    *) stu_lac ON stu_lac.LEARNING_ACTIVITY_ID = stu_toa.ACTIVITY_ID ------>This Select returns 117 records which is correct no. of rows*
    This below SELECT inside the LEFT OUTER JOIN is the Problem.it returns too much because 3 tables are joined directly without any value qualification.
    LEFT OUTER JOIN
    ( SELECT ch.COURSE_HISTORY_ID, stu_c.COURSE_NAME, mca.catalog_item_id, mca.catalog_id, mca.delivery_method
    FROM stu_COURSE stu_c
    LEFT OUTER JOIN stu_course_history ch on stu_c.course_id = ch.ch_course_id -
    If i can qualify here with ch.ch_course_id = stu_toa.ACTIVITY_ID (stu_toa.ACTIVITY_ID from the above select with correct no. of rows )
    Here,i get erros because i cant access outside values inside a left outer join
    LEFT OUTER JOIN student_master_catalog mca on ch.course_history_id = mca.catalog_item_id
    **Here this query gives me huge 22k*
    *) stu_c ON stu_c.COURSE_HISTORY_ID = stu_toa.ACTIVITY_ID--->This join queriess 117 records from top with 22k records found by the nested selected and fails processing.*
    then here above
    LEFT OUTER JOIN
    (SELECT stu_e.EVENT_ID, stu_e.EVENT_NAME, mca.catalog_item_id, mca.catalog_id, mca.delivery_method FROM stu_EVENTS stu_e LEFT OUTER JOIN student_master_catalog mca on stu_e.event_Id = mca.catalog_item_id ) stu_e ON stu_e.EVENT_ID = stu_toa.ACTIVITY_ID
    LEFT OUTER JOIN
    (SELECT stu_t.TEST_HISTORY_ID, stu_t.TEST_NAME, mca.catalog_item_id, mca.catalog_id, mca.delivery_method FROM stu_TEST_HISTORY stu_t LEFT OUTER JOIN student_master_catalog mca on stu_t.test_history_id = mca.catalog_item_id) stu_t ON stu_t.test_history_id = stu_toa.ACTIVITY_ID
    GROUP BY stu_toa.T_OBJECTIVE_ID) ) activity_list ON activity_list.ACTIVITY_TOBJ_ID = stu_tpo.T_OBJECTIVE_ID
    GROUP BY stu_tpo.TPLAN_ID) ) objective_list ON objective_list.OBJECTIVE_TPLAN_ID = stu_tp.TPLAN_ID
    )TP ON TP.TPLAN_ID = mcat.CATALOG_ITEM_ID
    WHERE
    mcat.CATALOG_ITEM_ID = '*****************' and mcat.CATALOG_ORG_ID = '********')
    We’re getting the following error:*
    ORA-22813: operand value exceeds system limits*
    Cause: Object or Collection value was too large.*
    The size of the value might have exceeded 30k in a SORT context, or the size might be too big for available memory.*

  • Easy t-SQL (need help)

    Hi Gurus,
    colm01 Colum02 colum03 colum04 colum05
    10001 America World 10 null
    10002 Virginia Europe 20 10
    10003 Florida Asia 30 10
    In this table, I want to have a new column (colum06), that gives me NULL for America and 10001 for Virginia and Florida
    Thanks in advance
    ebro

    In this table, I want to have a new column (colum06), that gives me NULL for America and 10001 for Virginia and Florida
    Please try this: 
    SELECT
    CASE
    WHEN Colum02 = N'America' THEN NULL
    WHEN Colum02 IN ( N'Virginia', N'Florida' ) THEN 10001
    END AS Colum06
    FROM [Your Table]
    Cheers,
    Saeid Hasani
    Database Consultant
    Please feel free to contact me at [email protected] as well as on Twitter and Facebook.
    [My Writings on TechNet Wiki] [T-SQL Blog] [Curah!]
    [Twitter] [Facebook] [Email]

Maybe you are looking for

  • How do i install the itunes in a new laptop

    how do I install the itunes in a new laptop?

  • I can't install CC after a PC System Restore

    I am running a PC – Windows 8.1 On Monday September 29th I purchased a 1-year subscription to Adobe Creative Cloud for Photographers. I successfully made a debit card payment and successfully installed the Adobe Creative Cloud for Desktop App then in

  • Chrome://browser/content/tabbrowser xml:1608 stops working etc

    chrome://browser/content/tabbrowser xml:1608 this script or another with the same beginning terms, has been stopping or freezing for a couple of months. It was doing this in both versions of firefox, I thought it was just facebook related but it is n

  • Doubts on Configuring Search

    Hi All, I am new to knowledge Management and have some basic doubts regarding Configuration of Search(TREX). Suppose i assume that, i have all documents in KM repository, well configured in Content Management and my TREX server is running.. Then, i c

  • Transaction type does not exist. Check entries

    Hello all, EBP 5.0, CCM 1.0, unicode When I try to log on different language than English and try to shop system is displaying two messages Internal number range is missing for transaction type. Inform syst. admin Transaction type does not exist. Che