Help - Nested XMLQuery (XQuery) Syntax

I need to query a relational table that includes an XMLType column as Binary XML.  The XMLType column contains an XML document of arbitrary length. My query is in part dependent on relational column values and data values within the XML documents.  The body of the XML document, beneath the root element, is composed of 3 main sections (elements): Header1, 1/document; Header2, 1/document; and Details, 1/document.  The Details section is composed of multiple, arbitrary in number, Detail sections (elements). Example data and table layout are below.
For a particular TLID or CUST, or SHIP_DATE, etc. I need to return the Header1, Header2, and multiple Detail sections where element values within particular Detail sections match additional qualifications.
If I just want to return the Detail sections, I can do this successfully with the following query:
select cust,  tlid,  xmlquery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                        for $i in /C52R09/DETAILS/DETAIL
                        where $i/OrderNumber = "SBC00999"
                        return $i' PASSING xml_doc
                        RETURNING CONTENT).getClobVal() detail
from xml_truck_info
where tlid = '424500'
    and  xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                 $x/C52R09/HEADER1[TruckNumber = "424500"]' PASSING xml_doc AS "x");
I need, however, to return the Header1 and Header2 sections once per document if the query returns any Detail sections, regardless of  whether the query returns 1 or multiple Detail sections.
My impression is that this will require a nested XQuery.  I haven't had success getting the syntax correct for this.  I've wasted a tremendous amount of time searching the web for examples that would replicate my scenario.  It seems there is a dearth of detailed, clear info and examples available on Oracle's XQuery implementation and structure.  I found a few examples that approximate what I'm trying to do; however, when I tweak them, the query spits up.
Based on the following 2 examples pulled from the web or Oracle documentation:
SELECT rownum, XMLQuery(
   <counties>
    {for $c in ora:view("CHAMBER_OF_COMMERCE")
     let $coc_county := $c/ROW/COC_COUNTY/text(),
         $coc_name := $c/ROW/COC_NAME,
         $coc_phone := $c/ROW/COC_PHONE/textb()
     where $coc_county = $cc_county/county/text()
     order by $coc_county
     return
        <county population="{xs:unsignedInt(sum(/cities/city/population))}">
           <name>{$coc_county}</name>
           <chamber phone="{$coc_phone}">{$coc_name/text()}</chamber>
           <attractions>
              {for $a in collection("/public")
               where $coc_county = $a/attraction/county/text()
               return $a
           </attractions>
        </county>}
    </counties>
    PASSING BY VALUE cc_city_populations,
       XMLTYPE('<county>' || cc_county || '</county>') AS "cc_county"
    RETURNING CONTENT)
FROM county_census;
and
SELECT XMLQuery(
'for $i in $h//channel
return
<headlines>
<title>OTN new articles on Oracle Solaris</title>
<items>
     for $j in $h//item
     where ora:contains($j, "Oracle Solaris")
     return <item> {($j/title, $j/link)}</item>
</items>
</headlines>'
PASSING xmlparse (document httpuritype ('http://feeds.delicious.com/v2/rss/OracleTechnologyNetwork/
otntecharticle').getCLOB()) as "h"
RETURNING CONTENT).getStringVal() as RESULT FROM DUAL;
I have modified my simple, successful query above to the following:
select tlid, XMLQuery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
              for $i in /C52R09
              return
                <Headers>
                  "{$i/Header1}"
                  "{$i/Header2}"
                </Headers>
                    for $x in $i/DETAILS/DETAIL
                    where $x/MarvinOrderNumber = "SBC00999"
                    return $x
                PASSING xml_doc
              RETURNING CONTENT).getClobVal() detail
from xml_truck_info
where TLID = '424500'
    and  xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                 $x/C52R09/HEADER1[TruckNumber = "424500"]' PASSING xml_doc AS "x");
When run in SQLDeveloper the result consistently reflects an issue with the curly braces '{}' around the second 'for' expression.  I have run this with different iterations, to include removing the curly braces around the $i/Header1 and $i/Header2 sections.  It makes no difference.  I get similar results as follows:
Error at Command Line:16 Column:6
Error report:
SQL Error: ORA-19114: XPST0003 - error during parsing the XQuery expression:
LPX-00801: XQuery syntax error at '{'
9                   {
-                   ^
19114. 00000 -  "error during parsing the XQuery expression: %s"
*Cause:    An error occurred during the parsing of the XQuery expression.
*Action:   Check the detailed error message for the possible causes.
My table, XML_TRUCK_INFO, looks like this:
Name                Type
CUST                VARCHAR2(7)
LOC                 VARCHAR2(5)
TLID                NUMBER
STID                NUMBER
SHIP_DATE           DATE
SHIPPED_FLAG        VARCHAR2(1)
XML_DOC             SYS.XMLTYPE STORAGE BINARY    
Here is a sample of the XML_DOC content that I am running  the XQuery against.
<?xml version="1.0" standalone="yes"?>
<C52R09 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamspaceSchemaLocation="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd                                           
        http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd">
  <HEADER1>
    <TruckNumber>424500</TruckNumber>
    <StopID>16</StopID>
    <ShipFrom>CITYNAME</ShipFrom>
    <ShippingDate>10-JUN-2013</ShippingDate>
    <PlannedDepartureDate>10-JUN-2013 05:00</PlannedDepartureDate>
    <ETADate>11-JUN-2013</ETADate>
    <LoadName>SW 29</LoadName>
    <StopName>16-FREEPORT, </StopName>
    <StopComment/>
    <TruckStatus>INVOICED</TruckStatus>
    <ReportType>C</ReportType>
  </HEADER1>
  <HEADER2>
    <DestAddrName>CUSTOMER-BUSINESS-NAME</DestAddrName>
    <DestAddrLine1>23 EAST 4TH AVENUE</DestAddrLine1>
    <DestAddrLine2/>
    <DestCity/>
    <DestState/>
    <DestZip>55555</DestZip>
  </HEADER2>
  <DETAILS>
    <DETAIL>
      <OrderNumber>SBC00999</OrderNumber>
      <LineNumber>3</LineNumber>
      <OrderType>STANDARD SALES ORDER</OrderType>
      <OrderStatus>SHIPPED COMPLETE</OrderStatus>
      <OrderDate>23-MAY-2013</OrderDate>
      <JobName>Job1</JobName>
      <QtyOrdered>3</QtyOrdered>
      <QtyShipped>3</QtyShipped>
      <WeekofDelivery>10-JUN-2013</WeekofDelivery>
      <Status>THIS TRUCK</Status>
      <CustomerNumber>5000-000</CustomerNumber>
      <CustomerName>CUSTNAME1</CustomerName>
      <CustomerPONumber>W163409</CustomerPONumber>
      <CubicFeet>4.56</CubicFeet>
      <ListPrice>677</ListPrice>
      <SpecialMQSCode>
        <ProductType>AAZG</ProductType>
        <UnitType>ABEG</UnitType>
      </SpecialMQSCode>
      <ShortDescription>INSERT ASSEMBLY</ShortDescription>
      <OpeningCount>5</OpeningCount>
      <TrackingLines>
        <TrackingNo>0YD746</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:05</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
        <TrackingNo>0YD747</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:31</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
        <TrackingNo>0YD748</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:06</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
      </TrackingLines>
    </DETAIL>
    <DETAIL>
      <OrderNumber>SBC00999</OrderNumber>
      <LineNumber>4</LineNumber>
      <OrderType>STANDARD SALES ORDER</OrderType>
      <OrderStatus>SHIPPED COMPLETE</OrderStatus>
      <OrderDate>23-MAY-2013</OrderDate>
      <JobName>Job1</JobName>
      <QtyOrdered>3</QtyOrdered>
      <QtyShipped>3</QtyShipped>
      <WeekofDelivery>10-JUN-2013</WeekofDelivery>
      <Status>THIS TRUCK</Status>
      <CustomerNumber>5000-000</CustomerNumber>
      <CustomerName>CUSTNAME1</CustomerName>
      <CustomerPONumber>W163409</CustomerPONumber>
      <CubicFeet>4.56</CubicFeet>
      <ListPrice>677</ListPrice>
      <SpecialMQSCode>
        <ProductType>AAZG</ProductType>
        <UnitType>ABEG</UnitType>
      </SpecialMQSCode>
      <ShortDescription>INSERT ASSEMBLY</ShortDescription>
      <OpeningCount>5</OpeningCount>
      <TrackingLines>
        <TrackingNo>0YD749</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:05</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
        <TrackingNo>0YD750</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:05</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
        <TrackingNo>0YD751</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 06:46</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
      </TrackingLines>
    </DETAIL>
    <DETAIL>
      <OrderNumber>SBC00999</OrderNumber>
      <LineNumber>5</LineNumber>
      <OrderType>STANDARD SALES ORDER</OrderType>
      <OrderStatus>SHIPPED COMPLETE</OrderStatus>
      <OrderDate>23-MAY-2013</OrderDate>
      <JobName>Job1</JobName>
      <QtyOrdered>2</QtyOrdered>
      <QtyShipped>2</QtyShipped>
      <WeekofDelivery>10-JUN-2013</WeekofDelivery>
      <Status>THIS TRUCK</Status>
      <CustomerNumber>5000-000</CustomerNumber>
      <CustomerName>CUSTNAME1</CustomerName>
      <CustomerPONumber>W163409</CustomerPONumber>
      <CubicFeet>4.56</CubicFeet>
      <ListPrice>677</ListPrice>
      <SpecialMQSCode>
        <ProductType>AAZG</ProductType>
        <UnitType>ABEG</UnitType>
      </SpecialMQSCode>
      <ShortDescription>INSERT ASSEMBLY</ShortDescription>
      <OpeningCount>5</OpeningCount>
      <TrackingLines>
        <TrackingNo>0YD752</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:05</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
        <TrackingNo>0YD753</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:42</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
      </TrackingLines>
    </DETAIL>
    <DETAIL>
      <OrderNumber>SBC01011</OrderNumber>
      <LineNumber>1</LineNumber>
      <OrderType>STANDARD SALES ORDER</OrderType>
      <OrderStatus>SHIPPED COMPLETE</OrderStatus>
      <OrderDate>28-MAY-2013</OrderDate>
      <JobName>Job2</JobName>
      <QtyOrdered>4</QtyOrdered>
      <QtyShipped>4</QtyShipped>
      <WeekofDelivery>10-JUN-2013</WeekofDelivery>
      <Status>THIS TRUCK</Status>
      <CustomerNumber>5000-000</CustomerNumber>
      <CustomerName>CUSTNAME1</CustomerName>
      <CustomerPONumber>W163766</CustomerPONumber>
      <CubicFeet>4.6</CubicFeet>
      <ListPrice>823</ListPrice>
      <SpecialMQSCode>
        <ProductType>AAZG</ProductType>
        <UnitType>ABEG</UnitType>
      </SpecialMQSCode>
      <ShortDescription>INSERT ASSEMBLY</ShortDescription>
      <OpeningCount>5</OpeningCount>
      <TrackingLines>
        <TrackingNo>0YV016</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:46</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
        <TrackingNo>0YV017</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:25</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
        <TrackingNo>0YV018</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 06:51</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
        <TrackingNo>0YV019</TrackingNo>
        <TrackingStatus>Shipped</TrackingStatus>
        <ScanData>
          <ScanDate>11-JUN-2013 07:22</ScanDate>
          <Signature>mark</Signature>
          <ScanStatus>SCANNED</ScanStatus>
        </ScanData>
      </TrackingLines>
    </DETAIL>
  </DETAILS>
</C52R09>
I would appreciate any help and/or insights from others more experienced in this than I.
Thanks in advance,
Paul

Sorry, as I look back at the declaration in the root element included in the example, I must have used an older version of the data.  The root element with declarations should have been this:
<C52R09 xmlns="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:SchemaLocation="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd                                 
http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd">
I've included the query with the declaration (using data values in the table, but different from those in the example) and the result below:
PK_XML-MOS2>>select tlid
  2       , XMLQuery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
  3           let $dtls := /C52R09/DETAILS/DETAIL[OrderNumber=$order_no]
  4            return if ($dtls) then
  5            <Doc>
  6            {
  7              <Headers>{ /C52R09/HEADER1, /C52R09/HEADER2 }</Headers>
  8            , <Details>{ $dtls }</Details>
  9            }
10            </Doc>
11            else ()'
12           PASSING xml_doc
13                 , '17Z00266' as "order_no"
14           RETURNING CONTENT
15         ).getClobVal() detail
16  from xml_truck_info
17  where tlid = 398043
18    and xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
19          /C52R09/HEADER1[TruckNumber=$truck_no]'
20          PASSING xml_doc
21                , '398043' as "truck_no"
22        );
More .....
      TLID  DETAIL
    398043   
I've included the query without the declaration (same data values as above) and the result below:
PK_XML-MOS2>>select tlid
   2       , XMLQuery('let $dtls := /C52R09/DETAILS/DETAIL[OrderNumber=$order_no]
   3            return if ($dtls) then
   4            <Doc>
   5            {
   6              <Headers>{ /C52R09/HEADER1, /C52R09/HEADER2 }</Headers>
   7            , <Details>{ $dtls }</Details>
   8            }
   9            </Doc>
  10            else ()'
  11           PASSING xml_doc
  12                 , '17Z00266' as "order_no"
  13           RETURNING CONTENT
  14         ).getClobVal() detail
  15  from xml_truck_info
  16  where tlid = 398043
  17    and xmlexists('/C52R09/HEADER1[TruckNumber=$truck_no]'
  18          PASSING xml_doc
  19                , '398043' as "truck_no"
  20        );
no rows selected
The first example, with the declaration, returns the TLID value, although no detail section.  Whereas, the second, without the declaration, finds nothing to return.
Thanks again.

Similar Messages

  • Please Help With : XVM-01003: [XPST0003]/LPX-00801: XQuery  Syntax error at

    Hi gurus,
    I need your help on using the XMLQuery function. We are FINALLY in the processing of migrating from 10g to 11gR2! Oracle says that we should replace extracValue with XMLQuery, so I am trying to do that but I am getting the errors below,
    XVM-01003: [XPST0003] Syntax error at (if I use a PL/SQL variable).
    LPX-00801: XQuery syntax error at (if I use the literals).
    I have read through many of the posts related to XMLQuery and its default element namespace, but I have no luck on that. I have an example that has this kind prefix (a part of the xml is posted here):
    <soap:Body>
    <soap:Fault xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Code>
    <soap:Value>soap:Sender</soap:Value>
    <soap:Subcode>
    <soap:Value>soap:InvalidMessage</soap:Value>
    </soap:Subcode>
    </soap:Code>
    <soap:Reason>
    <soap:Text xml:lang="en">UpdateCaseDetentionStatus does not apply to this case&apos;s type.</soap:Text>
    </soap:Reason>
    <soap:Node>CourtFileNumber</soap:Node>
    I need to get the Text inside the Reason node. No matter what I do with the default namespace (and if I don't declare one I also get an error), I get the following error:
    XMLQuery ('declare default element namespace s="http://www.w3.org/2003/05/soap-envelope" ; /s:Envelope/s:Body/s:Fault/s:Reason/s:Text'):
    LPX-00801: XQuery syntax error at 's'
    1 declare default element namespace s="http://www.w3.org/2003/05/soap-envelop
    - ^
    ORA-06512: at line 103
    XMLQuery('declare default element namespace xmlns:soap="http://www.w3.org/2003/05/soap-envelope" ; /soap:Envelope/soap:Body/soap:Fault/soap:Reason/soap:Text'):
    LPX-00801: XQuery syntax error at 'xmlns:soap'
    1 declare default element namespace xmlns:soap="http://www.w3.org/2003/05/soa
    - ^
    ORA-06512: at line 103
    Using the XMLTable function does not have any problems.
    What do I do wrong here? I could just use the XMLTable to replace all the extractValue(s) that I have, but I really want to learn how to make the XMLQuery correct. Please help!
    I just tried this and I got the same error:
    XMLQuery('declare default namespace s="http://www.w3.org/2003/05/soap-envelope" ; (::) $p/s:Envelope/s:Body/s:Fault/s:Reason/s:Text' passing p_XMLDoc as "p"
    Thank you.
    Ben
    Edited by: myora9i on Apr 22, 2011 1:42 PM

    Hi Ben,
    Can someone please explain to me when should I use the default key word and when I should not use it?If you declare a default namespace then all unqualified (= unprefixed) elements will be considered belonging to that namespace.
    If you declare a namespace with a prefix, you'll have to qualify each element in the XQuery.
    See below example based on your XML sample :
    DECLARE
      soap_doc xmltype := xmltype(
      '<soap:Body xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Fault>
    <soap:Code>
    <soap:Value>soap:Sender</soap:Value>
    <soap:Subcode>
    <soap:Value>soap:InvalidMessage</soap:Value>
    </soap:Subcode>
    </soap:Code>
    <soap:Reason>
    <soap:Text xml:lang="en">UpdateCaseDetentionStatus does not apply to this case''s type.</soap:Text>
    </soap:Reason>
    <soap:Node>CourtFileNumber</soap:Node>
    </soap:Fault>
    </soap:Body>'
      v_text  varchar2(100);
    BEGIN
      -- with a default namespace,
      -- no need to prefix each element :
      SELECT XMLCast(
        XMLQuery(
          'declare default element namespace "http://www.w3.org/2003/05/soap-envelope"; (::)
           /Body/Fault/Reason/Text'
          passing soap_doc
          returning content
        as varchar2(100)
      INTO v_text
      FROM dual;
      dbms_output.put_line(v_text);
      -- with a declared namespace prefix,
      -- each element must be qualified with the prefix :
      SELECT XMLCast(
        XMLQuery(
          'declare namespace s = "http://www.w3.org/2003/05/soap-envelope"; (::)
           /s:Body/s:Fault/s:Reason/s:Text'
          passing soap_doc
          returning content
        as varchar2(100)
      INTO v_text
      FROM dual;
      dbms_output.put_line(v_text);
    END;
    /

  • XQuery syntax to evaluate math formula

    I want to evaluate a math formula inside of a function, so I can't use dynamic SQL.
    I found that the query on an XML-variable with a literal works well.
     DECLARE @sParsedFormula varchar(200);
     DECLARE @xFormula xml;
     SET @xFormula = '';
     SET @sParsedFormula = '1+2';
     SELECT @xFormula.query('3+3') , @xFormula.query('sql:variable("@sParsedFormula")')
    Output (1st value is correctly evaluated, 2nd not):
    "6", "1+2"
    I can't directly pass @sParsedFormula to the query otherwise I get "The argument 1 of the XML data type method "query" must be a string literal".
    What is the correct XQuery-syntax to evaluate the SQL:variable?
    Tx,
    Patrick

    You are obviously on the wrong track when you ask for the impossible.
    You can use sql:variable in XQuery to provide a value. You cannot provide an
    expression.
    If you want to pursue the set-up, your function will have to parse the expression and evalaute it. You can do this is in T-SQL, but it is not the best language for string parsing. Count on wast^H^H^H^Hspending quite a few hours on the development.
    If you do it in C#, undoubtedly it will be easier, and I would expect that you can find classes that performs the parsing and evaluation. This can reduce your development costs considerably.
    Of the languages I have worked with, there is one where the evaluting the expressions are dirt simple: Perl. Here you can just say
      $value = eval($expr)
    But running Perl code from SQL Server? Nah.
    If you want to do this in T-SQL only, it will have to be dynamic SQL. To avoid the cursor you can do somthing like:
       SELECT @sql =
         (SELECT 'SELECT ' + ltrim(str(id)) + ', ' + expr + ';' + char(13) + char(10)
          FROM   #temp
          FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
      PRINT @sql
      INSERT #newtemp(id, value)
         EXEC (@sql)
      UPDATE #temp
      SET    value = n.value
      FROM   #temp t
      JOIN   #newtemp n ON t.id = n.id
    So, yes, XML had a place in your solution. But where you were looking.
    But note that with this solution, you will lose it all if one expression does not parse.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Need help with Xquery Syntax.

    Hi there,
    I am using a Berkeley XML DB and I have a xquery which I need to execute in a particular format. I have the following xquery:
    for $a in collection("test.dbxml")/Bookstore/Book where $a/book_ID/text() eq "6" return $a/book_ID/text()
    This xquery runs fine and I have the end result to be 6.
    I need the same result to be specified in a XML TAG like <order_ID> 6 </order_ID> for which I have the following xquery:
    for $a in collection"test.dbxml")/Bookstore/Book where $a/book_ID/text() eq "6" return <order_ID>$a/book_ID/text()</order_ID>
    This xquery runs but return me back with the string "<order_ID>$a/book_ID/text()</order_ID>".
    Can you please help me to correct the above output to result in "<order_ID> 6 </order_ID>"
    Thanks.

    Try
    for $a in collection("test.dbxml")/Bookstore/Book
    where $a/book_ID/text() eq "6"
    return <order_ID>{$a/book_ID/text()}</order_ID>Lauren Foutz
    Edited by: LaurenFoutz on Apr 17, 2009 9:41 AM

  • XMLQuery (XQuery) with namespace

    I'm pretty new to XML/XQuery and have the following problem.
    I've got a DB outside oracle which is the same as I got in Oracle (10.2.0.1.0). Using XMLSpy I can make a simple query with a default namespace that gives me an XML document.
    xquery version "1.0";
    declare default element namespace "POI";
    for $x in fn:doc("H:\urs\025_XPOI\XDB\xdb\Simple\xml\001_03082006\xpoi\simple.xml")/Simple_XPOIS/Simple
    where $x/ID = 1
    return $x
    When I try the same in Oracle, it fails. I have no idea how to use the XMLNamespaces......
    SQL>
    SQL> WITH XMLNamespaces (DEFAULT 'POI')
    2 SELECT XMLQuery('
    3 for $x in fn:doc("/home/Simple/xml/001_03082006/xpoi/simple.xml")/Simple_XPOIS/Simple
    4 where $x/ID = 1
    5 return $x
    6 '
    7 RETURNING CONTENT) AS RESULT FROM DUAL;
    WITH XMLNamespaces (DEFAULT 'POI')
    ERROR at line 1:
    ORA-32033: unsupported column aliasing
    ####################

    Does this help
    SQL> var docPath varchar2(128)
    SQL> var xmltext varchar2(4000)
    SQL> --
    SQL> begin
      2    :docPath := '/public/rdfSample.xml';
      3    :xmltext :=
      4  '<?xml version="1.0"?>
      5  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://mets.d2lab.net/onts/core.owl#" xmlns:core="http://mets.d
    2lab.net/onts/core.owl#" xmlns:ct="http://mets.d2lab.net/onts/ct.owl#" xmlns:dc="http://protege.stanford.edu/plugins/owl/dc/dublincore.owl#"
    xmlns:geo="http://reliant.teknowledge.com/DAML/Geography.owl#" xmlns:icmsp="http://mets.d2lab.net/onts/icmsp.owl#" xmlns:isocc="http://www.
    daml.org/2001/09/countries/iso-3166-ont#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmln
    s:xsd="http://www.w3.org/2001/XMLSchema#">
      6     <rdf:Description rdf:ID="AERO000001">
      7             <rdf:type rdf:resource="http://mets.d2lab.net/onts/core.owl#Municipality"/>
      8             <core:hasName>ST PETERSBURG</core:hasName>
      9             <core:hasRefs rdf:resource="#AERO000002"/>
    10             <core:fromDocument rdf:resource="#id00001"/>
    11             <core:hasName>SAINT  PETERSBURG</core:hasName>
    12             <core:hasName>PETERSBURG</core:hasName>
    13     </rdf:Description>
    14  </rdf:RDF>';
    15  end;
    16  /
    PL/SQL procedure successfully completed.
    SQL> declare
      2    res boolean;
      3  begin
      4    if (dbms_xdb.existsResource(:docPath)) then
      5      dbms_xdb.deleteResource(:docPath);
      6    end if;
      7    res := dbms_xdb.createResource(:docPath,:xmltext);
      8    commit;
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> set long 10000 lines 1000 pages 0
    SQL> --
    SQL> select xdburitype(:docPath).getXML()
      2    from dual
      3  /
    <?xml version="1.0"?>
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://mets.d2lab.net/onts/core.owl#" xmlns:core="http://mets.d2lab.
    net/onts/core.owl#" xmlns:ct="http://mets.d2lab.net/onts/ct.owl#" xmlns:dc="http://protege.stanford.edu/plugins/owl/dc/dublincore.owl#" xmln
    s:geo="http://reliant.teknowledge.com/DAML/Geography.owl#" xmlns:icmsp="http://mets.d2lab.net/onts/icmsp.owl#" xmlns:isocc="http://www.daml.
    org/2001/09/countries/iso-3166-ont#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd
    ="http://www.w3.org/2001/XMLSchema#">
      <rdf:Description rdf:ID="AERO000001">
        <rdf:type rdf:resource="http://mets.d2lab.net/onts/core.owl#Municipality"/>
        <core:hasName>ST PETERSBURG</core:hasName>
        <core:hasRefs rdf:resource="#AERO000002"/>
        <core:fromDocument rdf:resource="#id00001"/>
        <core:hasName>SAINT  PETERSBURG</core:hasName>
        <core:hasName>PETERSBURG</core:hasName>
      </rdf:Description>
    </rdf:RDF>
    SQL> select xmlquery( 'for $doc in doc($DOCPATH) return $doc' passing :DOCPATH as DOCPATH returning content)
      2    from dual
      3  /
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://mets.d2lab.net/onts/core.owl#" xmlns:core="http://mets.d2lab.
    net/onts/core.owl#" xmlns:ct="http://mets.d2lab.net/onts/ct.owl#" xmlns:dc="http://protege.stanford.edu/plugins/owl/dc/dublincore.owl#" xmln
    s:geo="http://reliant.teknowledge.com/DAML/Geography.owl#" xmlns:icmsp="http://mets.d2lab.net/onts/icmsp.owl#" xmlns:isocc="http://www.daml.
    org/2001/09/countries/iso-3166-ont#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd
    ="http://www.w3.org/2001/XMLSchema#"><rdf:Description rdf:ID="AERO000001"><rdf:type rdf:resource="http://mets.d2lab.net/onts/core.owl#Munici
    pality"/><core:hasName>ST PETERSBURG</core:hasName><core:hasRefs rdf:resource="#AERO000002"/><core:fromDocument rdf:resource="#id00001"/><co
    re:hasName>SAINT  PETERSBURG</core:hasName><core:hasName>PETERSBURG</core:hasName></rdf:Description></rdf:RDF>
    SQL> select xmlquery
      2         (
      3           'declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; (: :)
      4            declare namespace core="http://mets.d2lab.net/onts/core.owl#"; (: :)
      5            for $doc in doc($DOCPATH)/rdf:RDF/rdf:Description/core:fromDocument/@rdf:resource return $doc'
      6            passing :DOCPATH as "DOCPATH" returning content
      7         )
      8    from dual
      9  /
    #id00001
    SQL> --You should be able to use collection to refer to all the documents if a folder...
    Eg
    select xmlquery( 'for $doc in collection($DOCPATH) return $doc' passing :DOCPATH as DOCPATH returning content)
    from dual

  • HELP - Nested Case Question (Multiple Rows)

    OK, Now that the syntax has been corrected with the help of "Chanchal Wankhade" (Thank you very much!), I have an entirely new issue. I am sure this issue has to do with my case statement logic. I am getting multiple rows, when I am only looking for one. Here is my code:
    SELECT
      CASE
        WHEN EP.PHYSICAL_DATE IS NULL
        THEN
          CASE
            WHEN EC.ORIGINAL_CONTRACT_START < ((SYSDATE) - 365)
            THEN 'NEEDS PHYSICAL'
            WHEN EC.ORIGINAL_CONTRACT_START < ((SYSDATE) - 330)
            THEN 'COMING UP'
            ELSE 'No'
            END
        WHEN EP.PHYSICAL_DATE IS NOT NULL
        THEN
          CASE
            WHEN MAX(EP.PHYSICAL_DATE) KEEP (DENSE_RANK LAST ORDER BY EP.PHYSICAL_DATE) < ((SYSDATE) - 365)
            THEN 'NEEDS PHYSICAL'
            WHEN MAX(EP.PHYSICAL_DATE) KEEP (DENSE_RANK LAST ORDER BY EP.PHYSICAL_DATE) < ((SYSDATE) - 330)
            THEN 'COMING UP'
            ELSE 'No'
            END
      END "Needs Physical?"
    FROM AP AE
    LEFT JOIN EMP_PHYSICAL EP
    ON AE.EMP_ID = EP.EMP_ID
    LEFT JOIN POSITION_OFFERED PO
    ON AE.EMP_ID = PO.EMP_ID
    LEFT JOIN EMP_CONTRACT EC
    ON AE.EMP_ID         = EC.EMP_ID
    WHERE PO.ACTUAL_END IS NULL
    AND (EP.PHYSICAL     = 1
    OR EP.PHYSICAL      IS NULL)
    AND :P71_EMP_ID = AE.EMP_ID
    GROUP BY EP.PHYSICAL_DATE, EC.ORIGINAL_CONTRACT_START;The OUTPUT is:
    Needs Physical?
    Row 1 NEEDS PHYSICAL
    Row 2 No
    However, only one of these rows should be the output, which is "No". How do you get a nested case statement to evaluate to one result, instead of multiple? I'm quite sure it is in the logic. To spell it out, this is what I am trying to accomplish with the above code:
    If the "EP.PHYSICAL_DATE" is null, then use these sets of formula's to evalute the output, BUT if the "EP.PHYSICAL_DATE" is not null, then use these set's of formula's to evaluate the output.
    As it stands now, it appears as if my nested case statement is doing exactly what I told it to do, which is to evaluate both conditions, and output both.
    Any help would be appreciated. Thanks.
    Aqua
    Edited by: AquaNX4 on Mar 26, 2013 6:30 AM

    If you define your service_level as a table then it will be much easier.
    with service_level
    as
    select 'ALL' parent_lvl, 'Sergeant' srv_lvl from dual union all
    select 'ALL', 'Bonus I' from dual union all
    select 'ALL', 'Deputy Bailiff' from dual union all
    select 'ALL', 'Deputy Lockup' from dual union all
    select 'ALL', 'Deputy Bailiff Security' from dual union all
    select 'ALL', 'Custody Assistant' from dual union all
    select 'ALL', 'Security Officer' from dual union all
    select 'ALL', 'Security Assistant' from dual union all
    select 'ALL', 'Security Officer and Security Assistant' from dual union all
    select 'ALL', 'Private Security' from dual union all
    select 'All Deputies', 'Deputy Bailiff' srv_lvl from dual union all
    select 'All Deputies', 'Deputy Bailiff Security' from dual union all
    select 'All Deputies', 'Deputy Lockup' from dual union all
    select 'All Sworn', 'Sergeant' srv_lvl from dual union all
    select 'All Sworn','Bonus I' from dual union all
    select 'All Sworn','All Deputies' from dual union all
    select 'All Sworn','Deputy Bailiff' from dual union all
    select 'All Sworn','Deputy Lockup' from dual union all
    select 'All Sworn','Deputy Bailiff Security' from dual
    select *
      from in_service
    where rank IN (
              select srv_lvl
                from service_level
               where upper(parent_lvl) = upper(:SL)
                  or upper(srv_lvl) = upper(:SL)
                   )

  • Please Help Nested Editable Region Image & Spry

    Please Help Me.
    New to Dreamweaver. I've been given a "grandchild" nested temple with only one editable region to alter. I've read and Googled since Saturday. My brain actually hurts.
    Goal
    - Insert my background image into region
    - Add Spry accordion to mid left
    - Add Spry collapsible to bottom right
    How can 3 things be so hard? Please, can someone walk me through this? Thank you

    I've been given a "grandchild" nested template with only one editable region to alter.
    Nested templates.  Aaaaaak! There's no advantage in nested templates, ever.  They're so problematic it makes my head hurt just thinking about them.
    If you have the parent and grandparent template.dwt files to work with, you'll need to insert Editable Regions to hold your scripts and other supporting widget code.
    If you don't have those files and you can't edit the <head>, you can't insert widgets into Template child or grandchild pages.  You'll need to detach the page from Templates.
    Nancy O.

  • Power Query for Excel - Need Help with Oracle SQL Syntax

    Hello everyone,
    I am new to Power Query and am not able to figure this out.  I am trying to pull in data into my Excel spreadsheet using a specific Oracle SQL query.  While in query editor, how do I take the Oracle.Database function and add my SQL statement? 
    I already know what I want, I don't want it to download all the table names.  According to the help page, I should be able to do this but it does not provide a syntax example
    Also, I don't understand what "optional options as nullable record" means.
    Below is what function and arguments the help page notes.  How do I use this?
    Oracle.Database(server as text, optional options as nullable record) as table
    Any help is greatly appreciated.
    Thank you,
    Jessica

    When I try this, I get an error 
    DataSource.Error: Oracle: Sql.Database does not support the query option 'Query' with value '"Select * from Owner.View_Name"'. Details: null
    I'm trying to download oracle data from a view into power query - Power Query navigator does not list th eviews from my source, it lists only the tables. When I try write sql statements, it throws me the above
    error. This is what I tried
     Oracle.Database("Source/Service",[Query="Select * from Owner.View_Name"])
    Any ideas how to fix this? 

  • NEAD HELP WITH MISsING LINGO SyNtAx

    I need help
    I tray to convert my project build in director 6.5 in to mx
    2004.
    Problem is that in mx 2004 there is
    no lingo syntax modal
    Modal (the following is explanations from director 9 s help)
    Syntax
    window "window".modal
    the modal of window "window"
    Description
    Window property; specifies whether movies can respond to
    events that occur outside the window specified by window.
    When the modal window property is TRUE, movies cannot
    respond to events outside the window.
    When the modal window property is FALSE, movies can respond
    to events outside the window.
    With that syntax I force users to first close pop-up windows and
    than go further
    Is there anything like that in mx 2004.What to do???????/

    Well, the problem is that you are not using Director 9, and
    since there
    is no #modal option in the version you are using, you really
    should try
    to stick with what is available in Director 10. You can use a
    #tool
    dialog (be aware that #tool windows work differently in
    Authoring and in
    Projectors).
    Also, you can temporarily set Director to use older legacy
    syntax y
    changing the scriptExecutionStyle
    the scriptExecutionStyle=9
    --use old syntax here
    the scriptExecutionStyle=10
    --back to normal Dire10 style Lingo

  • Help! RDBMSCodeGenerator creates syntax errors!

    We have recompiled our Weblogic 8.1 product on Weblogic 9.2, and while re-deploying
    our EJBs one of our CMP beans curiously and unusually failed to deploy. The failure to deploy
    stems from syntax errors generated by RDBMSCodeGenerator!
    When we turn off use-select-for-update, the offending code is no longer
    generated and the EJB deploys, but we need and depend on this feature being enabled, so simply
    leaving this off is not a viable solution.
    Here's the header, so you know I'm not hallucinating.
    * This code was automatically generated at 10:43:37 AM on May 30, 2007
    * by weblogic.ejb.container.cmp.rdbms.codegen.RDBMSCodeGenerator -- do not edit.
    * @version WebLogic Server 9.2 MP1  Sun Jan 7 00:56:31 EST 2007 883308
    * @author Copyright (c) 2007 by BEA Systems, Inc. All Rights Reserved.
    */The offending code occurs in nine separate methods, all in the same line of code: an if statement.
    The if statement has two opening parentheses, and three closing parentheses!!
    if (!__WL_pkMap.containsKey(__WL_pk))) {(One such broken method is at the bottom of this post.)
    The seventh instance of this syntax error contains a second syntax error. It appears
    that the code generator corrupted the variable name as well:
    if (!WL_pkMap.containsKey(__WL_pk))) {(The two underscores at the beginning of the variable are missing.)
    Now, when use-select-for-update is removed, the compiler generates a slightly different if clause,
    but with no syntax errors. The __WL_pkMap variable is also written correctly.
    Has anyone encountered this? Can anyone surmise what might be going on??
    I think this might need to be posted as a bug. What do you think?
    Torin...
    Attached: One offending method (of nine) with the error highlighted and underscored is (about two-thirds of the way down):
    public java.util.Collection ejbFindByReturnValue(java.lang.String param0) throws javax.ejb.FinderException
        if(__WL_debugLogger.isDebugEnabled()) {
          __WL_debug("called findByReturnValue");
        java.sql.Connection __WL_con = null;
        java.sql.PreparedStatement __WL_stmt = null;
        java.sql.ResultSet __WL_rs = null;
        int __WL_offset = 0;
        __WL_pm.flushModifiedBeans();
        int updateLockType = __WL_pm.getUpdateLockType();
        java.lang.String __WL_query = null;
        switch(updateLockType) {
          case DDConstants.UPDATE_LOCK_AS_GENERATED:
          __WL_query = "SELECT  WL0.JOB_ID, WL0.COMPONENT_ID, WL0.HOSTNAME, WL0.LAST_EVENT, WL0.MESSAGE, WL0.PARAMETER, WL0.PARENT_JOB_ID, WL0.PID, WL0.PROGRESS, WL0.RETURN_VALUE, WL0.STATUS  FROM JOB_QUEUE WL0 WHERE ( WL0.RETURN_VALUE = ? ) FOR UPDATE ";
          break;
          case DDConstants.UPDATE_LOCK_TX_LEVEL:
          __WL_query = "SELECT  WL0.JOB_ID, WL0.COMPONENT_ID, WL0.HOSTNAME, WL0.LAST_EVENT, WL0.MESSAGE, WL0.PARAMETER, WL0.PARENT_JOB_ID, WL0.PID, WL0.PROGRESS, WL0.RETURN_VALUE, WL0.STATUS  FROM JOB_QUEUE WL0 WHERE ( WL0.RETURN_VALUE = ? ) FOR UPDATE ";
          break;
          case DDConstants.UPDATE_LOCK_TX_LEVEL_NO_WAIT:
          __WL_query = "SELECT  WL0.JOB_ID, WL0.COMPONENT_ID, WL0.HOSTNAME, WL0.LAST_EVENT, WL0.MESSAGE, WL0.PARAMETER, WL0.PARENT_JOB_ID, WL0.PID, WL0.PROGRESS, WL0.RETURN_VALUE, WL0.STATUS  FROM JOB_QUEUE WL0 WHERE ( WL0.RETURN_VALUE = ? ) FOR UPDATE NOWAIT ";
          break;
          case DDConstants.UPDATE_LOCK_NONE:
          __WL_query = "SELECT DISTINCT WL0.JOB_ID, WL0.COMPONENT_ID, WL0.HOSTNAME, WL0.LAST_EVENT, WL0.MESSAGE, WL0.PARAMETER, WL0.PARENT_JOB_ID, WL0.PID, WL0.PROGRESS, WL0.RETURN_VALUE, WL0.STATUS  FROM JOB_QUEUE WL0 WHERE ( WL0.RETURN_VALUE = ? )";
          break;
          default:
          throw new AssertionError(
          "Unknown update lock type: '"+updateLockType+"'");
        if(__WL_debugLogger.isDebugEnabled()) {
          __WL_debug("Finder produced statement string " + __WL_query);
        try {
          __WL_con = __WL_pm.getConnection();
        catch (java.lang.Exception e) {
          __WL_pm.releaseResources(__WL_con, __WL_stmt, __WL_rs);
          throw new javax.ejb.FinderException("Couldn't get connection: " + EOL +
          e.toString() + EOL +
          RDBMSUtils.throwable2StackTrace(e));
        try {
          __WL_stmt = __WL_con.prepareStatement(__WL_query);
          // preparedStatementParamIndex reset.
          if (param0 == null) {
            __WL_stmt.setNull(1,java.sql.Types.VARCHAR);
          } else {
            __WL_stmt.setString(1, param0);
            if (__WL_debugLogger.isDebugEnabled()) {
              __WL_debug("paramIdx :"+1+" binded with value :"+param0);
          __WL_rs = __WL_stmt.executeQuery();
        catch (java.lang.Exception e) {
          __WL_pm.releaseResources(__WL_con, __WL_stmt, __WL_rs);
          throw new javax.ejb.FinderException(
          "Exception in findByReturnValue while preparing or executing " +
          "query: '" +
          __WL_query + "': " + EOL +
          "statement: '" + __WL_stmt + "'" + EOL +
          e.toString() + EOL +
          RDBMSUtils.throwable2StackTrace(e));
        try {
          java.util.Collection __WL_collection = new java.util.ArrayList();
          com.quickplay.mmp.ingestionservices.ejb.JobQueue_r6lr5u__WebLogic_CMP_RDBMS __WL_bean = null;
          Object __WL_eo = null;
          Object __WL_eo_rc = null;
          Map __WL_pkMap = new HashMap();
          while (__WL_rs.next()) {
            Integer __WL_offsetIntObj = new Integer(0);
            Object __WL_pk = __WL_getPKFromRS(__WL_rs, __WL_offsetIntObj, __WL_classLoader);
            __WL_eo = null;
            if (__WL_pk != null) {
              if (!__WL_pkMap.containsKey(__WL_pk))) {
                RSInfo __WL_rsInfo = new RSInfoImpl(__WL_rs, 0, 0, __WL_pk);
                __WL_bean = (com.quickplay.mmp.ingestionservices.ejb.JobQueue_r6lr5u__WebLogic_CMP_RDBMS)__WL_pm.getBeanFromRS(__WL_pk, __WL_rsInfo);
                __WL_eo = __WL_pm.finderGetEoFromBeanOrPk(__WL_bean, __WL_pk, __WL_getIsLocal());
                if (__WL_debugLogger.isDebugEnabled()) __WL_debug("bean after finder load: " + ((__WL_bean == null) ? "null" : __WL_bean.hashCode()));
                if( __WL_bean == null || ( __WL_bean != null && !__WL_bean.__WL_getIsRemoved()))
                  __WL_collection.add(__WL_eo);
                Object __WL_retVal = __WL_pkMap.put(__WL_pk, __WL_bean);
            } else {
              if (__WL_pm.isFindersReturnNulls()) {
                __WL_collection.add(null);
          return __WL_collection;
        } catch (java.sql.SQLException sqle) {
          throw new javax.ejb.FinderException(
          "Exception in 'findByReturnValue' while using " +
          "result set: '" + __WL_rs + "'" + EOL +
          sqle.toString() + EOL +
          RDBMSUtils.throwable2StackTrace(sqle));
        } catch (java.lang.Exception e) {
          throw new javax.ejb.FinderException(
          "Exception executing finder 'findByReturnValue': " + EOL +
          e.toString() + EOL +
          RDBMSUtils.throwable2StackTrace(e));
        } finally {
          __WL_pm.releaseResources(__WL_con, __WL_stmt, __WL_rs);
      }

    Dreamweaver will not produce such a mess when using column names which comply with the MySQL Naming Conventions and don´t contain (often quite problematic) hyphen characters.
    That said, you´ll be on the safe side when renaming your columns by using underscores instead, example:
    about_p3_img
    Several other web developers have told me that they entirely abandoned DW CS* series and moved on to other IDE's rather than try to fix the problem.
    Dreamweaver is certainly not a "perfect" PHP development IDE, but other IDEs (I use Komodo or Aptana at times and like them a lot...) aren´t perfect either. This may seem strange, but IMO Dreamweaver did do the - sort of - right thing by not letting the user get away with using such problematic characters, and that´s what those other IDEs I work with regretfully don´t pay attention to.

  • Help:Nested Inner Join

    Hello Folks,
    I have a query which has a nested Inner Join as follows
    INNER JOIN(Client
    INNER JOIN CUBS SNAPSHOT ON Client . Client = CUBS SNAPSHOT . CLIENT) ON CancelDesc . CancelReason = CUBS SNAPSHOT . CANCELREASONcouldnt figure out wat is the quivalent of this nested inner join in Oracle Server. I am trying to create a report based on this inner join of a query. Can anyone throw some light on this.
    Thanks

    Hi,
    Inner joins don't need to be nested. The results will be the same, no matter in what order the tables are joined.
    In Oracle, don't use table names with spaces in them, and don't put spaces before or after the dots that separate table name qualifiers from column names.
    I think this is what you want:
    INNER JOIN     cubs_snapshot  ON     CancelDesc.CancelReason = cubs_snapshot.cancelreason
    INNER JOIN     Client            ON     Client.Client           = cubs_snapshot.clientWhenever you have a question, post a little sample data (CREATE TABLE and INSERT statememts) for all tables invlovled, and the results you want from that data.
    If you really did need to nest joins, you could join some tables in a sub-query, then use the result set of that sub-query as if it were a table.
    For example:
    WITH  cubs_and_client            AS
         SELECT     CancelReason
         ,     ...     -- Whatever other columns are needed in superior query or queries
         FROM          client
         INNER JOIN     cubs_snapshot     ON     Client.Client           = cubs_snapshot.client
    SELECT     
    INNER JOIN     cubs_and_client     ON     CancelDesc.CancelReason = cubs_and_client.CancelReason
    ...In this example, the two tables cubs_snapshot and client are joined in a sub-query. The results of that sub-query can be referenced later in the query as if it were a table called cubs_and_client, very much like a view.

  • Help for correct generics syntax

    I'm trying to write a generics version of an old non-generics program. But after a few hours trials in this afternoon, I still fails in compile.
    Error message from javac is:
    Library3.java:55: cannot find symbol
    symbol  : constructor SoftReference(BookShelf,java.lang.ref.ReferenceQueue<BookShelfReference>)
    location: class java.lang.ref.SoftReference<BookShelf>
        super(shelf, collectedQueue);
        ^
    1 errorAnd below is the code:
    /* Library3.java
    * from Item 11, Java Pitfalls, M.Daconta et al
    * John Wiley & Sons, 2000
    * trying to adapt to Java Generics feature
    * hiwa, 13 Aug. 2007
    import java.util.Random;
    import java.lang.ref.SoftReference;
    import java.lang.ref.ReferenceQueue;
    class TextPage
      char[] symbols = new char[300];
    class Book
      String      name;
      TextPage    pages[] = new TextPage[100];
      public Book ()
        for (int i = 0; i < pages.length; i++)
          pages[i] = new TextPage();
    class BookShelf
      String subject;
      Book[] books = new Book[100];
      public BookShelf (String subject)
        this.subject = subject;
        for (int i = 0; i < books.length; i++)
          books[i] = new Book();
        if (subject.equals("Sports"))
          books[0].name = "History of Ping Pong";
    class BookShelfReference extends SoftReference<BookShelf>
      String subject;
      //?? what should be the correct syntax here?
      static ReferenceQueue<BookShelfReference> collectedQueue
        = new ReferenceQueue<BookShelfReference>();
      public BookShelfReference (BookShelf shelf)
        //?? and here?
        super(shelf, collectedQueue);
        this.subject = shelf.subject;
    class GarbageMonitor extends Thread
      ReferenceQueue queue;
      public GarbageMonitor (ReferenceQueue queue)
        this.queue = queue;
      public void run ()
        while (true)
          try
            BookShelfReference shelfRef =
              (BookShelfReference) queue.remove(5000);
            System.out.println("Monitor: Shelf subject '" +
                shelfRef.subject + "' was collected.");
          catch (Exception e)
          {   break;  }
    public class Library3
      public static void main (String args[])
        String subjects[] = { "Sports", "New Age", "Religion",
          "Sci-Fi", "Romance", "Do-it-yourself",
          "Cooking", "Gardening", "Travel",
          "Mystery", "Fantasy", "Computers",
          "Business", "Young readers", "JW Books" };
        GarbageMonitor monitor =
          new GarbageMonitor(BookShelfReference.collectedQueue);
        monitor.start();
        BookShelfReference[] shelves = new BookShelfReference[25];
        int checkIndex = 10 + getRandomIndex(15);
        for (int i = 0; i < shelves.length; i++)
          String subject = subjects[getRandomIndex(subjects.length)];
          System.out.println("Creating bookshelf: " + (i + 1) +
              ", subject: " + subject);
          // Keep track of shelves as SoftReference objects
          shelves[i] = new BookShelfReference(new BookShelf(subject));
          // at a random interval check to see where the last
          //  "Sports" shelf was
          if (i == checkIndex)
            System.out.println("Checking for Sports...");
            for (int j = i; j >= 0; j--)
              // get BookShelf reference from SoftReference
              BookShelf shelf = (BookShelf)shelves[j].get();
              if (shelf != null)
                if (shelf.subject.equals("Sports"))
                  System.out.println();
                  System.out.println("Shelf " + (j + 1) +
                      " is Sports");
                  System.out.println("First book is: " +
                      shelf.books[0].name);
                  System.out.println();
                  break;
                else
                  System.out.println("No match. " +
                      "Subject was: " + shelf.subject);
      private static Random rnd = new Random(System.currentTimeMillis());
      private static int getRandomIndex (int range)
        return ((Math.abs(rnd.nextInt())) % range);
    }

    About ten minutes after posting previous post, I found the correct syntax by chance:
    The previous code
      static ReferenceQueue<BookShelfReference> collectedQueue
        = new ReferenceQueue<BookShelfReference>();should be:
      static ReferenceQueue<BookShelf> collectedQueue
        = new ReferenceQueue<BookShelf>();But I still don't understand why the content of the referencequeue is specified as a referent type, not a reference type.

  • Help with PL/SQL syntax

    Hi,
    In the code below, After a Bulk Insert, i tried to include an UPDATE statement(shown in Italics below) which will update a table . Then I received error. This code will work fine with that UPDATE statement. What do i need to change in the syntax to make this UPDATE statement work?
    DECLARE TYPE ename_type IS TABLE OF VARCHAR2(15) INDEX BY PLS_INTEGER;
    v_ename ename_type;
    BEGIN
    SELECT emp.ename BULK COLLECT INTO v_ename FROM emp;
    FORALL i IN 1..v_ename.count
    INSERT INTO TESTENAME VALUES(v_ename(i));
    UPDATE DEPT SET LOCATION='NY';
    END;
    /

    I am sorry. I managed to solve this problem. It was a typo.

  • Help me with the syntax

    This basic select will give me will count each occurence of origin. What would the syntax be if I wanted the SQL to return how many different origins there are (not how many each occurs)?
    select origin, count(*) from voucher group by origin
    Thanks all!!

    SQL> select deptno from emp;
                  DEPTNO
                      20
                      30
                      30
                      20
                      30
                      30
                      10
                      20
                      10
                      30
                      20
                      30
                      20
                      10
    14 rows selected.
    SQL> select distinct deptno from emp;
                  DEPTNO
                      10
                      20
                      30
    SQL> select count (distinct deptno) from emp;
    COUNT(DISTINCTDEPTNO)
                        3

  • Need help on post default syntax

    Hi
    I would like to setup post default syntax for field in oppty.
    I had tried below syntax and it worked :
    IIf([<Probability>]="90","A",
    IIf([<Probability>]="70","B",
    IIf([<Probability>]="50","C",
    IIf([<Probability>]="30","D",
    IIf([<Probability>]="100","S",
    "E")))))
    However when I added more conditions to the syntax, it doesn't work.
    IIf([<Probability>]="100","S",
    IIf(([<OpportunityType>]="GI" AND [<Probability>]="90"),"A",
    IIf(([<OpportunityType>]="GI" AND [<Probability>]="80"),"B",
    IIf(([<OpportunityType>]="GI" AND [<Probability>]="50"),"C",
    IIf(([<OpportunityType>]="GI" AND [<Probability>]="30"),"D",
    IIf(([<OpportunityType>]="GI" AND [<Probability>]="0"),"E",
    IIf(([<OpportunityType>]="SC" AND [<Probability>]="80"),"A",
    IIf(([<OpportunityType>]="SC" AND [<Probability>]="60"),"B",
    IIf(([<OpportunityType>]="SC" AND [<Probability>]="0"),"C",
    IIf(([<OpportunityType>]="ST" AND [<Probability>]="90"),"A",
    IIf(([<OpportunityType>]="ST" AND [<Probability>]="70"),"B",
    IIf(([<OpportunityType>]="ST" AND [<Probability>]="50"),"C",
    IIf(([<OpportunityType>]="ST" AND [<Probability>]="30"),"E",
    IIf(([<OpportunityType>]="ST" AND [<Probability>]="20"),"F",
    IIf(([<OpportunityType>]="ST" AND [<Probability>]="10"),"G",
    IIf(([<OpportunityType>]="ST" AND [<Probability>]="0"),"H",
    Anyone knows where I'm went wrong?

    Hi, Are you getting a sybtax error, if so try out this. While you see this the Squar brackets around the field is not shown. You can send me out an email
    IIf([<Probability>]="100","S",IIf(([<OpportunityType>]="GI" AND[<Probability>]="90"),"A",IIf(([<OpportunityType>]="GI" AND [<Probability>]="80"),"B",IIf(([<OpportunityType>]="GI" AND [<Probability>]="50"),"C",IIf(([<OpportunityType>]="GI" AND [<Probability>]="30"),"D",IIf(([<OpportunityType>]="GI" AND [<Probability>]="0"),"E",IIf(([<OpportunityType>]="SC" AND [<Probability>]="80"),"A",IIf(([<OpportunityType>]="SC" AND [<Probability>]="60"),"B",IIf(([<OpportunityType>]="SC" AND [<Probability>]="0"),"C",IIf(([<OpportunityType>]="ST" AND [<Probability>]="90"),"A",IIf(([<OpportunityType>]="ST" AND [<Probability>]="70"),"B",IIf(([<OpportunityType>]="ST" AND [<Probability>]="50"),"C",IIf(([<OpportunityType>]="ST" AND [<Probability>]="30"),"E",IIf(([<OpportunityType>]="ST" AND [<Probability>]="20"),"F",IIf(([<OpportunityType>]="ST" AND [<Probability>]="10"),"G",IIf(([<OpportunityType>]="ST" AND [<Probability>]="0"),"H",""))))))))))))))))
    -- Venky CRMIT
    Edited by: Venky CRMIT on Aug 26, 2009 3:40 PM

Maybe you are looking for

  • How do I move my PC iTunes collection to my Mac with Drobo FS?

    My iTunes collection is big--2,000 GB (2 TB).  It grew up on my first-generation Drobo, attached to my Windows laptop.  I recently purchased a Mac, and a Drobo FS.  The DroboApp Firefly was my planned method of execution, until I discovered that iTun

  • [EB3]Events not working in Photoshop

    Hi All, Except the "applicationActivate", other events- - documentAfterActivate - documentAfterDeactivate - documentAfterSave are not working in Photoshop; strange thing is that they are working in InDesign. The code I'm using(working in case of InDe

  • Ability to Queue Rather than "Open" Hundreds of Files

    Problem: I have 500 JPEG files to edit in Photoshop.  I cannot "open" more than 200 files at once for editing. Solution: Make a "Queue" option to allow me to queue as many files as I desire.  Only one file will be open at a time for editing, and when

  • How to show pending transfers

    Hey, I recently upgraded my iTunes for Windows... but I cannot see how to show pending file transfers when moving music to my iPod. When I click on my device, it only shows the current music thats on it... and not the queue of files currently in rout

  • Print large cells without page break

    I am trying to print a continuous spreadsheet. The print tries to keep a cell intact with tons of wasted paper in between. How do I turn off that "keep cell together when printing" concept?