Referencing a query in a nested struct

I have a nested struct that is being brought back from a
component. It looks like this
office_struct[ floor1_struct[ some query results]
floor2_struct[some query results] ....]
I am trying to reference the query so I can print it out to
screen. How would I do that?
I know for a normal nested sctruct I can use dot notation.
i.e office_struct.floor1_struct.value =
#office_struct[floor1_struct].value#

You can usually do the same thing, but I know in version
past, and I do
not know if it has yet been resolved, that some tags that
expect a query
variable get confused if the query is nested in too complex a
data
structure. For this I have just referenced the complex query
value with
a simple local variable name and then used that in the tags
needing a
reference to the query.
I.E.
If <cfoutput query="office_struct.floo1_struct" ....>
does not work try:
<cfset variables.localQuery =
office_struct.floor_struct>
<cfoutput query="variables.localQuery"....>

Similar Messages

  • Query rewrites with Nested materialized views with different aggregations

    Platform used : Oracle 11g.
    Here is a simple fact table (with measures m1,m2) and dimensions (a) Location (b) Calendar and (c) Product. The business problem is that aggregation operator for measure m1,m2 are different along location dimension and Calendar dimension. The intention is to preaggregate the measures for a product along the calendar dimension and Location dimension and store it as materialized views.
    The direct option is to define a materialized view with Inline queries (Because of the different aggrergation operator, it is not possible to write a query without Inline query). http://download-uk.oracle.com/docs/cd/B28359_01/server.111/b28313/qradv.htm#BABEAJBF documents the limitations that it works only for 'Text match' and 'Equivalent queries' and that is too limiting.
    So decided to have nested materialized view, with first view having just joins(my_dim_mvw_joins), the second view having aggregations along Calendar dimension (my_dim_mvw_calendar) and third view having aggregations along the Location dimension(my_dim_mvw_location). Obviously I do not want the query I fire to know about materialized views and I fire it against the fact table. I see that for the fired query (Which needs aggregations along both Calendar and Location), is rewritten with just second materialized view but not the third. (Had set QUERY_REWRITE_INTEGRITY as TRUSTED) .
    Wanted to know whether there are limitations on Query Writes with nested materialized views? Thanks
    (Have given a simple testable example below. Pls ignore the values given in 'CALENDAR_IDs', 'PRODUCT_IDs' etc as they are the same for all the queries)
    -- Calendar hierarchy table
    CREATE TABLE CALENDAR_HIERARCHY_TREE
    (     "CALENDAR_ID" NUMBER(5,0) NOT NULL ENABLE,
    "HIERARCHY1_ID" NUMBER(5,0),
    "HIERARCHY2_ID" NUMBER(5,0),
    "HIERARCHY3_ID" NUMBER(5,0),
    "HIERARCHY4_ID" NUMBER(5,0),
    CONSTRAINT "CALENDAR_HIERARCHY_TREE_PK" PRIMARY KEY ("CALENDAR_ID")
    -- Location hierarchy table
    CREATE TABLE LOCATION_HIERARCHY_TREE
    (     "LOCATION_ID" NUMBER(3,0) NOT NULL ENABLE,
    "HIERARCHY1_ID" NUMBER(3,0),
    "HIERARCHY2_ID" NUMBER(3,0),
    "HIERARCHY3_ID" NUMBER(3,0),
    "HIERARCHY4_ID" NUMBER(3,0),
    CONSTRAINT "LOCATION_HIERARCHY_TREE_PK" PRIMARY KEY ("LOCATION_ID")
    -- Product hierarchy table
    CREATE TABLE PRODUCT_HIERARCHY_TREE
    (     "PRODUCT_ID" NUMBER(3,0) NOT NULL ENABLE,
         "HIERARCHY1_ID" NUMBER(3,0),
         "HIERARCHY2_ID" NUMBER(3,0),
         "HIERARCHY3_ID" NUMBER(3,0),
         "HIERARCHY4_ID" NUMBER(3,0),
         "HIERARCHY5_ID" NUMBER(3,0),
         "HIERARCHY6_ID" NUMBER(3,0),
         CONSTRAINT "PRODUCT_HIERARCHY_TREE_PK" PRIMARY KEY ("PRODUCT_ID")
    -- Fact table
    CREATE TABLE RETAILER_SALES_TBL
    (     "PRODUCT_ID" NUMBER,
    "PRODUCT_KEY" VARCHAR2(50 BYTE),
    "PLAN_ID" NUMBER,
    "PLAN_PERIOD_ID" NUMBER,
    "PERIOD_ID" NUMBER(5,0),
    "M1" NUMBER,
    "M2" NUMBER,
    "M3" NUMBER,
    "M4" NUMBER,
    "M5" NUMBER,
    "M6" NUMBER,
    "M7" NUMBER,
    "M8" NUMBER,
    "LOCATION_ID" NUMBER(3,0),
    "M9" NUMBER,
    CONSTRAINT "RETAILER_SALES_TBL_LOCATI_FK1" FOREIGN KEY ("LOCATION_ID")
    REFERENCES LOCATION_HIERARCHY_TREE ("LOCATION_ID") ENABLE,
    CONSTRAINT "RETAILER_SALES_TBL_PRODUC_FK1" FOREIGN KEY ("PRODUCT_ID")
    REFERENCES PRODUCT_HIERARCHY_TREE ("PRODUCT_ID") ENABLE,
    CONSTRAINT "RETAILER_SALES_TBL_CALEND_FK1" FOREIGN KEY ("PERIOD_ID")
    REFERENCES CALENDAR_HIERARCHY_TREE ("CALENDAR_ID") ENABLE
    -- Location dimension definition to promote query rewrite
    create DIMENSION LOCATION_DIM
    LEVEL CHAIN IS LOCATION_HIERARCHY_TREE.HIERARCHY1_ID
    LEVEL CONSUMER_SEGMENT IS LOCATION_HIERARCHY_TREE.HIERARCHY3_ID
    LEVEL STORE IS LOCATION_HIERARCHY_TREE.LOCATION_ID
    LEVEL TRADING_AREA IS LOCATION_HIERARCHY_TREE.HIERARCHY2_ID
    HIERARCHY PROD_ROLLUP (
    STORE CHILD OF
    CONSUMER_SEGMENT CHILD OF
    TRADING_AREA CHILD OF
    CHAIN
    -- Calendar dimension definition
    create DIMENSION CALENDAR_DIM
    LEVEL MONTH IS CALENDAR_HIERARCHY_TREE.HIERARCHY3_ID
    LEVEL QUARTER IS CALENDAR_HIERARCHY_TREE.HIERARCHY2_ID
    LEVEL WEEK IS CALENDAR_HIERARCHY_TREE.CALENDAR_ID
    LEVEL YEAR IS CALENDAR_HIERARCHY_TREE.HIERARCHY1_ID
    HIERARCHY CALENDAR_ROLLUP (
    WEEK CHILD OF
    MONTH CHILD OF
    QUARTER CHILD OF
    YEAR
    -- Materialized view with just joins needed for other views
    CREATE MATERIALIZED VIEW my_dim_mvw_joins build immediate refresh complete enable query rewrite as
    select product_id, lht.HIERARCHY1_ID, lht.HIERARCHY2_ID, lht.HIERARCHY3_ID, lht.location_id, cht.HIERARCHY1_ID year,
    cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week, m1, m3, m7, m9
    from retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
    WHERE RS.period_id = cht.CALENDAR_ID
    and RS.location_id = lht.location_id
    and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
    AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
    AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
    -- Materialized view which aggregate along calendar dimension
    CREATE MATERIALIZED VIEW my_dim_mvw_calendar build immediate refresh complete enable query rewrite as
    select product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID ,location_id, year, quarter, month, week,
    sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total,
    GROUPING_ID(product_id, location_id, year, quarter, month, week) dim_mvw_gid
    from my_dim_mvw_joins
    GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id,
    rollup (year, quarter, month, week);
    -- Materialized view which aggregate along Location dimension
    CREATE MATERIALIZED VIEW my_dim_mvw_location build immediate refresh complete enable query rewrite as
    select product_id, year, quarter, month, week, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id,
    sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1,
    GROUPING_ID(product_id, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id, year, quarter, month, week) dim_mvw_gid
    from my_dim_mvw_calendar
    GROUP BY product_id, year, quarter, month, week,
    rollup (HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id)
    -- SQL Query Fired (for simplicity have used SUM as aggregation operator for both, but they will be different)
    select product_id, year, HIERARCHY1_ID, HIERARCHY2_ID,
    sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1
    from
    select product_id, HIERARCHY1_ID , HIERARCHY2_ID , year,
    sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total
    from
    select product_id, lht.HIERARCHY1_ID , lht.HIERARCHY2_ID , lht.HIERARCHY3_ID ,lht.location_id, cht.HIERARCHY1_ID year, cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week,m1,m3,m7,m9
    from
    retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
    WHERE RS.period_id = cht.CALENDAR_ID
    and RS.location_id = lht.location_id
    and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
    AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
    AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
    GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id, year
    ) sales_time
    GROUP BY product_id, year,HIERARCHY1_ID, HIERARCHY2_ID
    This Query rewrites only with my_dim_mvw_calendar. (as saw in Query Plan and EXPLAIN_MVIEW). But we would like it to use my_dim_mvw_location as that has aggregations for both dimensions.

    blackhole001 wrote:
    Hi all,
    I'm trying to make my programmer's life easier by creating a database view for them to query the data, so they don't have to worry about joining tables. This sounds like a pretty horrible idea. I say this because you will eventually end up with programmers that know nothing about your data model and how to properly interact with it.
    Additionally, what you will get is a developer that takes one of your views and see's that of the 20 columns in it, it has 4 that he needs. If all those 4 columns comes from a simple 2 table join, but the view has 8 tables, you're wasting a tonne of resources by using the view (and heaven forbid they have to join that view to another view to get 4 of the 20 columns from that other view as well).
    Ideally you'd write stored routines that satisfy exactly what is required (if you are the database resource and these other programmers are java, .net, etc... based) and the front end developers would call those routines customized for an exact purpose.
    Creating views is not bad, but it's by no means a proper solution to having developers not learn or understand SQL and/or the data model.

  • Traverse A Nested Struct

    Any thoughts on the quickest way to the last struct in a
    nested struct without knowing the keys or how deep it's nested? And
    of course it could branch much like trying to traverse a
    tree.

    I wasn't looking for an alphabetical list, just trying to get
    to the inner most nested struct the quickest. In you example, how
    would I get the value of employee.phone.office.ext without
    previousley knowing that phone.office.ext existed and I only know
    about employee. I could iterate over it with some type of iterator
    hasNext(), but was wondering if there was a quicker way.
    <cfset employee.name.first = "Mary">
    <cfset employee.name.last = "Smith">
    <cfset employee.position = "Boss">
    <cfset employee.phone.home = "111-2222-33333">
    <cfset employee.phone.office.ext = "444">
    <cfset employee.phone.office.number>

  • Who to query and join nested elements

    I have a table that contains a XMLTYPE Field. How do I query and join nested elements. For example I have a schema that has a PerstrenList element that holds one or more Perstren nodes.  The Perstren node will contain a RemarksList node that can contain one or more Remarks nodes.  My goal is to query all of the Remarks and join them with the information in it's parent node. Without the parent node information the remark is meaningless.  Following is a example document and desire result set. I know how to query the Perstren or the Remarks I just can not figure out how to marry the two. The query should only return the remarks joined with the parent information.
    <RasDataSet>
       <PerstrenList>
            <Perstren>
               <TPERS>A</TPERS>
               <DEPLY>B</DEPLY>
               <STRUC>5</STRUC>
               <RemarksList>
                   <REMARK>
                        <LABEL>ABC</LABEL>
                        <GENTEXT>Hello world</GENTEXT>
                   </REMARK>
                   <REMARK>
                        <LABEL>XYZ</LABEL>
                        <GENTEXT>Oracle XML</GENTEXT>
                   </REMARK>
               <RemarksList>
            </Perstren>
            <Perstren>
           <TPERS>C</TPERS>
           <DEPLY>D</DEPLY>
           <STRUC>4</STRUC>
           <RemarksList>
               <REMARK>
                    <LABEL>EFG</LABEL>
                    <GENTEXT>Database</GENTEXT>
               </REMARK>
           <RemarksList>
            </Perstren>
            <Perstren>
           <TPERS>E</TPERS>
           <DEPLY>F</DEPLY>
           <STRUC>3</STRUC>
            </Perstren>       
       <PerstrenList>
    </RasDataSet>
    desired Results
    TPERS  DEPLY   LABEL  GENTEXT
    A       B       ABC   Hello World
    A       B       XYZ   Oracle XML
    C       D       EFG   Database
    select uic,
            extractvalue(Column_value,'/Perstren/TPERS') as TPERS,
            extractvalue(Column_value,'/Perstren/DEPLY') as DEPLY,
            extractvalue(Column_value,'/Perstren/SECUR') as SECUR,
            extractvalue(Column_value,'/Perstren/STRUC') as STRUC,
            extractvalue(Column_value,'/Perstren/TIME') as TIME,
            extractvalue(Column_value,'/Perstren/AUTH') as AUTH,
            extractvalue(Column_value,'/Perstren/ASGD') as ASGD,
    from test_ref doc,
        table(XMLSequence(extract(doc.XML_DOC,'/RasDataSet/PerstrenList/Perstren'))) per
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Sorry my Pre tag was in the wrong place Text reads:
    I have a table that contains a XMLTYPE Field. How do I query and join nested elements. For example I have a schema that has a PerstrenList element that holds one or more Perstren nodes. The Perstren node will contain a RemarksList node that can contain one or more Remarks nodes. My goal is to query all of the Remarks and join them with the information in it's parent node. Without the parent node information the remark is meaningless. Following is a example document and desire result set. I know how to query the Perstren or the Remarks I just can not figure out how to marry the two. The query should only return the remarks joined with the parent information.
    Sorry my Pre tag was in the wrong place

  • DB Adapter Query - Polling using nested select

    When polling a table to initiate a BPEL process, can I use a nested select in the expression.

    The visual expression builder does not currently support this so you need to specify the raw sql directly.
    If you use the DeletePollingStrategy there is a way you can specify the exact sql string for both the 'select' and the after read 'delete'. So if you write the where clause yourself it can contain nested selects.
    This is the readme from the new PureSQLSelect database adapter sample. Also you may want to look at the PureSQLPolling sample.
    This sample shows you how you can bypass the designer's visual where clause builder to specify arbitrarily complex sql strings for your selects.
    Like the other samples, this sample uses the basic Movies schema.
    The Steps:
    Create a basic select. Made sure it has the same name and number of input parameters as you will need for your sql string. In this case create a single input parameter and call it 'genre_param'.
    Create a trivial where clause in the wizard expression builder using genre_param. I.e. genre.like(genre_param)
    Ideally run the sample once just to make sure everything else works and to get a template SQL. The select ... FROM ... part will be the same.
    Open the toplink_mappings.xml file. Look for an element called <database-query>. There will likely only be one. A sample is presented here:
    <query-manager>
    <descriptor-query-manager>
    <existence-check>Check cache</existence-check>
    <descriptor-named-queries>
    <database-query>
    <query-name>selectByGenreSelect</query-name>
    <query-should-maintain-cache>true</query-should-maintain-cache>
    <cascade-policy>1</cascade-policy>
    <should-bind-all-parameters>undefined</should-bind-all-parameters>
    <should-cache-statement>undefined</should-cache-statement>
    <should-use-wrapper-policy>true</should-use-wrapper-policy>
    <query-timeout>0</query-timeout>
    <query-arguments>
    <string>genre_param</string>
    </query-arguments>
    <query-argument-types>
    <values>java.lang.String</values>
    </query-argument-types>
    <reference-class>PureSQLSelect.Movies</reference-class>
    <refresh-identity-map>false</refresh-identity-map>
    <cache-usage>2</cache-usage>
    <lock-mode>0</lock-mode>
    <distinct-state>0</distinct-state>
    <query-indirection>
    <in-memory-query-indirection>
    <policy>0</policy>
    </in-memory-query-indirection>
    </query-indirection>
    <main-expression>
    <expression>
    <operator-type>AND</operator-type>
    <expression-list>
    <expression>
    <operator-type>Like</operator-type>
    <first-argument>
    <argument>
    <query-key-name>genre</query-key-name>
    <outer-join>false</outer-join>
    <to-many>false</to-many>
    <argument-class>oracle.toplink.tools.workbench.expressions.QueryableArgumentRepresentation</argument-class>
    </argument>
    </first-argument>
    <second-argument>
    <argument>
    <parameter-name>genre_param</parameter-name>
    <argument-class>oracle.toplink.tools.workbench.expressions.ParameterArgumentRepresentation</argument-class>
    </argument>
    </second-argument>
    <expression-class>oracle.toplink.tools.workbench.expressions.BinaryExpressionRepresentation</expression-class>
    </expression>
    </expression-list>
    <expression-class>oracle.toplink.tools.workbench.expressions.CompoundExpressionRepresentation</expression-class>
    </expression>
    </main-expression>
    <type>oracle.toplink.queryframework.ReadAllQuery</type>
    </database-query>
    </descriptor-named-queries>
    </descriptor-query-manager>
    </query-manager>
    We want to switch this query from using a high-level expression to a pure sql string. You will remove the <main-expression> element and replace it with a <sql-string> element of your own devising.
    Your replacement should look something like this:
    <query-manager>
    <descriptor-query-manager>
    <existence-check>Check cache</existence-check>
    <descriptor-named-queries>
    <database-query>
    <query-name>selectByGenreSelect</query-name>
    <query-should-maintain-cache>true</query-should-maintain-cache>
    <cascade-policy>1</cascade-policy>
    <should-bind-all-parameters>undefined</should-bind-all-parameters>
    <should-cache-statement>undefined</should-cache-statement>
    <should-use-wrapper-policy>true</should-use-wrapper-policy>
    <query-timeout>0</query-timeout>
    <sql-string>SELECT DELETED, DIRECTOR, GENRE, LAST_UPDATED, RATED, RATING, RELEASE_DATE, RUN_TIME, SEQUENCENO, STARRING, STATUS, SYNOPSIS, TITLE, TOTAL_GROSS, VIEWER_RATING FROM MOVIES WHERE (upper(GENRE) LIKE upper(concat(concat('%', #genre_param), '%'))) ORDER BY TOTAL_GROSS desc</sql-string>
    <query-arguments>
    <string>genre_param</string>
    </query-arguments>
    <query-argument-types>
    <values>java.lang.String</values>
    </query-argument-types>
    <reference-class>PureSQLSelect.Movies</reference-class>
    <refresh-identity-map>false</refresh-identity-map>
    <cache-usage>2</cache-usage>
    <lock-mode>0</lock-mode>
    <distinct-state>0</distinct-state>
    <query-indirection>
    <in-memory-query-indirection>
    <policy>0</policy>
    </in-memory-query-indirection>
    </query-indirection>
    <type>oracle.toplink.queryframework.ReadAllQuery</type>
    </database-query>
    </descriptor-named-queries>
    </descriptor-query-manager>
    </query-manager>
    Gotchas:
    The tempation to start writing pure sql may be terrible to some, but it was intentionally left out of the wizard for good reasons. Please be wary of the following when specifying pure sql:
    -There is a way to set the pure sql string in the Mapping Workbench, but when you edit the partnerlink to refresh the toplink_mappings.xml you may get an exception due to the query being in a pure sql format. For this reason you need to manually edit the toplink_mappings.xml, and again every time your run the wizard and hit finish after that.
    -The #genre_param is a TopLink convention for writing a sql string which still takes parameters. At runtime if you enter 'Action' in the bpel console, you will see this sql:
    SELECT DELETED, DIRECTOR, GENRE, LAST_UPDATED, RATED, RATING, RELEASE_DATE, RUN_TIME, SEQUENCENO, STARRING, STATUS, SYNOPSIS, TITLE, TOTAL_GROSS, VIEWER_RATING FROM SYSTEM.MOVIES WHERE (GENRE LIKE ?)
    bind => [Action]
    The #genre_param gets replaced with the value of the input parameter genre_param.
    -When specifying pure sql you should be aware of the following:
    -maintenance issues
    -loss of database platform independence
    -The sql needs to conform with the way TopLink works. It is recommended that you do not change the SELECT ... FROM ... part of the query. TopLink's design is to read from one table at a time. If an Employee has an Address, then the Address is read with a hidden relationship query. There are two advanced TopLink features which optimize reading from multiple tables, called joinedAttribute and batchAttribute reading, but the combination of these features with raw sql was not explored here. So to avoid danger you can only really affect the top level query, and only rewrite the where clause.
    -The pure sql route does not interact with most TopLink features, especially batch reading (on by default), and can not be combined with the following:
    -LogicalDeletePollingStrategy
    -SequencingPollingStrategy (LastUpdated, LastReadId, File)
    These features extend the selection criteria at runtime.

  • XML Query Performance on Nested Tables

    I am running an Xpath query on an XMLTYPE column extracting rows from a nested table which is two levels down from the root element:
    e.g.
    select extractValue(x.xmldata,'/rootElement/VersionNumber') VerNumber
    , etc...
    , etc.
    , extractValue(value(m),'/Member/Name/Ttl') Member_title
    , to_char(extractValue(value(e),'/Event/EventDate'),'yyyy-mm-dd') Event_Date
    , extractValue(value(e),'/Event/Type') Event_type
    from xml_table x,
    table(XMLSequence(extract(x.xmldata,'/rootElement/Member'))) m
    ,table(XMLSequence(extract(value(m),'/Member/Event'))) e
    The query is taking around 7 minutes to process 2000 XML docs and the result returns 61,000 rows.
    Statspack reports indicate that the main resource used is the LOBSEGMENT which supports the SYS_XDBPD$ column (system generated) in the Member nested table - result was over 100 million Logical Reads and Consistent Gets.
    Is there any way to influence the Schema Registration/XML Table creation to result in the XDBPD$ column being stored as a Table or VARRAY - the underlying data type for XDBPD$ is:
    XDB.XDB$RAW_LIST_T VARRAY(1000) OF RAW(2000)
    OR
    Should I spend time tuning access to the LOBSEGMENT?
    Anyone tuned this area of XDB before??
    Thanks
    Dave

    Do you need DOM Fidelity at all. DOM Fidelity is typically only needed in a document orientated application or where items like processing instructions and comments are present and need to be maintaned.
    Here are some notes from some training ppt slides that may help you decide
    Dom Fidelity requires that XML DB track document level meta data
    It creates overhead when inserting and retrieving XML due to processing as well as adding additional storage requirements. Dom Fidelity can be turned on and off at the 'Type' Level Each SQL Type corresponding to a complexType where DOM is enabled includes a System Binary attribute called SYS_XDBPD$. The SYS_XDBPD$ attribute is referred to as the Positional Descriptor (PD)
    The PD is used to manage the instance level meta data. The format of the PD is not documented The PD is stored as a (in-line) LOB.
    The PD is used to track
    Comments and Processing Instructions
    Location and Prefixes in Namespace declarations
    Empty Vs Missing Nodes
    Presence of Default Values
    Use of Substitutable elements
    Ordering of elements in all and choice models
    XMLSchemaInstance attributes
    xsi:nil, xsi:Type
    Mixed content –
    Text() nodes that are interspaced with elements
    Disabling DOM Fidelity improves performance
    Reduces storage requirements
    Reduces elapsed time for insert and retrieval operations
    DOM Fidelity is disabled on a Type by Type basis
    Use annotation xdb:maintainDOM="false“ on complexType definition
    Specifying xdb:maintainDOM="false“
    Removes the PD attribute from the SQLType.
    Causes the information managed in the PD to be discarded when shredding the XML document
    In general you can disable DOM Fidelity when
    All information is represented as simple content
    Elements with text() node children and or attribute values
    XML does not make use Mixed Text
    No Comments or Processing Instructions
    Applications do not need to differentiate between empty and missing elements
    Applications do not differentiate between default Vs missing values
    Order of elements in repeating Sequence, All and Choice models is not meaningful
    Typically Data-Centric XML does not require DOM Fidelity while Document Centric XML does. With DOM Fidelity disabled retrieved documents will still be valid per the XML Schema
    Order is preserved when repetition is specified at element or complexType level
    Use annotation xdb:maintainOrder=“false” for slight performance improvement in this case that order is not required in these cases.
    Order is not preserved when repetition is specified at the ‘model’ level, eg on a Choice, Sequence or All containing multiple child elements.
    Take the following document
    <?xml version="1.0" encoding="UTF-8"?>
    <!--Sample XML file generated by XMLSPY v2004 rel. 4 U (http://www.xmlspy.com)-->
    <dft:root xmlns:dft="domFidelityTest"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="domFidelityTest domFidelityExample">
    <?SomePI SomeValue?>
         <xxx:choice xmlns:xxx="domFidelityTest">
         <!--SomeComment-->
              <xxx:A>String</xxx:A>
              <xxx:B>String</xxx:B>
              <?Another PI SomeOtherValue?>
              <xxx:C>String</xxx:C>
              <xxx:A>String</xxx:A>
              <!--Another Comment-->
              <xxx:B>String</xxx:B>
              <xxx:C xsi:nil="true"/>
    </xxx:choice>
    </dft:root>
    With DOM Fidelity disabled it would come back as
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <!--Sample XML file generated by XMLSPY v2004 rel. 4 U (http://www.xmlspy.com)-->
    <dft:root xmlns:dft="domFidelityTest“ testAttr="NotInOriginal">
    <dft:choice>
    <dft:A>String</dft:A>
    <dft:A>String</dft:A>
    <dft:B>String</dft:B>
    <dft:B>String</dft:B>
    <dft:C>String</dft:C>
    <dft:C/>
    </dft:choice>
    </dft:root>
    In general you can disable DOM Fidelity and see reduced storage requirements and increased throughout...
    Hope this helps...

  • Sql Query Error (9i) nested select with OleDB

    I have the following query which works fine when used with Sqlplus, but fails when called from within crytal reports (using an OleDB connection). I saw an open Oracle bug number 3025605 on some website, but haven't been able to look up any additional information on the error. The query fails with Ora-00972.
    SELECT "CLIENTS"."CLTFIRSTNAME",
    "CLIENTS"."CLTLASTNAME",
    "CLIENTS"."CLTMIDDLENAME",
    "SCHEDULE"."SCSESSIONDATE",
    (SELECT r.REMPFIRSTNAME||' '||r.REMPLASTNAME
    FROM REFAGENCYEMPLOYEES R WHERE "R"."REMPLOYEEID" = "SCHEDULE"."SCREFPERSON1ID") REFAGENT1,
    (SELECT r.REMPFIRSTNAME||' '||r.REMPLASTNAME
    FROM REFAGENCYEMPLOYEES R WHERE "R"."REMPLOYEEID" = "SCHEDULE"."SCREFPERSON2ID") REFAGENT2,
    "CODELOOKUP"."CODELISTNAME"
    FROM "POBJS"."CLIENTS" "CLIENTS",
    "POBJS"."SCHEDULE" "SCHEDULE",
    "POBJS"."CODELOOKUP" "CODELOOKUP"
    WHERE ("CLIENTS"."CLIENTID"="SCHEDULE"."SCCLIENTID")
    AND ("SCHEDULE"."SCEXAMTYPE"="CODELOOKUP"."CODEVALUE")
    AND "CODELOOKUP"."CODELISTNAME"='EXAM TYPES'
    Thanks for any help.

    Thanks for the information. I worked around the problem by calling a function that basically runs the nested select statement and returns a value.
    pobjs.getrname("SCHEDULE"."SCREFPERSON1ID") AS AGENT1,
    "CODELOOKUP"."CODELISTNAME"
    FROM "POBJS"."CLIENTS" "CLIENTS", ........

  • Subquery referencing parent query table????

    Well my problem ( which I hope has a solution :) ) is the following:
    I work on a little OS Advertising project.
    When an advertiser wants to start a campaign, he must see the list of the publisher websites where he can advertise.
    ::::SELECT [...] FROM website wsite[...]
    With their places count
    ::::[...]COUNT(place.id) AS placeCnt[...]INNER JOIN place ON place.website_id = wsite.id[...]
    -Yes but the websites that have at least 1 place
    ::::[...]GROUP BY wsite.id HAVING COUNT(place.id)>0[...]
    -And here comes my big dead end problem:
    I would like to remove the websites where the advertiser can't advertiser.
    I mean by there > if every ads of the advertiser are blacklisted for the site "google.com", he can't see "google.com" in the list because he won't be able to advertiser on in anyway.
    however, if the advertiser has 4 ads, and all of it are blacklisted excepted the 4th, he must see "google.com" because he can advertise with the ad #4.
    There is 2 types of blacklisting :
    targetted ( by defining a website id on the blacklist line )
    global ( by setting the website id = null , so for example if ad#1 is globally blacklisted by user #1, ad#1 couldn't be able to advertise on every websites of user#1 )
    I thought I found a solutoin put it doesn't seem to work:
    ::::WHERE 0< (
    SELECT COUNT(DISTINCT ad.id)
    FROM ad
    LEFT OUTER JOIN blacklist bl ON bl.ad_id =ad.id AND (bl.website_id=wsite.id OR bl.site_id IS NULL)
    WHERE ad.user_id= $userid
    AND bl.id IS NULL
    A concrete scenario example: ( SQL included at the end of the post )
    the user [email protected] ( userid = 2 ) has 3 ads.
    -"my forbidden ad" ( id = 1)
    -"my ad" ( id = 2 )
    -"my unappreciated ad" ( id = 3 )
    the user [email protected] ( userid = 1 ) has 3 websites
    -google.com ( id = 1 )
    -yahoo.com ( id = 2 )
    [email protected] has blacklisted the following ads:
    -"my unappreciated ad" ON yahoo.com, type targetted, ( website_id = 2, ad_id = 3 , publisher_id = 1)
    -"my forbidden ad" type global, ( website_id = null , ad_id = 1 publisher_id = 1)
    so the publisher websites we'll see with the resulting query should be ( as the the advertiser, user 2 ) :
    google.com
    yahoo.com
    lol.com
    WHY?
    -Because the advertiser can advertise thanks to ad 2 ( ad2 is allowed to be advertised on each website )
    -Even if "forbidden ad" is blacklisted globally, unapprediated ad remains for google.com
    NOW, if the publisher adds another blacklist restriction
    -"my ad" , type global ( website_id = null, ad_id = 2 , publisher_id = 1)
    the result would be ( as the the advertiser, user 2 )
    google.com
    WHY?
    -Because the advertiser do not have any ad to put on yahoo.com. Ad 1 and Ad 2 are blacklisted globally, ad 3 is blacklisted for yahoo.com
    WELL, I thought I found the solution by this query but mysql returns an error > unknown colum on the subquery
    THe only thing I want to is to LINK the parent query WITH the subquery ON bl.site_id=psite.id
    Enfin bon, tout ça pour un truc qui semblait être possible avec cette requête mais qui renvoie donc une erreur de unknown column:
    SELECT wsite.*,COUNT(place.id) AS placeCnt
    FROM website wsite
    INNER JOIN place ON place.website_id = wsite.id
    WHERE 0< (
    SELECT COUNT(DISTINCT ad.id)
    FROM ad
    LEFT OUTER JOIN blacklist bl ON bl.ad_id =ad.id AND (*bl.website_id=wsite.id* OR bl.website_id IS NULL)
    WHERE ad.advertiser_id= 2
    AND bl.id IS NULL
    GROUP BY wsite.id
    HAVING COUNT(place.id)>0
    WELL THANKS A LOT to have read this post, AND THANK YOU EVEN MORE IF SOMEONE FIND A TRICK!
    PS :
    ( the only solution I can see for the moment is a loop like )
    foreach($publisher_sites as $s){
    if(advertiserCanAdvertiser($s['id'])) $sites[]=$s
    but the performances are really bad
    I think the following would help :)
    MySQL Data Transfer
    Source Host: localhost
    Source Database: orads
    Target Host: localhost
    Target Database: orads
    Date: 10/20/2009 1:02:03 PM
    SET FOREIGN_KEY_CHECKS=0;
    -- Table structure for ad
    DROP TABLE IF EXISTS `ad`;
    CREATE TABLE `ad` (
    `id` int(11) NOT NULL auto_increment,
    `title` varchar(32) NOT NULL,
    `url` varchar(50) NOT NULL,
    `advertiser_id` int(11) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
    -- Table structure for blacklist
    DROP TABLE IF EXISTS `blacklist`;
    CREATE TABLE `blacklist` (
    `id` int(11) NOT NULL auto_increment,
    `ad_id` int(11) NOT NULL,
    `website_id` int(11) default NULL,
    `publisher_id` int(11) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
    -- Table structure for place
    DROP TABLE IF EXISTS `place`;
    CREATE TABLE `place` (
    `id` int(11) NOT NULL auto_increment,
    `name` varchar(32) NOT NULL,
    `website_id` int(11) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
    -- Table structure for user
    DROP TABLE IF EXISTS `user`;
    CREATE TABLE `user` (
    `id` int(11) NOT NULL auto_increment,
    `email` varchar(64) NOT NULL,
    `password` varchar(16) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
    -- Table structure for website
    DROP TABLE IF EXISTS `website`;
    CREATE TABLE `website` (
    `id` int(11) NOT NULL auto_increment,
    `title` varchar(32) NOT NULL,
    `url` varchar(32) NOT NULL,
    `publisher_id` int(11) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
    -- Records
    INSERT INTO `ad` VALUES ('1', 'my forbidden ad 1', 'http://www.no.com', '2');
    INSERT INTO `ad` VALUES ('2', 'my ad 2', 'http://www.lol.com', '2');
    INSERT INTO `ad` VALUES ('3', 'my unappreciated ad 3', 'http://www.abc.com', '2');
    INSERT INTO `blacklist` VALUES ('1', '1', null, '1');
    INSERT INTO `blacklist` VALUES ('2', '3', '2', '1');
    INSERT INTO `place` VALUES ('1', 'banner1', '1');
    INSERT INTO `place` VALUES ('2', 'yahoo banner', '2');
    INSERT INTO `user` VALUES ('1', '[email protected]', 'publisher');
    INSERT INTO `user` VALUES ('2', '[email protected]', 'advertiser');
    INSERT INTO `website` VALUES ('1', 'google', 'http://www.google.com', '1');
    INSERT INTO `website` VALUES ('2', 'yahoo', 'http://www.yahoo.com', '1');
    Edited by: user12086067 on Oct 20, 2009 4:51 AM

    Hi,
    Welcome to the forum!
    Interesting problem!
    Here's one way to do that in Oracle:
    SELECT DISTINCT     w.*
    FROM     website     w
    JOIN     place     p  ON     p.website_id     = w.id
    JOIN     ad     a  ON     w.publisher_id     NOT IN (
                                    SELECT     b.publisher_id
                                    FROM     blacklist     b
                                    WHERE     b.ad_id     = a.id
                                    AND     COALESCE ( b.website_id
                                                    , w.id
                                             ) = w.id
    WHERE     a.advertiser_id     = 2     -- parameter
    ;Thanks for posting the CREATE TABLE and INSERT statements. Since this is an Oracle forum, you should post statementts that will work in Oracle.
    I don't know anything about MySQL, so I don't know if you'll need to change query above or not.
    This doesn't quite produce the output you requested, since lol.com isn't in the website table. Do you need to get lol.com from the user table somehow?

  • Query to generate Nested XML feed

    Hello,
    I use Oracle 11g R2 SOE....
    I have two main tables
    COMMERCIALS_PROPERTIES (com_id number PK , com_size number, project_id number, com_type number)
    COM_PHOTOS (ID number PK , com_id number FK, content blob, mimetype varchar2)
    Please, note the following has nothing to do with my problem:
    CONTENT and MIMETYPE columns. Also, the lookup tables: PROJECTS , COM_TYPE
    I Exposed a report as RESTful web service in XML format:
    I am using this query to generate the XML 1 feed, but I need to tweak the query to generate XML 2 feed.
    Is it possible, how to do it ???
    Select
    "COM"."COM_ID" as "COM_ID",
    "COM"."COM_SIZE" as "SIZE",
    "PROJECTS"."PROJECT_NAME_EN" as "PROJECT",
    "COM_TYPES"."COM_TYPE" as "COM_TYPE",
    'http://fam-erp.com/apex/erp/fateh/'||IMG.ID as "ImgURL"
    FROM
    COM_PHOTOS IMG inner join COMMERCIALS_PROPERTIES "COM"
    on   IMG.COM_ID = COM.COM_ID
    inner join "PROJECTS" "PROJECTS"
    on "PROJECTS"."PROJECT_ID"="COM"."PROJECT_ID"
    inner join "COM_TYPE_LOOKUP" "COM_TYPES"
    on "COM_TYPES"."TYPE_ID"="COM"."COM_TYPE"
    WHERE
      COM.COM_ID < 80 order by 1h1. XML 1
    h2. Please look only at <COM_ID> and <ImgURL>
    <ROWSET>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
    </ROW>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
    </ROW>
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
    </ROW>
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
    </ROW>
    </ROWSET>---------------------------
    h1. XML 2
    h2. Please look only at <COM_ID> and <Images> and <ImgURL>
    <ROWSET>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <Images>
          <ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
          <ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
    </Images>
    </ROW>
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <Images>
            <ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
            <ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
    </Images>
    </ROW>
    </ROWSET>

    Hello,
    I see, I found another solution, but come across another problem that is the web service should get Data from more than one table. I have this procedure, and I would like to *"UNION" its* Select Statement with another Select Statement:
    declare
      v_xml clob;
      v_retval clob := '<?xml version="1.0" encoding="iso-8859-1"?>';
      v_blob blob;
    begin
    select
           xmlelement(
             "LISTINGS",
             xmlagg(
               xmlelement(
                 "LISTING",
                 xmlforest(
    'RS-'||R."RES_ID" as "Property_Ref_No",
    "UNIT_TYPE_LOOKUP"."UNIT_TYPE" as "Unit_Type",
    'Sale' as "Ad_Type",
    'Dubai' as "State",
    L.LOCATION_NAME_EN AS "Community",
    "PROJECTS"."PROJECT_NAME_EN" as "Property_Name",
    "RES_SALE"."ASKING_PRICE" as "Price",
    ' ' as "Frequency",
    ST."SUB_TYPE" as "Unit_Model",
    R."RES_SIZE" as "Unit_Builtup_Area",
    R.BEDS as "Bedrooms",
    R.bath as "No_of_Bathrooms",
    "RES_SALE"."AD_TITLE" as "Property_Title",
    RES_SALE.DESCRIPTION as "Web_Remarks",
    to_char("RES_SALE"."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') as "Last_Updated",
    R.VIDEO as "Web_Tour",
    select xmlagg(
                                 xmlforest(
                                'http://thevillaproject.com/apex/erp/IMAGES/'||IMG.ID AS "ImageUrl"
    FROM      
          IMAGES IMG     
    WHERE IMG.RES_ID = R.RES_ID ) Images )))).getclobval()
      into      v_xml
      FROM
          "RES_SALE" "RES_SALE"
    inner join
          RES R on (R."RES_ID"="RES_SALE"."RES_ID")
    inner join
              "UNIT_STATUS_LOOKUP" on (UNIT_STATUS_LOOKUP.status_id = "RES_SALE"."RES_STATUS")
    inner join
          "PROJECTS" "PROJECTS" on ("PROJECTS"."PROJECT_ID"=R."PROJECT_ID")
    inner join
          "UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP" on ("UNIT_TYPE_LOOKUP"."TYPE_ID"=R."RES_TYPE")
    inner join
          "RES_SUB_TYPE_LOOKUP" ST on (ST."SUB_TYPE_ID"=R."SUB_TYPE")
    INNER JOIN
          COMPLEX_LOOKUP CL ON (CL.COMPLEX_ID = "PROJECTS".COMPLEX_ID)
    INNER JOIN
          LOCATIONS L ON (L.LOCATION_ID = CL.LOCATION_ID)
    WHERE  "RES_SALE".RES_status IN (5,8) AND "RES_SALE".LIVE = 'Y' AND "RES_SALE".DESCRIPTION IS NOT NULL
      dbms_lob.append(v_retval,v_xml);
      OWA_UTIL.Mime_Header('text/xml'); 
      htp.p('Content-length: ' || to_char(dbms_lob.getlength(v_retval)));
      htp.p('Content-Disposition:  inline; filename="Just.xml"');
      owa_util.http_header_close;
      v_blob := wwv_flow_utilities.clob_to_blob(v_retval);
      wpg_docload.download_file(v_blob);
    end; h1. Select Statement that is needed to be "UNION-ED" with the Select Statement of the previous procedure:
    select
           xmlelement(
             "LISTINGS",
             xmlagg(
               xmlelement(
                 "LISTING",
                 xmlforest(
    'RR-'||R."RES_ID" as "Property_Ref_No",
    "UNIT_TYPE_LOOKUP"."UNIT_TYPE" as "Unit_Type",
    'Rent' as "Ad_Type",
    'Dubai' as "State",
    L.LOCATION_NAME_EN AS "Community",
    "PROJECTS"."PROJECT_NAME_EN" as "Property_Name",
    "RES_RENT"."ASKING_PRICE" as "Price",
    ' ' as "Frequency",
    ST."SUB_TYPE" as "Unit_Model",
    R."RES_SIZE" as "Unit_Builtup_Area",
    R.BEDS as "Bedrooms",
    R.bath as "No_of_Bathrooms",
    "RES_RENT"."AD_TITLE" as "Property_Title",
    "RES_RENT".DESCRIPTION as "Web_Remarks",
    to_char("RES_RENT"."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') as "Last_Updated",
    R.VIDEO as "Web_Tour",
    select xmlagg(
                                 xmlforest(
                                'http://thevillaproject.com/apex/erp/IMAGES/'||IMG.ID AS "ImageUrl"
    FROM      
          IMAGES IMG     
    WHERE IMG.RES_ID = R.RES_ID ) Images ))))
    FROM
          "RES_RENT" "RES_RENT"
    inner join
          RES R on (R."RES_ID"="RES_RENT"."RES_ID")
    inner join
              "UNIT_STATUS_LOOKUP" on (UNIT_STATUS_LOOKUP.status_id = "RES_RENT"."RES_STATUS")
    inner join
          "PROJECTS" "PROJECTS" on ("PROJECTS"."PROJECT_ID"=R."PROJECT_ID")
    inner join
          "UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP" on ("UNIT_TYPE_LOOKUP"."TYPE_ID"=R."RES_TYPE")
    inner join
          "RES_SUB_TYPE_LOOKUP" ST on (ST."SUB_TYPE_ID"=R."SUB_TYPE")
    INNER JOIN
          COMPLEX_LOOKUP CL ON (CL.COMPLEX_ID = "PROJECTS".COMPLEX_ID)
    INNER JOIN
          LOCATIONS L ON (L.LOCATION_ID = CL.LOCATION_ID)
    WHERE  "RES_RENT".RES_status IN (5,8) AND "RES_RENT".LIVE = 'Y' AND "RES_RENT".DESCRIPTION IS NOT NULL

  • How to call LabView function with nested structs and arrays from C#

    Hi,
    I've got the following functions defined in a LabView-dll:
    uint32_t __stdcall VOSC04_General(uint32_t Command, TD18Hdl *Messages);
    uint32_t __stdcall CheckDiameter(uint32_t Command, TD6 *Parameter);
    typedef struct {
     double SP_Diameter;
     double SP_Tolerantie;
     double PV_Diameter;
     } TD6;
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[1];
     } TD18;
    typedef TD18 **TD18Hdl;
    I've got some C#-code (generated by PInvoke-wizard) to call these functions:
    [DllImport("vosc04.dll")]
    public static extern uint32_t VOSC04_General (uint32_t Command, ref TD18Hdl Messages);
    [DllImport("vosc04.dll")]
    public static extern uint32_t CheckDiameter(uint32_t Command, ref TD6 Parameter);
    [StructLayout(LayoutKind.Sequential,Pack=4)]
    public struct TD18
       public int32_t dimSize;
       [ MarshalAs( UnmanagedType.ByValArray, SizeConst=1)]
       public int32_t [] Numeric;
    [StructLayout(LayoutKind.Sequential,Pack=4)]
    public struct TD6
       public Double SP_Diameter;
       public Double SP_Tolerantie;
       public Double PV_Diameter;
    The problem now is that when I try to read the Messages-output-parameter, I get wrong values (pointers?). I think that the problem lies in the fact that LabView generated a TD18 AND an TD18Hdl struct.
    How can I correct this problem?
    Can anyone give me some advise to correct this problem? I'm not an expert in C, only in C#.

    I think the problematic line is this:
    public struct TD18
       public int32_t dimSize;
       [ MarshalAs( UnmanagedType.ByValArray, SizeConst=1)]
       public int32_t [] Numeric;
    It looks like C# is forcing the array to be of size 1. The thing is, LabVIEW stores arrays as handles which are double pointers to a structure which contains a size element followed by the elements of the array. For your example, int32 arrays are stored in memory as:
    handle -> location -> |size|element 1|element 2| .... |element size-1|
    Because C does not do runtime array bounds checking, you can get away by declaring the structure as:
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[1];
     } TD18;
    The correct declaration would've been:
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[size];
     } TD18;
    But size is not a constant, so C/C++ won't let you do that. So, even though the array is declared to be of size 1, it can (and usually does) have more than 1 element. This does not cause a problem because LabVIEW allocates memory based on the actual size of the array.
    If I were you, I'd try to change the prototype of the LabVIEW DLL function to accept a pointer to array data, rather than an array handle, pre-allocate memory for the array in C# and pass a pointer to the allocated memory into LabVIEW so that LabVIEW can "fill it up".
    Let me know if you need more information.
    Pramod

  • Query related with nested transaction

    Friends,
    Today i've been encountered with problem in running a nested transaction and i guess the sample script given below illustrates well abt the same ...
    I've a proc "sp_proc1" as follows
    CREATE OR REPLACE PROCEDURE sp_proc1
    AS
         val INT;     
         BEGIN      
              val := 1;     
              BEGIN SAVEPOINT proc1;                         
              INSERT INTO tab1 VALUES ( 1 , 2 );
              sp_proc2(val);
              ROLLBACK TO SAVEPOINT proc1;               
         END;
    and the called proc is like this
    CREATE OR REPLACE PROCEDURE sp_proc2
         val1 IN      INT DEFAULT NULL
    AS
         BEGIN SAVEPOINT proc2;          
         UPDATE tab1 SET     col1 = 5;
         IF val1 = 0 THEN
         BEGIN
              ROLLBACK TO SAVEPOINT proc2;
         END;
         ELSE
         BEGIN
    COMMIT;
         END;
         END IF;
         END;
    and when i exec the proc1
    ORA-01086: savepoint 'PROC1' never established
    Any suggestions on this .....

    Autonomous transactions are independent units of work and should be completely
    committed of rolled back before returning from an autonomous program unit.
    So anything you do in the calling procedure doesn't affect the autonomous one:
    SQL> create table t (id number);
    Table created.
    SQL> create or replace procedure auto_01
      2  is
      3   pragma autonomous_transaction;
      4  begin
      5   insert into t values(1);
      6   savepoint a;
      7   insert into t values(2);
      8   rollback to savepoint a;
      9   commit;
    10  end;
    11  /
    Procedure created.
    SQL> begin
      2   insert into t values(3);
      3   savepoint a;
      4   auto_01;
      5   insert into t values(4);
      6   rollback to savepoint a;
      7   commit;
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> select * from t;
            ID
             3
             1Rgds.

  • SQL query to generate Nested XML

    Hello,
    I use Oracle 11g R2 SOE....
    I have two main tables
    COMMERCIALS_PROPERTIES (com_id number PK , com_size number, project_id number, com_type number)
    COM_PHOTOS (ID number PK , com_id number FK, content blob, mimetype varchar2)
    Please, note the following has nothing to do with my problem:
    CONTENT and MIMETYPE columns. Also, the lookup tables: PROJECTS , COM_TYPE
    In APEX ( Application Express ) we can expose a report as RESTful web service in XML format:
    I am using this query to generate the XML 1 feed, but I need to tweak the query to generate XML 2 feed.
    Is it possible, how to do it ???
    Select
    "COM"."COM_ID" as "COM_ID",
    "COM"."COM_SIZE" as "SIZE",
    "PROJECTS"."PROJECT_NAME_EN" as "PROJECT",
    "COM_TYPES"."COM_TYPE" as "COM_TYPE",
    'http://fam-erp.com/apex/erp/fateh/'||IMG.ID as "ImgURL"
    FROM
    COM_PHOTOS IMG inner join COMMERCIALS_PROPERTIES "COM"
    on   IMG.COM_ID = COM.COM_ID
    inner join "PROJECTS" "PROJECTS"
    on "PROJECTS"."PROJECT_ID"="COM"."PROJECT_ID"
    inner join "COM_TYPE_LOOKUP" "COM_TYPES"
    on "COM_TYPES"."TYPE_ID"="COM"."COM_TYPE"
    WHERE
      COM.COM_ID < 80 order by 1h1. XML 1
    h2. Please look only at <COM_ID> and <ImgURL>
    <ROWSET>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
    </ROW>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
    </ROW>
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
    </ROW>
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
    </ROW>
    </ROWSET>---------------------------
    h1. XML 2
    h2. Please look only at <COM_ID> and <Images> and <ImgURL>
    <ROWSET>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <Images>
          <ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
          <ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
    </Images>
    </ROW>
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <Images>
            <ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
            <ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
    </Images>
    </ROW>
    </ROWSET>

    Hi, Fateh
    One possible way is to use XML functions to create your XML.
    Using XML functions you can do the IMAGES as an XMLAGG subquery rather than join to the image table.
    Here's an example using SCOTT schema:
    SQL> select xmlelement(
      2            "ROWSET"
      3          , xmlagg(
      4               xmlelement(
      5                  "ROW"
      6                , xmlforest(
      7                     d.deptno as "ID"
      8                   , d.dname as "NAME"
      9                   , (
    10                        select xmlagg(
    11                                  xmlelement(
    12                                     "ImgUrl"
    13                                   , 'http://the.server.com/'||e.empno
    14                                  )
    15                                  order by e.empno
    16                               )
    17                          from scott.emp e
    18                         where e.deptno = d.deptno
    19                     ) as "Images"
    20                  )
    21               )
    22               order by d.deptno
    23            )
    24         ) the_xml
    25    from scott.dept d
    26    /* joins to the other tables EXCEPT image table */
    27  /
    THE_XML
    <ROWSET><ROW><ID>10</ID><NAME>ACCOUNTING</NAME><Images><ImgUrl>http://the.serverThat output is an XMLTYPE column (think of it as a CLOB with added functionality ;-) )
    My SQL*PLUS cuts the output, but believe me, it is all there.
    Just to show it, here's the same example wrapped in an XMLSERIALIZE function to pretty-print the XML:
    SQL> select xmlserialize(
      2            content
      3            xmlelement(
      4               "ROWSET"
      5             , xmlagg(
      6                  xmlelement(
      7                     "ROW"
      8                   , xmlforest(
      9                        d.deptno as "ID"
    10                      , d.dname as "NAME"
    11                      , (
    12                           select xmlagg(
    13                                     xmlelement(
    14                                        "ImgUrl"
    15                                      , 'http://the.server.com/'||e.empno
    16                                     )
    17                                     order by e.empno
    18                                  )
    19                             from scott.emp e
    20                            where e.deptno = d.deptno
    21                        ) as "Images"
    22                     )
    23                  )
    24                  order by d.deptno
    25               )
    26            )
    27            as varchar2(4000)
    28            indent size=2
    29         ) the_xml
    30    from scott.dept d
    31    /* joins to the other tables EXCEPT image table */
    32  /
    THE_XML
    <ROWSET>
      <ROW>
        <ID>10</ID>
        <NAME>ACCOUNTING</NAME>
        <Images>
          <ImgUrl>http://the.server.com/7782</ImgUrl>
          <ImgUrl>http://the.server.com/7839</ImgUrl>
          <ImgUrl>http://the.server.com/7934</ImgUrl>
        </Images>
      </ROW>
      <ROW>
        <ID>20</ID>
        <NAME>RESEARCH</NAME>
        <Images>
          <ImgUrl>http://the.server.com/7369</ImgUrl>
          <ImgUrl>http://the.server.com/7566</ImgUrl>
          <ImgUrl>http://the.server.com/7788</ImgUrl>
          <ImgUrl>http://the.server.com/7876</ImgUrl>
          <ImgUrl>http://the.server.com/7902</ImgUrl>
        </Images>
      </ROW>
      <ROW>
        <ID>30</ID>
        <NAME>SALES</NAME>
        <Images>
          <ImgUrl>http://the.server.com/7499</ImgUrl>
          <ImgUrl>http://the.server.com/7521</ImgUrl>
          <ImgUrl>http://the.server.com/7654</ImgUrl>
          <ImgUrl>http://the.server.com/7698</ImgUrl>
          <ImgUrl>http://the.server.com/7844</ImgUrl>
          <ImgUrl>http://the.server.com/7900</ImgUrl>
        </Images>
      </ROW>
      <ROW>
        <ID>40</ID>
        <NAME>OPERATIONS</NAME>
      </ROW>
    </ROWSET>For a webservice you do not need to pretty-print the XML that is returned by the webservice.
    I do not know APEX, so I do not know if APEX supports exposing an allready built piece of XML rather than exposing a query result.
    But my guess is that it should do it very nicely if you query an XMLTYPE datatype (that is - use the first of my examples rather than the pretty-printed one.)
    If you can't get APEX to do it this way, then I suggest you try asking in the APEX forum rather than the SQL forum ;-)

  • DLookUp Referencing a Query To Get a Total Amount Owed

    I have a form named: Branch 142 Membership that has a text box named: TextBoxTotalAmountDueToDate. The control source is: =DLookUp("[Total Amount Due]","[QryTotalAmtDueBy]","[MemberID]=" & [Forms]![Branch 142 Membership]![MemberID])
    I'm getting the sum total for all of the records in my database that is the sum for just one member. There's one payment record in the Payments table. Of course when I open the query I get the total for the one payment record.
    I want to get the Sum([PPUnionDuesAmountNoDeduct]-[PaymentAmount]) for each record in the object: TextBoxTotalAmountDueToDate.  If the amount is zero I want the text box to display zero. When I entered =Sum([PPUnionDuesAmountNoDeduct]-[PaymentAmount])
    I got an error in text box.
    Thanks for the help.

    I will try again. For example, I have a table (Payments) that has 5 records. The 5 Payments table records has $24.45 entered all for the same person, Billy Bob that totals $122.25. I have a table (Members) that Billy Bob is one of 10 records. The query:QryTotalAmtDueBy
    returns 1 result (record) and it is only for Billy Bob for $122.25 because he is the only one entered in the Payments table. Total Amount Due: Sum([PaymentAmount]-[PPUnionDuesAmountNoDeduct])
    When I enter into the control source for text box:
    TextBoxTotalAmountDueToDateTab5 the expression: =DLookUp("[Total Amount Due]","[QryTotalAmtDueBy]","[MemberID]=" & [Forms]![Branch 142 Membership]![MemberID]) on the form: Branch 142 Membership. I get the
    $122.25 total amount due for Billy Bob and for the remaining 9 records in the
    TextBoxTotalAmountDueToDateTab5.
    You suggested I try =DLookUp("Total Amount Due","QryTotalAmtDueBy"). I get #Error when I entered it in the text box:
    TextBoxTotalAmountDueToDateTab5. I modified what you gave me and entered: =DLookUp("[Total Amount Due]","[QryIndivTotalAmtDueBy]"). I still get the
    $122.25 total amount due for Billy Bob and for the remaining 9 records in the Members table.
    I don’t care if I use a control source that references the
    Total Amount Due from the query QryTotalAmtDueBy or if I use a control source expression that is the sum
    of the PaymentAmounts minus the sum of the PPUnionDuesAmountNoDeduct for each record in the Members table. I've tried:
    =IIf(IsNull([MemberID]),0,DSum("[PPUnionDuesAmountNoDeduct]-[PaymentAmount]","Payments","[MemberID]=" & [MemberID])). I get nothing for
    any record in the Members table.

  • Nested query value used as comparison in second nested query

    Hi,
    What would be the best way of writing the following:
    I have a simple SELECT statement which includes two nested queries used to get the start and end dates from two different tables (if the first date from the first table and the second from a different table), there is not real direct relationship between
    those two seperate tables.  However the result of the first date nested select would determine part of the WHERE statement in the second nested statement.
    I need a way of using the value returned as a part of first nested select in the where statement of the second.
    I know exactly how to do this using something like ASP.NET C# but that involved running them as seperate queries and storing the values in variables before running a new statement for example and I would prefer to run a single query with the nested selects
    and get the results as required.
    Can anyone point me in the right direction of the best way of running this kind of thing?
    Cheers for any replies!

    Hello,
    Please provide DML for the tables, some sample data and the expected result. Just with your description we could only guess.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Query Nested table (collection)

    I try to query on a nested table (collection).
    How ever, I get a 600 error.
    Is there any way to reuse the result of query in the store procedure?
    SQL&gt; DECLARE
    2 TYPE T_PER_ID IS TABLE OF PERIOD.PER_ID%TYPE;
    3 V_EXP_PER_ID T_PER_ID;
    4 V_EXP_PER_ID2 T_PER_ID;
    5 BEGIN
    6 SELECT PER_ID BULK COLLECT INTO V_EXP_PER_ID FROM PERIOD;
    7 SELECT * BULK COLLECT INTO V_EXP_PER_ID2 FROM TABLE(V_EXP_PER_ID);
    8 END;
    9 /
    DECLARE
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [15419], [severe error during PL/SQL
    execution], [], [], [], [], [], []
    ORA-06544: PL/SQL: internal error, arguments: [pfrrun.c:pfrbnd1()], [], [], [],
    ORA-06553: PLS-801: internal error [0]

    Oracle Version 8.1.6

Maybe you are looking for