Extract function

Hi All,
I have a piece of code
DECLARE
V_DOB DATE := '29-FEB-2000';
v_don1 DATE;
BEGIN
SELECT to_date('2003'||lpad(extract(Month FROM V_DOB),2,0)||extract(Day FROM V_DOB), 'YYYYMMDD') into v_don1
FROM DUAL;
dbms_output.put_line(v_don1);
END;The above code is giving error, it is working fine with V_dob as '28-FEB-2000'.
Year 2000 was a leap year so date 29 should be there.
Kindly suggest me what to do?
oracle version : 11.2.0.2.0 Thanks
Edited by: AbSHeik on Nov 16, 2012 10:41 PM

And few more things:
DECLARE
  --"Whenever you assign to a date value, dont assign as string
  --"use TO_DATE, else your code will have a dependency on NLS settings
  /*V_DOB DATE := '29-FEB-2000';*/
  V_DOB DATE := to_date('29-FEB-2000','DD-MON-YYYY');
  v_don1 DATE;
BEGIN
  /*SELECT to_date('2003'||lpad(extract(Month FROM V_DOB),2,0)||
        extract(Day FROM V_DOB), 'YYYYMMDD') into v_don1
  FROM DUAL;*/
  --"You dont need to use SELECT as in above code"
  --"Directly you can assign as below"
  v_don1 := to_date('2004'||
                    lpad(extract(Month FROM V_DOB),2,0)||
                    extract(Day FROM V_DOB), 'YYYYMMDD'
  --"And, whenever you are printing a date, use TO_CHAR
  /*dbms_output.put_line(v_don1);*/
  dbms_output.put_line(to_char(v_don1,'DD-Mon-YYYY'));
END;
{code}
And if your objective is to find out the last day of the same month of a different year, you can use LAST_DAY function
{code}
DECLARE
  V_DOB DATE := to_date('29-FEB-2000','DD-MON-YYYY');
  v_don1 DATE;
BEGIN
  v_don1 := last_day(to_date('2003'||
                    lpad(extract(Month FROM V_DOB),2,0)||
                    '01', 'YYYYMMDD'
  dbms_output.put_line(to_char(v_don1,'DD-Mon-YYYY'));
END;
28-Feb-2003
{code}
{code}
Edited by: jeneesh on Nov 17, 2012 12:46 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Extract function not working with tag attributes

    Hi all,
    I have an xml document stored in the db as an xmlType. I am trying to use the extract function to retrieve values. The extract will work fine on tags without attributes. Any tags with attributes or tags beyond the tags with attributes will not be accessible.
    <tag1>
    <tag2>hi</tag2>
    <tag3 att="hello">bye</tag3>
    <tag4> hi again </tag4>
    </tag1>
    In the example above I can extract tag2 values but not tag3 or tag4 values.
    here is my select statement
    works
    select e.xmlval.extract('/tag1/tag2').getStringval()
    from test_xml e;
    does not work
    select e.xmlval.extract('/tag1/tag2/tag3').getStringval()
    from test_xml e;
    does not work
    select e.xmlval.extract('/tag1/tag2/tag3/tag4').getStringval()
    from test_xml e;
    Any ideas?

    Hi all,
    Found the issue. The problem was that I was not specifying the second argument to the extract function.
    The tag attribute that I was not handling was xmlns="".
    I used this atttribute as the second argument in the extract function and now I am off and running.
    Hope this helps someone.
    Cheers

  • Extract Function return NULL

    Hello All,
    I am new to XML so bear with me. I have a situation where I need to extract column field name from XML file stored in table column. I am trying to use extract function but getting NULL value from below SQL. In this case I am expecting to have list of all caption text listed. Please let me know what wrong I am doing below.
    SELECT X.XML.EXTRACT('/report/criteria/columns/column/columnHeading/caption/text()').GETSTRINGVAL() FROM <Table_name>
    XML File is stored in Column name XML in table
    - <saw:report xmlns:saw="com.siebel.analytics.web/report/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlVersion="201008230" xmlns:sawx="com.siebel.analytics.web/expression/v1.1">
    - <saw:criteria xsi:type="saw:simpleCriteria" subjectArea=""Study Execution"" withinHierarchy="true">
    - <saw:columns>
    - <saw:column xsi:type="saw:switchGroupColumn" columnID="c997a816d5ca37338">
    - <saw:choices>
    - <saw:choice>
    - <saw:column xsi:type="saw:regularColumn" columnID="c8b17a7121096d3b2">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Study"."ICON Study No."</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    - <saw:formatSpec suppress="suppress" wrapText="true" interaction="action">
    - <saw:actionLinks showPopupMenuForOneLink="false">
    - <saw:actionLink actionLinkID="c8b17a7121096d3b2_ale3731f8d930e8604">
    - <saw:action>
    <saw:actionName>Deviations - Site Summary PM Dash Board</saw:actionName>
    - <saw:parameters allowExtraParameters="true">
    - <saw:parameter name="__navigateToBIContent__" type="string" mandatory="true" removable="true" order="999" multiValues="false">
    <saw:prompt>__navigateToBIContent__</saw:prompt>
    <saw:description />
    </saw:parameter>
    </saw:parameters>
    - <saw:assignments>
    - <saw:assign name="__navigateToBIContent__" fixed="true" hidden="true" parentFixed="false" parentHidden="false" xsi:type="saw:stringAssign">
    <saw:value>/shared/Clinical Operations/Project Managment Dashboard/Quality Tab/Deviations - Site Summary PM Dash Board</saw:value>
    </saw:assign>
    </saw:assignments>
    - <saw:implementation xsi:type="saw:ScriptActionType" executeOnClient="true">
    <saw:functionName>__navigateToBIContent__</saw:functionName>
    <saw:scriptLanguage>JScript</saw:scriptLanguage>
    <saw:scriptPath />
    </saw:implementation>
    - <saw:clientImplementation>
    <saw:customisation invokeConfirmation="false" />
    </saw:clientImplementation>
    </saw:action>
    - <saw:linkText>
    <saw:text>Deviation Site Summary</saw:text>
    </saw:linkText>
    </saw:actionLink>
    </saw:actionLinks>
    </saw:formatSpec>
    </saw:displayFormat>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec interaction="none" />
    </saw:displayFormat>
    </saw:columnHeading>
    </saw:column>
    </saw:choice>
    - <saw:choice>
    - <saw:column xsi:type="saw:regularColumn" columnID="cd77e27e7b33767de">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Geography"."Region"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    - <saw:formatSpec suppress="suppress" wrapText="true" interaction="action">
    - <saw:actionLinks showPopupMenuForOneLink="false">
    - <saw:actionLink actionLinkID="cd77e27e7b33767de_alad0f25191c60257b">
    - <saw:action>
    <saw:actionName>Deviations - Site Summary PM Dash Board</saw:actionName>
    - <saw:parameters allowExtraParameters="true">
    - <saw:parameter name="__navigateToBIContent__" type="string" mandatory="true" removable="true" order="999" multiValues="false">
    <saw:prompt>__navigateToBIContent__</saw:prompt>
    <saw:description />
    </saw:parameter>
    </saw:parameters>
    - <saw:assignments>
    - <saw:assign name="__navigateToBIContent__" fixed="true" hidden="true" parentFixed="false" parentHidden="false" xsi:type="saw:stringAssign">
    <saw:value>/shared/Clinical Operations/Project Managment Dashboard/Quality Tab/Deviations - Site Summary PM Dash Board</saw:value>
    </saw:assign>
    </saw:assignments>
    - <saw:implementation xsi:type="saw:ScriptActionType" executeOnClient="true">
    <saw:functionName>__navigateToBIContent__</saw:functionName>
    <saw:scriptLanguage>JScript</saw:scriptLanguage>
    <saw:scriptPath />
    </saw:implementation>
    - <saw:clientImplementation>
    <saw:customisation invokeConfirmation="false" />
    </saw:clientImplementation>
    </saw:action>
    - <saw:linkText>
    <saw:text>Deviation Site Summary</saw:text>
    </saw:linkText>
    </saw:actionLink>
    </saw:actionLinks>
    </saw:formatSpec>
    </saw:displayFormat>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:columnHeading>
    </saw:column>
    </saw:choice>
    - <saw:choice>
    - <saw:column xsi:type="saw:regularColumn" columnID="cb13030672571aad9">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Geography"."Country"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    - <saw:formatSpec suppress="suppress" wrapText="true" interaction="action">
    - <saw:actionLinks showPopupMenuForOneLink="false">
    - <saw:actionLink actionLinkID="cb13030672571aad9_al40e4484c67de09d6">
    - <saw:action>
    <saw:actionName>Deviations - Site Summary PM Dash Board</saw:actionName>
    - <saw:parameters allowExtraParameters="true">
    - <saw:parameter name="__navigateToBIContent__" type="string" mandatory="true" removable="true" order="999" multiValues="false">
    <saw:prompt>__navigateToBIContent__</saw:prompt>
    <saw:description />
    </saw:parameter>
    </saw:parameters>
    - <saw:assignments>
    - <saw:assign name="__navigateToBIContent__" fixed="true" hidden="true" parentFixed="false" parentHidden="false" xsi:type="saw:stringAssign">
    <saw:value>/shared/Clinical Operations/Project Managment Dashboard/Quality Tab/Deviations - Site Summary PM Dash Board</saw:value>
    </saw:assign>
    </saw:assignments>
    - <saw:implementation xsi:type="saw:ScriptActionType" executeOnClient="true">
    <saw:functionName>__navigateToBIContent__</saw:functionName>
    <saw:scriptLanguage>JScript</saw:scriptLanguage>
    <saw:scriptPath />
    </saw:implementation>
    - <saw:clientImplementation>
    <saw:customisation invokeConfirmation="false" />
    </saw:clientImplementation>
    </saw:action>
    - <saw:linkText>
    <saw:text>Deviation Site Summary</saw:text>
    </saw:linkText>
    </saw:actionLink>
    </saw:actionLinks>
    </saw:formatSpec>
    </saw:displayFormat>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec interaction="none" />
    </saw:displayFormat>
    </saw:columnHeading>
    </saw:column>
    </saw:choice>
    </saw:choices>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cf5c435bd3d235724">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Study"."Sponsor Name"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cf48a34febca748ff">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Study"."Project Status"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="ce51ccb4c38ed538f">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Project Goverance"."Project Manager"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cf4bc5bea2531f3fe">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Study"."Indication"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="c430e05de61704a98">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Key Deviations"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cf658139b454c5a7f">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Non-Key Deviations"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="c1276c4cb2684ce42">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Key/Non-Key NA Deviations"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cea25118bedcf2772">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Site Life Cycle Metrics"."# of Sites Activated by Deviation"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    <saw:formatSpec suppress="repeat" wrapText="true" />
    </saw:displayFormat>
    - <saw:tableHeading>
    - <saw:caption fmt="text">
    <saw:text>Site Life Cycle Metrics</saw:text>
    </saw:caption>
    </saw:tableHeading>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    - <saw:caption fmt="text">
    <saw:text># of Sites Activated</saw:text>
    </saw:caption>
    </saw:columnHeading>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cae9b8f9cb7b8daba">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Key Deviations per Active Site"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    - <saw:formatSpec suppress="repeat" wrapText="true">
    <saw:dataFormat minDigits="2" maxDigits="2" commas="true" negativeType="minus" xsi:type="saw:number" />
    </saw:formatSpec>
    </saw:displayFormat>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:columnHeading>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cbb0790d62c120f67">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Site Life Cycle Metrics"."# of Sites Activated with FPS by Deviation"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    <saw:formatSpec suppress="repeat" wrapText="true" />
    </saw:displayFormat>
    - <saw:tableHeading>
    - <saw:caption fmt="text">
    <saw:text>Site Life Cycle Metrics</saw:text>
    </saw:caption>
    </saw:tableHeading>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    - <saw:caption fmt="text">
    <saw:text># of Recruiting Sites (FPS)</saw:text>
    </saw:caption>
    </saw:columnHeading>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cec29c1b67bd731bc">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Key Deviations per Recruiting Site (FPS)"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    - <saw:formatSpec suppress="repeat" wrapText="true">
    <saw:dataFormat minDigits="2" maxDigits="2" commas="true" negativeType="minus" xsi:type="saw:number" />
    </saw:formatSpec>
    </saw:displayFormat>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:columnHeading>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cf52f2d88d2e78ff9">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Subject Life Cycle Metrics"."# of Actual Subjects Randomized by Deviation"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    <saw:formatSpec suppress="repeat" wrapText="true" />
    </saw:displayFormat>
    - <saw:tableHeading>
    - <saw:caption fmt="text">
    <saw:text>Subject Life Cycle Metrics</saw:text>
    </saw:caption>
    </saw:tableHeading>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    - <saw:caption fmt="text">
    <saw:text># of Actual Subjects Randomized</saw:text>
    </saw:caption>
    </saw:columnHeading>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="c804cdbe82e3fa7f3">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Key Deviations per Rand Patient"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    - <saw:formatSpec suppress="repeat" wrapText="true">
    <saw:dataFormat minDigits="2" maxDigits="2" commas="true" negativeType="minus" xsi:type="saw:number" />
    </saw:formatSpec>
    </saw:displayFormat>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:columnHeading>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="ce344decda5f6fd83">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Total Waivers"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    <saw:formatSpec suppress="repeat" wrapText="true" />
    </saw:displayFormat>
    - <saw:tableHeading>
    - <saw:caption fmt="text">
    <saw:text>Deviation Metrics</saw:text>
    </saw:caption>
    </saw:tableHeading>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    - <saw:caption fmt="text">
    <saw:text># Total Waivers</saw:text>
    </saw:caption>
    </saw:columnHeading>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="c0d6921698af79211">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Inclusion/Exclusion Waivers"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cef66aab5dfc4449d">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"- Deviation Metrics"."# Other Waivers"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="cb963b668b55786bb">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Deviation Level"."Deviation Level"</sawx:expr>
    </saw:columnFormula>
    - <saw:displayFormat>
    - <saw:formatSpec suppress="repeat" wrapText="true" interaction="clientEvent">
    <saw:clientEventSpec channel="Level" />
    </saw:formatSpec>
    </saw:displayFormat>
    - <saw:columnHeading>
    - <saw:displayFormat>
    <saw:formatSpec interaction="none" />
    </saw:displayFormat>
    </saw:columnHeading>
    </saw:column>
    - <saw:column xsi:type="saw:regularColumn" columnID="c15b89d8487d41b29">
    - <saw:columnFormula>
    <sawx:expr xsi:type="sawx:sqlExpression">"Deviation"."Deviation Type"</sawx:expr>
    </saw:columnFormula>
    </saw:column>
    </saw:columns>
    - <saw:filter>
    - <sawx:expr xsi:type="sawx:logical" op="and">
    <sawx:expr xsi:type="sawx:savedFilter" path="/shared/Clinical Operations/_filters/Study Execution/PM Dashboard - Quality" name="PM Dashboard - Quality" />
    - <sawx:expr op="prompted" xsi:type="sawx:special">
    <sawx:expr xsi:type="sawx:sqlExpression">"Deviation Level"."Deviation Level"</sawx:expr>
    </sawx:expr>
    </sawx:expr>
    </saw:filter>
    </saw:criteria>
    - <saw:views currentView="0">
    - <saw:view xsi:type="saw:compoundView" name="compoundView!1">
    - <saw:cvTable>
    - <saw:cvRow>
    - <saw:cvCell viewName="titleView!1">
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:cvCell>
    </saw:cvRow>
    - <saw:cvRow>
    <saw:cvCell viewName="columnSelectorView!1" />
    </saw:cvRow>
    - <saw:cvRow>
    - <saw:cvCell viewName="tableView!1">
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:cvCell>
    </saw:cvRow>
    - <saw:cvRow>
    <saw:cvCell viewName="filtersView!1" />
    </saw:cvRow>
    </saw:cvTable>
    </saw:view>
    <saw:view xsi:type="saw:titleView" name="titleView!1" includeName="false" startedDisplay="dateTime" />
    - <saw:view xsi:type="saw:tableView" name="tableView!1" clientEventChannels="MD1" clientEventEnabled="true">
    - <saw:edges>
    - <saw:edge axis="page" showColumnHeader="true">
    - <saw:displayGrandTotals>
    - <saw:displayGrandTotal id="t1" grandTotalPosition="none">
    - <saw:memberFormat>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:memberFormat>
    - <saw:dataBodyFormat>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:dataBodyFormat>
    </saw:displayGrandTotal>
    </saw:displayGrandTotals>
    </saw:edge>
    <saw:edge axis="section" />
    - <saw:edge axis="row" showColumnHeader="true">
    - <saw:displayGrandTotals>
    <saw:displayGrandTotal id="t2" grandTotalPosition="after" />
    </saw:displayGrandTotals>
    - <saw:edgeLayers>
    <saw:edgeLayer type="column" columnID="c997a816d5ca37338" />
    <saw:edgeLayer type="column" columnID="c430e05de61704a98" />
    <saw:edgeLayer type="column" columnID="cf658139b454c5a7f" />
    <saw:edgeLayer type="column" columnID="c1276c4cb2684ce42" />
    <saw:edgeLayer type="column" columnID="cea25118bedcf2772" />
    <saw:edgeLayer type="column" columnID="cae9b8f9cb7b8daba" />
    <saw:edgeLayer type="column" columnID="cbb0790d62c120f67" />
    <saw:edgeLayer type="column" columnID="cec29c1b67bd731bc" />
    <saw:edgeLayer type="column" columnID="cf52f2d88d2e78ff9" />
    <saw:edgeLayer type="column" columnID="c804cdbe82e3fa7f3" />
    - <saw:edgeLayer type="column" columnID="ce344decda5f6fd83">
    - <saw:headerFormat>
    - <saw:displayFormat>
    <saw:formatSpec />
    </saw:displayFormat>
    </saw:headerFormat>
    </saw:edgeLayer>
    <saw:edgeLayer type="column" columnID="c0d6921698af79211" />
    <saw:edgeLayer type="column" columnID="cef66aab5dfc4449d" />
    </saw:edgeLayers>
    </saw:edge>
    <saw:edge axis="column" />
    </saw:edges>
    </saw:view>
    - <saw:view xsi:type="saw:columnSelectorView" name="columnSelectorView!1" labelPosition="left" goButton="false">
    - <saw:selector prompt="true" columnID="c997a816d5ca37338">
    - <saw:label>
    - <saw:caption>
    <saw:text>Select Level</saw:text>
    </saw:caption>
    </saw:label>
    </saw:selector>
    </saw:view>
    - <saw:view xsi:type="saw:dvtchart" name="dvtchart!1">
    - <saw:display type="bar" subtype="default" renderFormat="default" mode="online" xAxisLiveScrolling="false" yAxisLiveScrolling="false" clientEventEnabled="false" animateOnDisplay="true">
    <saw:style barStyle="default" lineStyle="default" scatterStyle="default" fillStyle="default" bubblePercentSize="100" effect="2d" />
    </saw:display>
    - <saw:canvasFormat height="330" width="750" showGradient="true">
    <saw:dataLabels display="default" label="default" position="below" transparentBackground="true" valueAs="default" />
    - <saw:title mode="custom">
    - <saw:caption>
    <saw:text>Severity vs Deviation Type</saw:text>
    </saw:caption>
    </saw:title>
    - <saw:gridlines default="true">
    - <saw:horizontal>
    <saw:major visible="false" />
    <saw:minor visible="false" />
    </saw:horizontal>
    - <saw:vertical>
    <saw:major visible="false" />
    <saw:minor visible="false" />
    </saw:vertical>
    </saw:gridlines>
    </saw:canvasFormat>
    - <saw:selections>
    - <saw:categories>
    - <saw:category>
    <saw:columnRef columnID="c15b89d8487d41b29" />
    </saw:category>
    </saw:categories>
    - <saw:measures showMeasureLabelsOnCategory="false">
    - <saw:column measureType="y">
    <saw:columnRef columnID="c430e05de61704a98" />
    </saw:column>
    - <saw:column measureType="y">
    <saw:columnRef columnID="cf658139b454c5a7f" />
    </saw:column>
    - <saw:column measureType="y">
    <saw:columnRef columnID="c1276c4cb2684ce42" />
    </saw:column>
    </saw:measures>
    - <saw:seriesGenerators>
    <saw:measureLabels />
    </saw:seriesGenerators>
    - <saw:page>
    - <saw:column>
    <saw:columnRef columnID="cb963b668b55786bb" />
    </saw:column>
    </saw:page>
    <saw:sections displayAsSlider="false" />
    </saw:selections>
    - <saw:legendFormat position="default" transparentFill="true">
    <saw:textFormat />
    </saw:legendFormat>
    - <saw:axesFormats syncAxis="false">
    - <saw:axisFormat axis="Y1">
    - <saw:title mode="custom">
    - <saw:caption>
    <saw:text>Severity</saw:text>
    </saw:caption>
    </saw:title>
    <saw:labels />
    <saw:textFormat />
    <saw:scale scaleValues="auto" showMajorTicks="false" showMinorTicks="false" logarithmic="false" defaultTicks="true" />
    </saw:axisFormat>
    - <saw:axisFormat axis="X" displayScaleLabels="true">
    - <saw:title mode="custom">
    - <saw:caption>
    <saw:text>Deviation Type</saw:text>
    </saw:caption>
    </saw:title>
    <saw:labels rotate="15" rotateLabels="true" stagger="false" skip="false" abbreviation="default" />
    <saw:textFormat />
    <saw:scale scaleValues="auto" showMajorTicks="false" showMinorTicks="false" logarithmic="false" />
    </saw:axisFormat>
    </saw:axesFormats>
    - <saw:pageEdgeState>
    - <saw:QDR>
    - <saw:staticMemberGroup>
    - <saw:groupType>
    <sawx:columnRefExpr columnID="cb963b668b55786bb" />
    </saw:groupType>
    - <saw:members xsi:type="saw:stringMembers">
    <saw:value>Patient</saw:value>
    </saw:members>
    </saw:staticMemberGroup>
    </saw:QDR>
    - <saw:selectionGroups>
    <saw:selectionGroup columnID="cb963b668b55786bb" groupID="0" />
    </saw:selectionGroups>
    </saw:pageEdgeState>
    </saw:view>
    <saw:view xsi:type="saw:filtersView" name="filtersView!1" />
    </saw:views>
    <saw:prompts scope="report" subjectArea=""Study Execution"" />
    </saw:report>
    Edited by: Dinesh Chauhan on Jan 19, 2012 4:34 AM

    2) In reality I'll have another column defined in same table which will have same value as columnFormula (from xml file). I would need to extract caption from the XMLType and store in another column.OK, let's see if I understand correctly.
    You want to extract the caption text from the column where the columnFormula contains the value in COL1?
    If I'm correct, it's this one :
    <sawx:expr xsi:type="sawx:sqlExpression">" Site Life Cycle Metrics"."# of Sites Activated with FPS by Deviation"</sawx:expr>Assuming there's a unique match, you can do :
    SQL> SELECT XMLCast(
      2           XMLQuery(
      3             'declare default element namespace "com.siebel.analytics.web/report/v1.1"; (: :)
      4              declare namespace x = "com.siebel.analytics.web/expression/v1.1"; (: :)
      5              /report/criteria/columns/column[ora:contains(columnFormula/x:expr,$val)>0]/columnHeading/caption/text'
      6             passing t.xml
      7                   , t.col1 as "val"
      8             returning content
      9           )
    10           as varchar2(100)
    11         ) as caption_text
    12  FROM temp_xml t
    13  ;
    CAPTION_TEXT
    # of Recruiting Sites (FPS)
    If you want to update the same table, say COL2, you can do it directly like this :
    UPDATE temp_xml t
    SET t.col2 =
           XMLCast(
             XMLQuery(
               'declare default element namespace "com.siebel.analytics.web/report/v1.1"; (: :)
                declare namespace x = "com.siebel.analytics.web/expression/v1.1"; (: :)
                /report/criteria/columns/column[ora:contains(columnFormula/x:expr,$val)>0]/columnHeading/caption/text'
               passing t.xml
                     , t.col1 as "val"
               returning content
             as varchar2(100)
    ;

  • Oracle.xdb.XMLType extract function

    I have an external java program that connect to the database using a thick connection so I can use the methods extract and existsNode available with the XMLType from oracle.xdb.XMLType.
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection(jdbc:oracle:oci8:@,"user","pwd");
    It works fine from the program. When I load the java function in the SQL database I use the default connection
    conn = DriverManager.getConnection("jdbc:default:connection:");
    and the extract function gives the error java.sql.SQLException.
    Is there a way to define the native connection as thin or thick because that was the error I was getting from the client program when I was using thin connection
    Thanks
    Mirette

    Please try and avoid duplicate posts...

  • How to pass parameter into extract function (for XMLTYPE)

    I have a table PROBLEMXML with XMLTYPE field xml_column. In this column there are several deffinitions for the problem. There is no max amount of deffinitions and it can be no definition at all. I need to return all definitions for every problem as a string wirh definitions separated by ";".
    Query
    SELECT extract(prob.Def,'/Definitions/Definition[1]/@var') || ';'|| extract(prob.Def,'/Definitions/Definition[2]/@var')
    FROM PROBLEMXML j ,
    XMLTABLE (
    '/problem'
    PASSING j.xml_column
    COLUMNS probid VARCHAR (31) PATH '/problem/@id',
    Def XMLTYPE PATH '/problem/Definitions') prob
    where PROBLEM_ID =1;
    returns exactly what I want a;m.
    But
    declare
    my_var varchar2(2000) :=null;
    n1 number;
    n2 number;
    begin
    n1:=1;
    n2:=2;
    SELECT extract(prob.Def,'/Definitions/Definition[n1]/@var') || '|'|| extract(prob.Def,'/Definitions/Definition[n2]/@var') into my_var
    FROM ETL_PROBLEMXML_STG_T j ,
    XMLTABLE (
    '/problem'
    PASSING j.xml_column
    COLUMNS probid VARCHAR (31) PATH '/problem/@id',
    Def XMLTYPE PATH '/problem/Definitions') prob
    where PROBLEM_ID =1;
    dbms_output.put_line(my_var);
    end;
    returns NULL.
    Is there is a way to pass parameter into extract function?

    I need to return all definitions for every problem as a string wirh definitions separated by ";".In XQuery, there's the handy function "string-join" for that.
    For example :
    SQL> WITH etl_problemxml_stg_t AS (
      2   SELECT 1 problem_id,
      3  xmltype('<problem id="1">
      4   <Definitions>
      5    <Definition var="var1"></Definition>
      6    <Definition var="var2"></Definition>
      7    <Definition var="var3"></Definition>
      8   </Definitions>
      9  </problem>') xml_column
    10   FROM dual
    11  )
    12  SELECT j.problem_id,
    13         prob.probid,
    14         prob.def
    15  FROM etl_problemxml_stg_t j,
    16       XMLTable(
    17        'for $i in /problem
    18         return element r
    19         {
    20          $i/@id,
    21          element d { string-join($i/Definitions/Definition/@var, ";") }
    22         }'
    23        passing j.xml_column
    24        columns
    25         probid varchar2(30)  path '@id',
    26         def    varchar2(100) path 'd'
    27       ) prob
    28  ;
    PROBLEM_ID PROBID               DEF
             1 1                    var1;var2;var3

  • How to assign to variable from XML type values with extract function?

    Hi ,
    I have XMLTYPE variable LeXml having below record
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <AddListing xmlns="http://www.christielites.com/">
    <sComCode>string</sComCode>
    <sLocCode>string</sLocCode>
    <dStart>dateTime</dStart>
    <dEnd>dateTime</dEnd>
    <sEcode>string</sEcode>
    <iAvail>int</iAvail>
    <iOwned>int</iOwned>
    <sPostTrans>string</sPostTrans>
    </AddListing>
    </soap:Body>
    </soap:Envelope>
    I want to get sEcode value string into one varialbe using extract function or alternate?
    can any one give me syntax fro it?
    I tried with Mstring:=LeXml.extract('AddListing/scomcode/text()').getStringval(); but iam getting error
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00601: Invalid token in: 'soap:Envelope/text()'
    ORA-06512: at "SYS.XMLTYPE", line 111
    ORA-06512: at "BLUEWATER.CREATELERESPONSELOG", line 12
    ORA-06512: at line 1
    Please guide Me..

    Hi Ravi kumar,
    I have similar type of problem like above . My xml file is like below:
    <doSingleRecordResponse xmlns="urn:mdWebService">
    <doSingleRecordResult xsi:type="ResponseRecord" id="1" version="2.30" action="Response" timeout="10" timestamp="12-17-2009" transmissionReference="ABCDEF" TimeToProcess="31.25" xmlns:xsi="http://www
    .w3.org/2001/XMLSchema-instance">
    <CustomerCredentials>
    <CustomerID>111111</CustomerID>
    </CustomerCredentials>
    <ServiceResult>
    <ErrorCode> </ErrorCode>
    <ErrorDesc>OK;</ErrorDesc>
    </ServiceResult>
    <Address version="2.30">
    <Faults count="0"/>
    <Result>
    <ErrorCode> </ErrorCode>
    <ErrorDesc>OK</ErrorDesc>
    <StatusCode>9</StatusCode>
    <StatusD
    esc>(U.S.) The address was fully coded.</StatusDesc>
    </Result>
    <Company/>
    <Urbanization>
    <Name/>
    <Code/>
    </Urbanization>
    <Type>
    <String>Highrise</String>
    <Code>H</Code>
    </Type>
    <Street>XXXXXXXXXXXXX</Street>
    <Street2/>
    <Suite/>
    <PrivateMailBox/>
    <CarrierRoute>C048</CarrierRoute>
    <Lacs> </Lacs>
    <LacsLink>
    <LacsStatusCode/>
    <LacsReturnCode/>
    </LacsLink>
    <DeliveryPointCode>99</DeliveryPointCode>
    <DeliveryPointCheckDigit>6</DeliveryPointCheckDigit>
    <DPV>
    <Footnotes/>
    <CMRA/>
    <AddressStatus/>
    </DPV>
    <DeliveryIndicator>
    <Code/>
    </DeliveryIndicator>
    <City>
    <Name>String</Na
    me>
    <Abbreviation>Memphis</Abbreviation>
    </City>
    <County>
    <Name>String</Name>
    <Fips>41111</Fips>
    </County>
    <State>
    <Name>Tennessee</Name>
    <Abbreviation>TN</Abbreviation>
    </State>
    <Zip>
    <Type> </Type>
    <Zip5>38111</Zip5>
    <Plus4>1111</Plus4>
    </Zip>
    <GeoCode>
    <Latitude/>
    <Longitude/>
    </GeoCode>
    <TimeZone>
    <Name/>
    <Code/>
    </TimeZone>
    <Msa>
    <Code/>
    </Msa>
    <Pmsa>
    <Code/>
    </Pmsa>
    <Census>
    <Block/>
    <Tract/>
    </Census>
    <CongressionalDistrict>
    <Code/>
    </CongressionalDistrict>
    <Parsed>
    <StreetName/>
    <AddressRange/>
    <Suffix/>
    <Direction>
    <Post/>
    <Pre/>
    </Direction>
    <Suite>
    <Name/>
    <Range/>
    </Suite>
    <PrivateMailBox>
    <Name/>
    <Range/>
    </PrivateMailBox>
    <Garbage/>
    </Parsed>
    <Country>
    <Abbreviation>US</Abbreviation>
    <Name>United St
    ates of America</Name>
    </Country>
    </Address>
    <Telephone version="" action="">
    <Result>
    <ErrorCode/>
    <ErrorDesc/>
    <StatusCode/>
    <StatusDesc/>
    </Result>
    <Number/>
    <PhoneAreaCode/>
    <NewAreaCode/>
    <Prefix/>
    <Suffix/>
    <Extension/>
    <City>
    <Name/>
    </City>
    <State>
    <Name/>
    <Abbreviation/>
    </State>
    <GeoCode>
    <Latitude/>
    <Longitude/>
    </GeoCode>
    <TimeZone>
    <Name/>
    <Code/>
    </TimeZone>
    <Msa>
    <Code/>
    </Msa>
    <Pmsa>
    <Code/>
    </Pmsa>
    <County>
    <Name/>
    <Fips/>
    </County>
    <Country>
    <Abbreviation/>
    <Name/>
    </Country>
    </Telephone>
    <Name version="" action="">
    <Result>
    <ErrorCode/>
    <ErrorDesc/>
    <StatusCode/>
    <StatusDesc/>
    </Result>
    <Company/>
    <Prefix/>
    <Suffix/>
    <Full/>
    <First/>
    <Middle/>
    <Last/>
    <Gender/>
    </Name>
    </doSingleRecordResult>
    </doSingleRecordResponse>
    This is the response i got from a webservice , from this i need to extract customer id .
    I tried like this :
    response := UTL_DBWS.invoke ( l_call,request);
    if RESPONSE.extract('/doSingleRecordResponse/doSingleRecordResult/CustomerCredentials/CustomerID/text()','xmlns:xsi="http://www
    .w3.org/2001/XMLSchema-instance" xmlns="urn:mdWebService"') is not NULL
    then
    errorcode :=RESPONSE.extract('/doSingleRecordResponse/doSingleRecordResult/CustomerCredentials/CustomerID/text()','xmlns:xsi="http://www
    .w3.org/2001/XMLSchema-instance" xmlns="urn:mdWebService"').getStringVal;
    end if;
    I am getting null value into errorcode,
    Can youplease let me know what i am doing wrong?
    Thanks

  • Problem using extract function (PL/SQL) with "&#34"

    Hi,
    When I use extract function (PL/SQL), it does not transform well "&#34". Insted of returning ' " ' , it returns ' &quot '.
    I know this works changing the code replacing xml.extract for SELECT extractvalue(xml,'//A/text()') into v from dual;
    But Is there another way to do this using PL/SQL? any patch, option..?
    Regards

    Had to use my website to demonstrate the code...
    As said, whatever I try here the code gets automatically converted...
    See for answer on your question: http://www.liberidu.com/blog/?p=635

  • EXTRACT function and Chinese data

    Hi !
    I'm working with PL/SQL web applications, and I'm having trouble viewing it on a webpage when I use EXTRACT function for Chinese data.
    <abccompany> <department> &#20975;&#20262;·&#23041;&#24265;&#26031;&#26159;&#19968;&#23478;&#23567;&#22411;&#31038;&#21306;&#21046;&#33647;&#21378;&#30340;&#25152;&#26377;&#32773;&#65292;&#22905;&#27491;&#32771;&#34385;&#24320;&#22987;&#25552;&#20379;&#33647;&#26041;&#36882;&#36865;&#30340;&#26381;&#21153;&#65292;&#21516;&#26102;&#20063;&#24050;&#32463;&#23601;&#27492;&#20107;&#24449;&#27714;&#20102;&#20445;&#38505;&#19987;&#23478;&#40077;&#21187;·&#24067;&#26391;&#30340;&#24847;&#35265;&#12290;&#20975;&#20262;&#35810;&#38382;&#40077;&#21187;&#65292;&#38656;&#35201;&#36141;&#20080;&#21738;&#20123;&#20445;&#38505;&#12289;</department></abccompany>
    The Chinese xml data is stored as 'xmltype' in the Oracle database.
    1)
    When I run the below query, the output shown on a web page is upside down question marks like this
    select v.xtext.EXTRACT('/abccompany/department/text()').GetClobVal()
    into text
    from case_text v
    where case_identifier=inIdx;
    htp.print('<html><body>')
    htp.print(text);
    htp.print('</body></html>');
    2)
    However, the EXTRACT function works perfectly for English data.
    3)
    I also observed that, when I replace
    select v.xtext.EXTRACT('/abccompany/department/text()').GetClobVal()
    with
    to_clob(xtext)
    the web page displays the Chinese contents of the whole file and not just within the nodes <abccompany><department>.
    How can I make Extract function work with Chinese data ?
    Any help appreciated !
    -Sara

    Sara
    This normally happens when the client character set is not capable of showing chinese data. For instance on my laptop I cannot show the results of an extract() which returns chinese or japanese data in sqlplus (which cannot show chinese data on my machine) but I can in ISQL*PLUS which is web based and can show chinese data.
    THis might be a result of your NLS_LANG settings. The database translates from the database character set (I'm assuming AL32UTF8 in this case, into the client character set (as defined by NLS_LANG). Again if the characters cannot be converted this can cause this issue.

  • Extract function for xmltype replaces ~ (tilde) with ']]]'

    Hi,
    In 10.2.0.4 when extracting fragment using xpath and extract function is replacing ~ with ]]]. strange thing is, it happens with only one ~ though there are many ~ in the xml.
    Has anyone faced similar issue with extract() function ?
    Thanks,
    vivek

    This turned out to be a bug. It was resolved through a patch developed.

  • Suppress default namespace in extract() function

    How can I avoid that Oracle includes the target namespace of my schema as the default namespace when using the EXTRACT function?
    E.g., select xmlelement("XmlData",
    xmlagg(extract(tx.transmission, '/Transmission/Item')))
    from transmissions tx
    returns something like
    <XmlData>
    <Item xmlns="http://myschematargetnamespace" N="1">abcdef</Item>
    <Item xmlns="http://myschematargetnamespace" N="2">abcdef</Item>
    </XmlData>
    Any ideas will be appreciated very much!
    P.S. Can anybody tell me how I configure sqlplus to display the complete XML instead of only two lines?

    Jash
    I'm not aware of the answer, not would it make sense to do. element x in the noNamespaceNamespace is not the same object as element x in a specified namespace. Techinically there is no correct way to move the element from some specific namespace to the noNamespaceNamespace. You would have to construct a new element in the noNamespaceNamespace from scratch.

  • Problem using the IMAQ Extract function.Not getting two different image out

    Hi, I am trying to use the multiple IMAQ extract functions to get certain parts of the webcam image and then using the color extract function to get the average RGB values. The problem is that both the IMAQ extract functions give the same image on its output port. The block diagram snippet and VI are attached below. Also, please let me know if there is a better way of doing this. I need to expand this later to extract rgb values of about 40-50 different parts of the image instead of just two shown below.
    Solved!
    Go to Solution.
    Attachments:
    Extract RGB Data.vi ‏104 KB

    You did not create another image that you should wire to the input "Image Dst" of "IMAQ Extract".  That's why you always operate on the original image (which you should not do if you intend to operate on several regions of the image).
    Solution: 
    (1) Create a new image and wire this to "Image Dst".
    (2) Apply the histogram operation sequentially (e.g. in a loop).
    That way you will notice, that Image Dst contains actually(!) the region you have specified.  (Put a probe on the image wire that goes from the Extract VI to the Histogram VI).

  • BW Extract function module

    I have a problem - I am trying to create a generic extract function module. The problem is that the template RSAX_BIW_GET_DATA_SIMPLE uses one database select. However for my purpose I need to select from various tables in order to build up my internal table.
    It is for PO Service orders so I have to read headers then detailed lines then other tables to get account assignments etc. How do I transfer this to E_T_Data using the required logic for the fetch and open curser etc.

    OK I have written an ABAP report which gets the information I need. This is crude code that I know I can tidy up with joins but I just wanted to make sure I could get the information and that it was correct first.
    The code is below. I have two scenarios one for full load and one for delta (which will be the same process but reading the po's that have changed from a bespoke table populated from a user exit EXIT_SAPLRSAP_001
    from 2LIS_02_SCL.)
    Anyway here it is:-
        FULL LOAD   ************************************
    IF FLAG = 'F'.
    EKKO FIRST READ
    SELECT * FROM EKKO
    WHERE EBELN IN PO
       AND AEDAT IN DDATE
       AND BUKRS = 'OPCS'
       AND BSTYP = 'F'
       AND LOEKZ NE 'X'.
       MOVE-CORRESPONDING EKKO TO I_TAB.
       APPEND I_TAB.
    ENDSELECT.
    EKPO SECOND READ POULATING i_tab2
    LOOP AT I_TAB.
    SELECT * FROM EKPO
    WHERE EBELN = I_TAB-EBELN
    AND PSTYP = '9'
    AND EREKZ NE 'X'
    AND ELIKZ NE 'X'
    AND LOEKZ NE 'X'.
    I_TAB2-WAERS = I_TAB-WAERS.
    MOVE-CORRESPONDING EKPO TO I_TAB2.
    APPEND I_TAB2.
    ENDSELECT.
    ENDLOOP.
    SORT I_TAB2 BY EBELN EBELP.
    CLEAR W_PACKNO.
    POPULATE ITAB_ESLL FINAL TABLE
    LOOP AT I_TAB2.
    SELECT SINGLE SUB_PACKNO INTO W_PACKNO FROM ESLL
    WHERE PACKNO = I_TAB2-PACKNO.
    IF SY-SUBRC = 0.
    SELECT * FROM ESLL
    WHERE PACKNO = W_PACKNO.
    ITAB_ESLL-ERDAT = I_TAB2-AEDAT.
    ITAB_ESLL-WAERS = I_TAB2-WAERS.
    MOVE-CORRESPONDING ESLL TO ITAB_ESLL.
    ITAB_ESLL-EBELN = I_TAB2-EBELN.
    ITAB_ESLL-EBELP = I_TAB2-EBELP.
    account assignment
    CLEAR W_ZEKKN.
          SELECT SINGLE ZEKKN FROM ESKL INTO W_ZEKKN
          WHERE PACKNO = W_PACKNO
          AND INTROW = ESLL-INTROW.
          IF SY-SUBRC = 0.
          CLEAR EKKN.
          SELECT  SINGLE * FROM EKKN
          WHERE EBELN = ITAB_ESLL-EBELN
          AND EBELP =
                        ITAB_ESLL-EBELP AND ZEKKN = W_ZEKKN.
                        ITAB_ESLL-PS_PSP_PNR = EKKN-PS_PSP_PNR.
          ITAB_ESLL-SAKTO = EKKN-SAKTO.
          ITAB_ESLL-KOSTL = EKKN-KOSTL.
          ITAB_ESLL-KOKRS = EKKN-KOKRS.
          I_TAB2-SAKTO = EKKN-SAKTO.
          I_TAB2-KOSTL = EKKN-KOSTL.
          I_TAB2-KOKRS = EKKN-KOKRS.
         ENDIF.
    MODIFY I_TAB2.
    APPEND ITAB_ESLL.
    ENDSELECT.
    ENDIF.
    ENDLOOP.
    NOW READ EKBE
    LOOP AT I_TAB2.
      SELECT * FROM EKBE
      WHERE EBELN = I_TAB2-EBELN
       AND EBELP = I_TAB2-EBELP
       AND ( BEWTP = 'E' OR BEWTP = 'R' OR BEWTP = 'Q' ).
       IF SY-SUBRC = 0.
           MOVE-CORRESPONDING EKBE TO ITAB_EKBE.
           APPEND ITAB_EKBE.
       ENDIF.
          ENDSELECT.
    ENDLOOP.
    get rid of duplicate lines in ekbe
    SORT ITAB_EKBE BY EBELN EBELP BELNR.
    DATA: FIRST(1) TYPE C.
    FIRST = 'x'.
    DATA: D_BELNR LIKE EKBE-BELNR.
    LOOP AT ITAB_EKBE.
    IF FIRST = 'x'.
    D_BELNR = ITAB_EKBE-BELNR.
    FIRST = ''.
    ELSE.
    IF ITAB_EKBE-BELNR = D_BELNR.
    DELETE ITAB_EKBE.
    ELSE.
    D_BELNR = ITAB_EKBE-BELNR.
    ENDIF.
    ENDIF.
    ENDLOOP.
    LOOP AT ITAB_EKBE.
         CLEAR W_PACKNO1.
         SELECT SINGLE * FROM ESSR
        WHERE LBLNI = ITAB_EKBE-LFBNR.
        W_PACKNO1 = ESSR-PACKNO.
         CLEAR W_PACKNO.
        IF SY-SUBRC = 0.
          SELECT SINGLE SUB_PACKNO FROM ESLL INTO W_PACKNO
          WHERE PACKNO = W_PACKNO1.
    get service line items from esll
          SELECT * FROM ESLL
          WHERE PACKNO = W_PACKNO.
          IF SY-SUBRC = 0.
    ACCOUNT ASSIGNMENT INSERVICE PACKAGE
          CLEAR W_ZEKKN.
          SELECT SINGLE ZEKKN FROM ESKL INTO W_ZEKKN
          WHERE PACKNO = W_PACKNO
          AND INTROW = ESLL-INTROW.
          IF SY-SUBRC = 0.
          CLEAR EKKN.
          SELECT  SINGLE * FROM EKKN
          WHERE EBELN = ITAB_EKBE-EBELN
          AND EBELP =
                       ITAB_EKBE-EBELP AND ZEKKN = W_ZEKKN.
          IF SY-SUBRC = 0.
          CLEAR ITAB_ESLL.
          MOVE-CORRESPONDING ESLL TO ITAB_ESLL.
          ITAB_ESLL-EBELN = ITAB_EKBE-EBELN.
          ITAB_ESLL-EBELP = ITAB_EKBE-EBELP.
          ITAB_ESLL-ZEKKN = W_ZEKKN.
          ITAB_ESLL-VGABE = ITAB_EKBE-VGABE.
          ITAB_ESLL-BELNR = ITAB_EKBE-BELNR.
          ITAB_ESLL-BEWTP = ITAB_EKBE-BEWTP.
          ITAB_ESLL-SAKTO = EKKN-SAKTO.
          ITAB_ESLL-KOSTL = EKKN-KOSTL.
          ITAB_ESLL-KOKRS = EKKN-KOKRS.
          ITAB_ESLL-PS_PSP_PNR = EKKN-PS_PSP_PNR.
          ENDIF.
         ENDIF.
    CHECK IF CREDIT OR DEBIT AND ADJUST
          IF ITAB_EKBE-SHKZG = 'H'.
           ESLL-MENGE = ESLL-MENGE * -1.
           ESLL-NETWR = ESLL-NETWR * -1.
          ENDIF.
          ITAB_ESLL-MENGE = ESLL-MENGE.
          ITAB_ESLL-NETWR = ESLL-NETWR.
          ITAB_ESLL-ERDAT = ESSR-ERDAT.
          ITAB_ESLL-WAERS = ESSR-WAERS.
          ITAB_ESLL-LOEKZ = ESSR-LOEKZ.
          ITAB_ESLL-KZABN = ESSR-KZABN.
          ITAB_ESLL-FRGKL = ESSR-FRGKL.
          ITAB_ESLL-BUZEI = ITAB_EKBE-BUZEI.
          ITAB_ESLL-GJAHR = ITAB_EKBE-GJAHR.
          ITAB_ESLL-EBELN = ITAB_EKBE-EBELN.
          ITAB_ESLL-EBELP = ITAB_EKBE-EBELP.
          APPEND ITAB_ESLL.
          ENDIF.
        ENDSELECT.
       ENDIF.
    ENDLOOP.
    report print out
    WRITE:/5 'doc',
           20 'PO Line',
           30 'date created',
           45 'Currency',
           55 'deletion Ind',
           70 'ACCEPT IND',
           85 'Rel Ind',
           95 'Line No',
           115 'Service',
           135 'Quantity',
           155 'UOM',
           175 'Net Value',
           195 'Mat Grp',
           215 'G/L Acc',
           230 'Cost Centre',
           245 'Cont Area',
           255 'Acc *** line',
           275 'Trans/Event Type',
           295 'Posting Year',
           315 'Mat Doc No',
           335 'Mat Doc Line no',
           355 'bewtp',
           375 'WBS'.
    SORT ITAB_ESLL BY EBELN EBELP SRVPOS EXTROW.
    LOOP AT ITAB_ESLL.
    WRITE:/5 ITAB_ESLL-EBELN,
            20 ITAB_ESLL-EBELP,
            30 ITAB_ESLL-ERDAT,
            45 ITAB_ESLL-WAERS,
            55 ITAB_ESLL-LOEKZ,
            70 ITAB_ESLL-KZABN,
            85 ITAB_ESLL-FRGKL,
            95 ITAB_ESLL-EXTROW,
            115 ITAB_ESLL-SRVPOS,
            135 ITAB_ESLL-MENGE,
            155 ITAB_ESLL-MEINS,
            175 ITAB_ESLL-NETWR,
            195 ITAB_ESLL-MATKL,
            215 ITAB_ESLL-SAKTO,
            230 ITAB_ESLL-KOSTL,
            245 ITAB_ESLL-KOKRS,
            255 ITAB_ESLL-ZEKKN,
            275 ITAB_ESLL-VGABE,
            295 ITAB_ESLL-GJAHR,
            315 ITAB_ESLL-BELNR,
            335 ITAB_ESLL-BUZEI,
            355 ITAB_ESLL-BEWTP,
            375 ITAB_ESLL-PS_PSP_PNR.
    ENDLOOP.
       DELTA LOAD    ****************
    ELSE.
    IF FLAG = 'D'.
    WRITE: /'Test DELTA Part'.
    SELECT * FROM ZBWSERVICEPOS
    WHERE DATE_UPDATED IN DDATE.
    MOVE-CORRESPONDING ZBWSERVICEPOS TO I_TAB-DELTA.
    APPEND I_TAB-DELTA.
    ENDSELECT.
    *LOOP AT I_TAB-DELTA.
    WRITE:/ I_TAB-DELTA-DATE_UPDATED,
      I_TAB-DELTA-EBELN, I_TAB-DELTA-EBELP.
    *ENDLOOP.
    ELSE.
      MESSAGE I100.
    ENDIF.
    ENDIF.

  • Problem with "&#34" using PL/SQL extract function ( XMLTYPE)

    Hi,
    When I use extract function (PL/SQL), it does not transform well "&#34". Insted of returning ' " ' , it returns ' &quot '.
    I know this works changing the code replacing xml.extract for SELECT extractvalue(xml,'//A/text()') into v from dual;
    But Is there another way to do this using PL/SQL? any patch, option..?
    Regards

    Hi,
    cursor proct is select * from proc22;
    cursor proct5 is select *from proc24;
    fetch proct into proctval;
    fetch proct5 into proctval5;
    if proct.symbol=proct5.symbolThat's strange to join two tables like this. You will have chance if you enter in your if condition.
    Why not create only one cursor with this join condition on the two tables ?
    re5:=re5/proctval.previousprice5;Furthermore, what do you make with r5 variable ? It seems nothing to do. Your proc does no much job.
    What do you want to achieve exactly ?
    Nicolas.

  • How can I speed up the extract() function queries on XML

    Hi,
    Please I need some light on xml and indexes.
    This is my case:
    I use Oracle 9i R2.
    I have a table with some rows containing some few xml documents (each row contains a big xml document).
    Given a value for an attribute of a tag, I want to extract the entire section within the tags.
    Example:
    <MYTAG number="1">
    .....big stuff here
    </MYTAG>
    <MYTAG number="2">
    .....big stuff here
    </MYTAG>
    <MYTAG number="x">
    .....big stuff here
    </MYTAG>
    So for number=2 I would like to extract from the document the xmltype
    <MYTAG number="2">
    .....big stuff here
    </MYTAG>
    I created an index and have followed all the steps from the XML Database Developers Kit manual. Then I would use extrac() as the document says.
    Now some doubts arised:
    Are these text/xml indexes only useful for getting the rowid of my document?
    I mean, if I select 'x' from the table looking for some value, then the index is used. But when I use extract in the select to get the section I look for, the query gets really low, specially when xml documents are big. I think when I have only row with one document, getting the rowid is not the problem, but the extraction from the document is.
    Is the extraction process faster because of the index?
    For what I see, the index only helps me to find the rowid, but then Oracle has to deal with the very big document inside the row. At that point Its oracle against a big text processing and index has nothing to do.
    How can I speed up the extraction of the section?
    If there any other index or tool for help extraction to be faster?
    I would appreciate to know what can I do. I need help on this.
    Thanks in advance!

    Well,
    - What indexes, if any, already exist?
    - What do the functions rl and nice do?
    - What are the current query plans?
    - How restrictive are the various predicates?
    - What version of Oracle?
    Justin

  • Extract function (For XML)

    Hi,
    I need to extract values from the following XML block where I need to extract the value of TDEXPIRYDATE (20120707):
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <soapenv:Body>
              <m:EEODEN01_Response xmlns:m="http://entirex/rop">
                   <TDEXPIRYDATE>20120707</TDEXPIRYDATE>
                   <TD-ISSUE-PLACE>999</TD-ISSUE-PLACE>
                   <PASSPORT-LANG>1</PASSPORT-LANG>
              </m:EEODEN01_Response>
         </soapenv:Body>
    </soapenv:Envelope>
    How can this be done , I mean what is the XPAth to be passed to the function extract?
    Thanks in advance
    Regards
    AK

    michaels>  with t as (
    select xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                                                                                                                                                                                                                                                                                          
      <soapenv:Body>                                                                                                                                                                                                                                                                                                                                                                                                                                                         
        <m:EEODEN01_Response xmlns:m="http://entirex/rop">                                                                                                                                                                                                                                                                                                                                                                                                                   
          <TDEXPIRYDATE>20120707</TDEXPIRYDATE>                                                                                                                                                                                                                                                                                                                                                                                                                              
          <TD-ISSUE-PLACE>999</TD-ISSUE-PLACE>                                                                                                                                                                                                                                                                                                                                                                                                                               
          <PASSPORT-LANG>1</PASSPORT-LANG>                                                                                                                                                                                                                                                                                                                                                                                                                                   
        </m:EEODEN01_Response>                                                                                                                                                                                                                                                                                                                                                                                                                                               
      </soapenv:Body>                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    </soapenv:Envelope>
    ') xml from dual)
    select extractvalue(xml, '//TDEXPIRYDATE/text()') tdexpirydate from t t
    TDEXPIRYDATE  
    20120707 

Maybe you are looking for