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
        )

Similar Messages

  • Merging two SQLs

    Hi Gurus,
    I have two SQLs which are;
    select bbe
    from alu_sdhnm.dwdm_logical_stats dis_1
    where bbe <= (select max(bbe) from alu_sdhnm.dwdm_logical_stats ic_1 where ic_1.datetime=dis_1.datetime)
    order by bbe desc;
    select es
    from alu_sdhnm.dwdm_logical_stats dis_2
    where es <= (select max(es) from alu_sdhnm.dwdm_logical_stats ic_2 where ic_2.datetime=dis_2.datetime)
    order by es desc;
    Those are showing top es and bbe values inside dwdm_logical_stats table seperately by using correlated sub-query. My question is, how can i see them inside one single query? In addition, in the same row if bbe has the highest value, es has not the highest.
    Thank you,
    Ogan

    I'm forgetting the little detail of the data ;)
    What do each of these give you?
      SELECT
          bbe,
          DENSE_RANK() OVER (ORDER BY BBE DESC) bbe_rank,
          ROW_NUMBER() OVER (ORDER BY BBE DESC) row_num
        FROM alu_sdhnm.dwdm_logical_stats;And:
        SELECT
          es,
          DENSE_RANK() OVER (ORDER BY ES DESC) es_rank,
          ROW_NUMBER() OVER (ORDER BY ES DESC) row_num
        FROM alu_sdhnm.dwdm_logical_stats)And finally:
    SELECT bbe,  bbe_rank, es, es_rank
      FROM (
      SELECT
          bbe,
          DENSE_RANK() OVER (ORDER BY BBE DESC) bbe_rank,
          ROW_NUMBER() OVER (ORDER BY BBE DESC) row_num
        FROM alu_sdhnm.dwdm_logical_stats) ilv1
    JOIN (
        SELECT
          es,
          DENSE_RANK() OVER (ORDER BY ES DESC) es_rank,
          ROW_NUMBER() OVER (ORDER BY ES DESC) row_num
        FROM alu_sdhnm.dwdm_logical_stats) ilv2
    ON (ilv1.row_num = ilv2.row_num)

  • 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

  • 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;

  • 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.

  • Merge two iCal files- Help

    I have two Macs, a desktop and a Macbook air. The desktop had a problem which kept it off line for quite a while. It is now working. I wanted to merge several years worth of old iCal information onto my Macbook Air calendar, which has only recent and future appointments.  I exported the deskto iCal information into a .icbu file. When I tried to import it into my Macbook Air calendar, I got a warning the the current info would be replaced.  
    Any ideas how to do a clean merger?  There would be few, if any duplicate events.
    Thanks

    Randy,
    Use Calendar>File>Export>Export...on the desired calendar. This will create a .ics file for the selected calendar.
    Transfer the .ics file to your desired computer, double click the .ics file and follow the importing prompts. Make sure you import it into your existing calendar. As you indicated there will be duplicates, but it sounds like you will be able to manage and delete them without consequence.
    These comments are made in consideration that you are NOT using iCloud.

  • One ipod two computers need help please

    I have two computers and 1 ipod 60gb video.Computer #1 is my old computer that stores my videos and music files (about 500 total)It has itunes and quicktime installed on it.I just bought a new sony laptop computer and I installed itunes and quicktime on it as well.I have been using my new computer to download all my new and resent music and videos files and storeing them on the new computer.Well I have about 100 or more music files on it now.My question is how do I transfer the new files on my new computer without deleting my old files on my old computer.I do not want to tranfer the files from old computer on to the new one.If I plug in the ipod to the new computer that does not have the old music files from the old computer then all my old music files will be deleted right since it updates the ipod automatactly itunes will detect that the old files are not on the new computer.How can I tranfer my new files to my ipod????I dont want to put my old music files on my new computer.Im new to the ipod world but i have read a bit on the discossions segment.Please please help any body that can give any suggestions.

    I new to this so I'm not sure if this will work.I have been playing and trying different thing. Try making a new playlist, make sure that the music/book you want to add is in that playlist, and update just that playlist,under your preferences. When you are done you will have to change your preference to Manual update. This way I'm just uploading the new stuff and leaving the info that is on the iPod is not effected. I just added a couple of books on CD, listened to them while I ripped some more CD's I have into different playlists, and then added then later. Not sure if it will work with two computers. Right now I'm just working on my laptop, desktop is down and I have not replaced it yet. I hope this helps.

  • 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.*

  • Requirement to combine data in two cubes-need help

    Hi all,
    There is a cube which has Material number and Amount .
    There is one more cube which has material number and salesindicator.
    We need report in such a way that the common material numbers in both cubes should display amount and sales indicator values and uncommon material numbers should also be displayed.
    Suppose MATO01 is material numebr in cube 1 with amount 200.
    It should display same 200 for MATO01 in cube2 even though amount is not an infobject in cube2.
    How to achieve this.
    Please suggest.
    Thanks in advance!

    Hi Pallavi,
    You can create a multiprovider on both the cubes and build a query on this multiprovider.
    In this case, the characteristics from both the cubes will be available for reporting.
    Regards,
    Srinivas Kamireddy.

  • 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]

  • Rank SQL need help

    I have a simple Table with 2 columns, customer_id (distinct) and Spend
    some same fake data
    CUST_ID     SPEND        RANK
    1234          -125           0
    1254          -12             0
    1547          0               0
    5478          0               0
    8874          1               1
    6587          1               2
    65555        124            3
    54784        124            4
    45777        1148          5
    45774        2458          6I need to create a Rank column but only create the Rank for positive transaction, negative and 0 will get a RANK of 0, the rest need to have a rank where low spend gets low rank, and high spend gets high rank. Also if a customer has the same spend just rank them in the Order of the row position, ties can't have the same rank number, what is the best way to do this ?
    was thinking of ising row_number () over, but not sure how to make the RANK of 0 happen.
    I am on 11G, thank you!

    Hi,
    Kodiak_Seattle wrote:
    I have a simple Table with 2 columns, customer_id (distinct) and Spend
    some same fake data
    CUST_ID     SPEND        RANK
    1234          -125           0
    1254          -12             0
    1547          0               0
    5478          0               0
    8874          1               1
    6587          1               2
    65555        124            3
    54784        124            4
    45777        1148          5
    45774        2458          6I need to create a Rank column but only create the Rank for positive transaction, negative and 0 will get a RANK of 0, the rest need to have a rank where low spend gets low rank, and high spend gets high rank. Also if a customer has the same spend just rank them in the Order of the row position, ties can't have the same rank number, What is "row position"?
    The query below will assign unique numbers to ties, but there's no telling which of the tying rows will get the lower number. You can add more expressions to the analytic ORDER BY clause if you want to number the ties in a particular way.
    what is the best way to do this ?
    was thinking of ising row_number () over, Exactly! ROW_NUMBER will assign distinct numbers. RANK or DENSE_RANK would give duplicate results in case of a tie.
    but not sure how to make the RANK of 0 happen.
    I am on 11G, thank you!One way is to use CASE to assign 0 to the non-positive spends, and also to sort negatives at the end when computing the ROW_NUMBERSELECT       cust_id
    ,       spend
    ,       CASE
               WHEN  spend <= 0
               THEN  0
               ELSE  ROW_NUMBER () OVER ( ORDER BY CASE
                                       WHEN spend > 0
                                       THEN spend
                                                                   END
           END          AS rnk
    FROM       fake_data
    ORDER BY  spend
    ;Edited by: Frank Kulash on Jul 20, 2011 3:53 PM
    Here's a slightly more elegant way, that avoids a nested CASE expression:
    SELECT       cust_id
    ,       spend
    ,       CASE
               WHEN  spend <= 0
               THEN  0
               ELSE  ROW_NUMBER () OVER ( PARTITION BY  SIGN (spend)
                                                      ORDER BY      spend
                              ,                 cust_id     DESC     -- or whatever
                                                                   END
           END          AS rnk
    FROM       fake_data
    ORDER BY  spend
    ;I also added an example of numbering ties in a particular order.
    Edited by: Frank Kulash on Jul 20, 2011 4:05 PM

  • Need help in merging two database

    Dear All,
    Can any one please let me know the methodology/Best practices for merging two databases.
    We are having two oracle Database A and B, the data from
    Database A has to be migrated to Database B using PL/SQL scripting.
    it will be a great help,Thanks in advance!

    Hi,
    Use the DB Links and try to use the "MERGE" that is better.
    you can clone it right, almost you are getting the same data from A to B and then you are going to Update is I am correct. Does the "B" consist the data, If yes then you can't clone on exiting DB, As i said above go for DB links and write custom scripts as per your requirement.
    Refer for DB links
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#sthref4108
    - Pavan Kumar N

  • Need help in using sleep function in pl/sql

    Hi,
    need help:
    I have a condition where i want to validate total_pass=total_fail and
    I want to use the sleep function in a pl/sql where i want to wait for 2 minutes ie.checking
    whether total_pass=total_fail based upon class_id .
    I have the data in the table as:
    CLASS_ID TOT_PASS TOT_FAIL
    1 10 10
    2 5 4
    3 6 6
    4 7 5
    Any help will be needful for me

    I'm not quite sure what you are lookg for here, but whatever it is, your code as posted won't do it. You will never break out of the WHILE r_Class.Tot_Pass = r_Class.Tot_Fail loop, since these values will never change because you never get the next record form the cursor.
    From your original data, it looks like your cursor will return multiple rows which implies to me that you want to fetch the first row from the cursor, check if tot_pass = tot_fail, if they are equal, sleep for two minutes then get the next row. This does not make sense to me. Once the select in the cursor is executed, the data it returns will not change due to Oracle's read consistency model, so there seems to me no point in the sleep.
    The other alternative I can see is that you want to check all the returned rows, and if tot_pass = tot_fail for one of the rows (or possibly for all of the rows), then you want to sleep and try again.
    If you can explain in words what it is you are trying to accomplish, someone will be able to point you to a solution.
    John

Maybe you are looking for

  • How do I install Firefox in English on a computer in Mexico?

    ''I have a Dell 2009 computer with 4 gigs of memory. I am running Windows 7 home ultimate. My home is in San Carlos Mexico. I had Firefox installed with the Windows 7 as my web browser. I uninstalled Windows 7 and went back to Windows XP service pack

  • Exporting and color conversion for print

    I have artwork created in Flash MX 2004 that I need to print. I have never done this and am concerned about color matching. I realize that Flash works in RGB; my printers need the file in CMYK and as Photoshop or Illustrator files. Should I export th

  • "Inbound deliveries for PO reciepts with confirmation control keys"

    Hi Gurus, Can somebody tell me the detailed configuaration steps " Inbound deliveries for PO reciepts with confirmation control keys". Thanks Raj

  • Broadcaster Variable Schedule Date

    Is there a way to use a variable for the date and time the broadcaster will email workbooks. We want to email some workbooks right after the financial books close. This date will always change and cannot predict. Is there a userexit or something? Any

  • Installing CS2 on Vista 64

    After many struggles, I recommend the following... 1) Install ALL Service Packs and updates for Microsoft Vista. If you read the details of those upgrades, many of them mention fixing compatibility issues with Adobe CS2 and other Adobe products. 2) A