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.

Similar Messages

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

  • Using nested select in oracle functions

    hi, im new to oracle functions, and im trying to write a function using a nested select statment, but i get the error
    Error: PLS-00428: an INTO clause is expected in this SELECT statement
    can anyone help point out what i am doing wrong, The sql select statment works on a worksheet, so i guess its the way i am using the function
    create or replace function Media_Object_Name(Detail_id Number) return varchar2 as
    Result varchar2(300);
    begin
    select promo_name from promo where promo_id =
    (select promo_id from promo_plan where promo_plan_id =
    (select promo_plan_id from event_promotion where detail_id = Detail_id)) into ;
    return(Result);
    end Media_Object_Name;
    thanks
    james

    The into clause should go here:
    SELECT promo_name
      INTO Result
      FROM promo
    WHERE promo_id = (SELECT promo_id
                         FROM promo_plan
                        WHERE promo_plan_id = (SELECT promo_plan_id
                                                 FROM event_promotion
                                                WHERE detail_id = detail_id));I don't know about your data modell, but are you sure you need nested selects?
    C.

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

  • Using nested Joins in abap prog

    Hi All,
    please help me  out in using nested joins in abap progrmaming. I dont know about joins in abap.specially in case of outer join.
      I have 5 internal tables.. mara ,marc, mvke,mbew,ampl. am using  a  select query with certain fields from all these tables.
      I need to disply  all the materials  of  a mara for  a particular date irrespective of  the values in fields of  other tables.
            Even if that materail is not present in other table for certain condtion ,that material  should get displyed with all other fields  showing null value..

    Hi RK,
    the  code am using is of the same way...but my problem was with the joins..in the  select query  am using nested join combining inner  and outer join.. but i could  not able to display all the materials  of mara of a particular date..
    The code looks like this..
    SELECT <some fields.......>
    INTO  TABLE i_materials
          FROM  ( marc AS b
          INNER JOIN mara AS a ON amatnr = bmatnr
          INNER JOIN mvke AS c ON cmatnr = amatnr
          INNER JOIN ampl AS g ON gbmatn = amatnr
          LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
                                   AND dbwkey = bwerks )
      WHERE a~matnr  IN s_matnr AND .................
    Else
    SELECT <some fields.......>
    INTO  TABLE i_materials
          FROM  ( marc AS b
          INNER JOIN mara AS a ON amatnr = bmatnr
          INNER JOIN mvke AS c ON cmatnr = amatnr
          INNER JOIN ampl AS g ON gbmatn = amatnr
          LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
                                   AND dbwkey = bwerks )
       FOR ALL ENTRIES IN i_mara
         WHERE a~matnr = i_mara-matnr AND ............

  • Nested select statements.

    Hi, I am writing a piece of code in which i use nested select statements for 4 tables to retrieve one column's data (ie: POSNR). But when i execute it, it takes way too long to get the data. I'm quite new to ABAP so very in need of your help. Thanks
    REPORT  z_impos_test.
    TABLES: coss,       "CO Object: Cost Totals for Internal Postings
            afvc,       "Operation within an order
            prps,       "WBS (Work Breakdown Structure) Element Master Data
            imzo.       "Table: CO Object - Capital Investment Prog.Pos.
    TYPES: BEGIN OF st_impos,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF st_impos.
    data: year TYPE coss-gjahr value '2007'.
    DATA: t_output  TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
          st_output TYPE st_impos,
          t_output2 TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
          st_output2 TYPE st_impos.
    SELECT objnr gjahr kstar FROM coss
    INTO CORRESPONDING FIELDS OF st_output
    WHERE ( objnr LIKE 'NV%' OR
          objnr LIKE 'PR%' ) AND
           gjahr = year.
       SELECT SINGLE projn from afvc into CORRESPONDING FIELDS OF st_output
           WHERE objnr = st_output-objnr.
    APPEND st_output to t_output.
    ENDSELECT.
    SORT t_output BY objnr.
    DELETE ADJACENT DUPLICATES FROM t_output.
    LOOP AT t_output into st_output.
    SELECT objnr pspnr
           INTO CORRESPONDING FIELDS OF st_output2
           FROM prps
           WHERE objnr = st_output-objnr
           AND   pspnr = st_output-pspnr.
      SELECT SINGLE posnr from imzo into CORRESPONDING FIELDS OF st_output2
           WHERE objnr = st_output2-objnr.
    APPEND st_output2 to t_output2.
    ENDSELECT.
    ENDLOOP.
    LOOP AT t_output2 to st_output2.
    WRITE:   st_output2-posnr.
    ENDLOOP.
    Edited by: Jacie Johns on Apr 23, 2009 11:26 PM

    HI John,
    Try to avoid INTO CORRESPONDING FIELDS in SELECT statement.
    As you are not using PSPNR and POSNR fields in the first SELECT statement. If you remove these fields, in structure, INTO CORRESPONDING FIELDS can be avoided. Create a separate structure with the fields that are required for T_OUTPUT table (i.e. create another structure with only first 4 fields, as T_OUTPUT1.
    And as mentioned in your code,
      WHERE objnr = st_output-objnr
           AND   pspnr = st_output-pspnr
    in select statement, ST_OUTPUT-PSPNR value is not fetched in the previous select statements.
    Create Another structure with fields OBJNR, PSPNR, POSNR for table T_OUTPUT2 to store the data from tables, PRPS and IMZO.
    Use JOINS and FOR ALL ENTRIES to fetch the desired data.
    The sample code is as follows:
    ===
    TYPES: BEGIN OF ty_output1,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
    END OF ty_output1,
    BEGIN OF ty_output2,
      objnr       TYPE coss-objnr,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF ty_output2,
    BEGIN OF ty_output3,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF ty_output3.
    data: year TYPE coss-gjahr value '2007'.
    DATA:
           wa_output1 TYPE ty_output1,   
           wa_output2 TYPE ty_output2,
           wa_output3 TYPE ty_output3,
           t_output1  TYPE STANDARD TABLE OF ty_output1 ,
           t_output2 TYPE STANDARD TABLE OF ty_output2 ,
           t_output3 TYPE STANDARD TABLE OF ty_output3..
    SELECT cobjnr cgjahr ckstar aprojn FROM coss as c
         INNER JOIN afvc as A on aobjnr = cobjnr
      INTO table t_output1
      WHERE ( c~objnr like 'NV%'   or
              c~objnr like 'PR%' ) and
            c~gjahr = year.
    SELECT pobjnr ppspnr i~posnr FROM prps as P
         INNER JOIN imzo AS I on pobjnr = iobjnr
         INTO TABLE t_output2
         for all entries in table T_OUTPUT1
         WHERE      p~objnr = t_output1-objnr.
    SORT : t_output1 BY objnr,
                t_output2 BY objnr.
    DELETE ADJACENT DUPLICATES FROM : t_output1 COMPARING objnr,
                                                                     t_output2 COMPARING objnr.
    LOOP AT t_output1 INTO wa_output1
    READ TABLE t_output2 INTO wa_output2 WITH KEY objnr - wa_output1-objnr BINARY SEARCH.
    if sy-subrc = 0.
      MOVE <wa_output1 fiels> and <wa_output2 fields> to WA_OUTPUT3.
      append wa_output3 to T_OUTPUT3.
    endif.
    ENDLOOP.
    Hope this will solve your problem.
    Regards,
    Sai Prasad

  • Use of current time for polling Database Adapter query

    I am writing a simple BPEL process with a Polling Database Adapter and a Recieve. The idea is that we are polling an XE database for any entries in a TRIP table which have an expiration date/time field that has passed.
    The Adapter was build using JDeveloper 10.1.3.2 (with Oracle Application Server patched to 10.1.3.3.0) as a "Poll for New Changed Records in a Table" Operation type with a STATUS field (0 for live, 1 for expired) as the Logical Delete Field.
    I was unable to find a way to generate a SELECT query expression with the wizard that would allow me to use current/system time as an attribute, so I finished the wizard and edited the Toplink Descriptor to use a custom SQL expression for the query. This resulted in the following code in the toplink_mappings.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <toplink:object-persistence version="Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)"
    xmlns:opm="http://xmlns.oracle.com/ias/xsds/opm" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:toplink="http://xmlns.oracle.com/ias/xsds/toplink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <opm:name>ExpiredTripPoller</opm:name>
    <opm:class-mapping-descriptors>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>ExpiredTripPoller.Trip</opm:class>
    <opm:alias>Trip</opm:alias>
    <opm:primary-key>
    <opm:field table="TRIP" name="ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy">
    <opm:queries>
    <opm:query name="ExpiredTripPoller" xsi:type="toplink:read-all-query">
    <toplink:timeout>0</toplink:timeout>
    <toplink:call xsi:type="toplink:sql-call">
    <toplink:sql>SELECT ID, LPN, START_TIME, EXPIRY_TIME, STATUS FROM TRIP WHERE ((STATUS = '0') AND (EXPIRY_TIME < SYSDATE)) ORDER BY EXPIRY_TIME ASC</toplink:sql>
    </toplink:call>
    <toplink:reference-class>ExpiredTripPoller.Trip</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    <opm:query name="findAllTrip" xsi:type="toplink:read-all-query">
    <toplink:timeout>0</toplink:timeout>
    <toplink:reference-class>ExpiredTripPoller.Trip</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    </opm:queries>
    <toplink:does-exist-query xsi:type="toplink:does-exist-query">
    <toplink:existence-check>check-database</toplink:existence-check>
    </toplink:does-exist-query>
    <toplink:read-all-query xsi:type="toplink:read-all-query">
    <toplink:reference-class>ExpiredTripPoller.Trip</toplink:reference-class>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </toplink:read-all-query>
    </opm:querying>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>id</opm:attribute-name>
    <opm:field table="TRIP" name="ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.math.BigDecimal</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>lpn</opm:attribute-name>
    <opm:field table="TRIP" name="LPN" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>startTime</opm:attribute-name>
    <opm:field table="TRIP" name="START_TIME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>expiryTime</opm:attribute-name>
    <opm:field table="TRIP" name="EXPIRY_TIME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>status</opm:attribute-name>
    <opm:field table="TRIP" name="STATUS" xsi:type="opm:column"/>
    <opm:attribute-classification>java.math.BigDecimal</opm:attribute-classification>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    <toplink:always-refresh>true</toplink:always-refresh>
    </toplink:caching>
    <toplink:remote-caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    </toplink:remote-caching>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="TRIP"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    </opm:class-mapping-descriptors>
    </toplink:object-persistence>
    To test I used the above custom SQL at the command line and it filtered the records by EXPIRY_TIME as expected.
    When deployed, the polling process updates the STATUS file dof table entries, but all entries with status 0 regardless of EXPIRY_DATE. My modification appears to be being ignored. I was unsure as to whether the QUERY was being determined in some other way so I modified the descriptor (with the toplink expression editor) to compare against a literal time value, producing the following modified toplink_mappings.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <toplink:object-persistence version="Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)"
    xmlns:opm="http://xmlns.oracle.com/ias/xsds/opm" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:toplink="http://xmlns.oracle.com/ias/xsds/toplink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <opm:name>ExpiredTripPoller</opm:name>
    <opm:class-mapping-descriptors>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>ExpiredTripPoller.Trip</opm:class>
    <opm:alias>Trip</opm:alias>
    <opm:primary-key>
    <opm:field table="TRIP" name="ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy">
    <opm:queries>
    <opm:query name="ExpiredTripPoller" xsi:type="toplink:read-all-query">
    <opm:criteria operator="lessThan" xsi:type="toplink:relation-expression">
    <toplink:left name="expiryTime" xsi:type="toplink:query-key-expression">
    <toplink:base xsi:type="toplink:base-expression"/>
    </toplink:left>
    <toplink:right xsi:type="toplink:constant-expression">
    <toplink:value xsi:type="xsd:date">2007-07-30</toplink:value>
    </toplink:right>
    </opm:criteria>
    <toplink:timeout>0</toplink:timeout>
    <toplink:reference-class>ExpiredTripPoller.Trip</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    <opm:query name="findAllTrip" xsi:type="toplink:read-all-query">
    <toplink:timeout>0</toplink:timeout>
    <toplink:reference-class>ExpiredTripPoller.Trip</toplink:reference-class>
    <toplink:cache-usage>primary-key</toplink:cache-usage>
    <toplink:lock-mode>none</toplink:lock-mode>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </opm:query>
    </opm:queries>
    <toplink:does-exist-query xsi:type="toplink:does-exist-query">
    <toplink:existence-check>check-database</toplink:existence-check>
    </toplink:does-exist-query>
    <toplink:read-all-query xsi:type="toplink:read-all-query">
    <toplink:reference-class>ExpiredTripPoller.Trip</toplink:reference-class>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>java.util.Vector</toplink:collection-type>
    </toplink:container>
    </toplink:read-all-query>
    </opm:querying>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>id</opm:attribute-name>
    <opm:field table="TRIP" name="ID" xsi:type="opm:column"/>
    <opm:attribute-classification>java.math.BigDecimal</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>lpn</opm:attribute-name>
    <opm:field table="TRIP" name="LPN" xsi:type="opm:column"/>
    <opm:attribute-classification>java.lang.String</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>startTime</opm:attribute-name>
    <opm:field table="TRIP" name="START_TIME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>expiryTime</opm:attribute-name>
    <opm:field table="TRIP" name="EXPIRY_TIME" xsi:type="opm:column"/>
    <opm:attribute-classification>java.sql.Timestamp</opm:attribute-classification>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>status</opm:attribute-name>
    <opm:field table="TRIP" name="STATUS" xsi:type="opm:column"/>
    <opm:attribute-classification>java.math.BigDecimal</opm:attribute-classification>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    <toplink:always-refresh>true</toplink:always-refresh>
    </toplink:caching>
    <toplink:remote-caching>
    <toplink:cache-type>weak-reference</toplink:cache-type>
    </toplink:remote-caching>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="TRIP"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    </opm:class-mapping-descriptors>
    </toplink:object-persistence>
    On deployment, this version of the BPEL process behaved as expected - only modifying the records with EXPIRY_TIME less thatn the literal time specified. (Also, I can't really pass in the time as a parameter as this is a polling model).
    Can anyone shed any light on what is happening or suggest how I might go about polling in the desired way?
    Cheers

    Please take a look at this article which states SYSDATE is not supported in a
    where clause.
    http://www.oracle.com/technology/pub/articles/bpel_cookbook/qualcomm-bpel.html
    Excerpt from the article:
    Here are three important things you should do in implementing the above design:
    Have the status of the record being processed stored in the database. The status includes the process state, next process attempt time, and processing attempt count.
    Create an updatable view that exposes only records that are ready to be processed. A view is needed because the database adapter cannot handle a where clause that compares against SYSDATE.
    Design logic that determines if a process instance that has faulted should be retried and when the retry should occur. This information will be updated in the database by use of a stored procedure. This can also be done with an update partner link and additional logic in BPEL.
    mahalo,
    a iii

  • Can I use custom query in DB Adapter with Polling

    Hi All,
    I am getting problem while using db adapter with polling. Can I use custom query in db adapter with polling.
    I am using 2 tables; table 1 and table2
    Structure of table1 is as:
    File_name
    Batch_id
    Creation_date
    Status
    Structure of table2 is as:
    Batch_id
    Employee_ID
    Last_Name
    First_Name
    Middle_Name
    Group_ID
    Site_ID
    Dept_Num
    Report_id
    I have to use below query while polling to table1
    Select count(*) as NOSEXP, Report_id
    from table1, table2
    where table2.batch_id =
    table2.batch_id
    and table1.Status= 0
    group by Report_id;
    I mean, when I use DB adapter to poll table1, I have to use above query.
    Can you Please suggest on this.
    Thanks in advance.

    I will check for existance not based on Primary key but based on three other fields in the table. I think , by default DB adapter configured for MERGE checks for existance based on PK. Can we change the Primary Key in the mapping file after the DB adapter is configured. In that case , will it check for existance based on the fields , I mention.
    Edited by: user12020809 on Sep 16, 2012 6:08 PM

  • How to use multi select in a query report

    I defined a lov. This lov retuns name and a id. I want to use the result of this multi select in my query.
    I always get invalid number when I choose two items of the select. When I debug I see that the return value of the multi select is 1:2. How can I change the seperator : in , I tried the following but this does't work.
    if :P26_PRODUCTTYPE IS NOT NULL then
    l_sql := l_sql ||' and producttype in
    (REPLACE(:p26_producttype,'':'','','' ))';
    end if;

    as you're finding, multiple values selected from html db multi-select list items (and checkboxes) are stored as a single, colon-delimited string. i explained an easy way to handle this via pl/sql in...
    Multiple select list
    ...that post shows you how to throw the selected values into a pl/sql table and step through them as needed. it also showed how to use an instr to parse through the string if you want to go that route. you could use that same instr logic right in your sql query. so let's say your lov for your multi-select item (P1_MY_MULTISELECT, we'll call it) was defined as...
    select ename, empno from emp order by 1
    ...and your user selected KING, FORD, and JONES. :P1_MY_MULTISELECT would store those values as...
    7839:7902:7566
    ...you could then write a query to return the selected enames with something like...
    select ename, job
    from emp
    where insrt (':'||:P1_MY_MULTISELECT||':',':'||empno||':') != 0
    ...hope this helps,
    raj

  • Needs  help to retrive the last row in a  select query without using rownum

    Hi ,
    i need to retrive the last row from the select sub query without using rownum.
    is there any other way to retrive the last row other than the below query.
    is that the ROWNUM=1 will always retrive the 1 row of the select query ?
    select from*
    *(select ename from employee where dept_id=5 order by desc) where rownum=1;*
    Please advise.
    thanks for your help advance,
    regards,
    Senthur

    957595 wrote:
    Actually my problem is ithat while selecting the parents hiearchy of the child data using
    CONNECT BY PRIOIR query
    I need the immediate parent of my child data.
    For example my connect BY query returns
    AAA --- ROOT
    BBB --PARENT -2
    CCC --PARENT-1
    DDD IS my input child to the connect by query
    Immediate parent of my child data "DDD" ---> CCC(parent -1)
    i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
    I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
    So confusing with using this rownum in my query.
    Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
    you can select the PRIOR values to get the parent details if you want...
    SQL> ed
    Wrote file afiedt.buf
      1  select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
      2  from emp
      3  connect by mgr = prior empno
      4* start with mgr is null
    SQL> /
         EMPNO ENAME                                 MGR
          7839 KING
          7566   JONES                              7839
          7788     SCOTT                            7566
          7876       ADAMS                          7788
          7902     FORD                             7566
          7369       SMITH                          7902
          7698   BLAKE                              7839
          7499     ALLEN                            7698
          7521     WARD                             7698
          7654     MARTIN                           7698
          7844     TURNER                           7698
          7900     JAMES                            7698
          7782   CLARK                              7839
          7934     MILLER                           7782
    14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data)

  • Improving a simple select query, which uses all rows.

    Hi All,
    Please excuse me if the question is too silly. Below is my code
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.07
    SQL> show parameter optim
    NAME                                 TYPE        VALUE
    object_cache_optimal_size            integer     102400
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.1
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    plsql_optimize_level                 integer     2
    SQL> explain plan for select SUM(decode(transaction_type,'D',txn_amount,0)) payments_reversals,
      2          SUM(decode(transaction_type,'C',txn_amount,0)) payments,primary_card_no,statement_date
      3             from credit_card_pymt_dtls  group by primary_card_no,statement_date;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2801218574
    | Id  | Operation          | Name                  | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                       |  1912K|    56M|       | 21466   (3)| 00:04:18 |
    |   1 |  SORT GROUP BY     |                       |  1912K|    56M|   161M| 21466   (3)| 00:04:18 |
    |   2 |   TABLE ACCESS FULL| CREDIT_CARD_PYMT_DTLS |  1912K|    56M|       |  4863   (3)| 00:00:59 |
    9 rows selected.
    SQL> select index_name,index_type
      2  from all_indexes
      3  where table_name = 'CREDIT_CARD_PYMT_DTLS';
    INDEX_NAME                     INDEX_TYPE
    INDX_TRANTYPE                  BITMAP
    INDX_PCARD                     NORMAL
    INDX_PSTATEMENT_DATE           NORMALThe query is using all the records in the CREDIT_CARD_PYMT_DTLS table. Transaction type will be either 'C' or 'D'.
    CREDIT_CARD_PYMT_DTLS has 2 million rows and the qury will output 1.5 million rows. Table statisticas are upto date.
    The query now is taking almost 5 minutes. Is thaere any way to reduce the time ?
    Our DB server has 8 CPUs and 8 GB memory. Is the timing genuine ?
    Thanks in Advance.
    Edited by: user11115924 on Apr 29, 2009 2:43 AM
    All the columns used in the query are already indexed. ( Ofcourse, not only for this query.)

    Hi All,
    Thanks for the helps provided. Expecting it once more..
    My actual query is as below
    select     primary_card_no,base_segment_number,atab.previous_balance,current_balance,intrest_amt_due_this_cycle,total_min_amt_due,total_credit_limit,
              total_purchase_this_cycle,total_cash_trns_this_cycle,available_credit_limit,payments,utilization,payment_ratio,payments_reversals,cash_limit,
              available_cash_limit, description
    from
           select primary_card_no,DECODE(base_segment_number,NULL,primary_card_no,base_segment_number) base_segment_number,
                   SUM(previous_balance) previous_balance,SUM(current_balance) current_balance ,SUM(intrest_amt_due_this_cycle) intrest_amt_due_this_cycle,
                   SUM(total_min_amt_due) total_min_amt_due,SUM(total_credit_limit_all) total_credit_limit,
                   SUM(total_purchase_this_cycle) total_purchase_this_cycle,SUM(total_cash_trns_this_cycle) total_cash_trns_this_cycle,
                   SUM(available_credit_limit) available_credit_limit,SUM(payments) payments,
                   (SUM(NVL(current_balance,0)) / SUM(total_credit_limit_all)) * 100 utilization,
                   (SUM(NVL(payments,0)) / DECODE(SUM(previous_balance),0,NULL,SUM(previous_balance))) * 100 payment_ratio,
                   SUM(payments_reversals) payments_reversals,SUM(cash_limit) cash_limit,SUM(available_cash_limit) available_cash_limit
          from
            ( select a.*,NVL(payments_reversals,0)payments_reversals ,NVL(payments,0) payments
              from
                    (  select primary_card_no,previous_balance,current_balance,intrest_amt_due_this_cycle,total_min_amt_due,total_purchase_this_cycle,
                              total_cash_trns_this_cycle,statement_date,available_credit_limit,cash_limit,available_cash_limit,
                           (case when statement_date <= TO_DATE('301108','ddmmyy') then NULLIF(total_credit_limit,0)
                                      else NULLIF((select credit_limit
                                                from ccm_dbf_chtxn_v0 t1
                                                   where t1.batch_id = '011208'
                                                   and SUBSTR(t1.card_number,4) = a.primary_card_no),0)
                             end) total_credit_limit_all
                     from
                        ( select primary_card_no,previous_balance,current_balance,INTREST_AMT_DUE_THIS_CYCLE,
                                    TOTAL_MIN_AMT_DUE,TOTAL_PURCHASE_THIS_CYCLE,TOTAL_CASH_TRNS_THIS_CYCLE,statement_date,
                                   AVAILABLE_CREDIT_LIMIT,cash_limit,available_cash_limit,total_credit_limit
                          from credit_card_master_all@FGBAPPL_LINK
                        ) a
                     where statement_date between ADD_MONTHS(TRUNC(SYSDATE,'mm'),-6) and  TRUNC(SYSDATE,'mm')-1
                 ) a,
                 ( select SUM(decode(transaction_type,'D',txn_amount,0)) payments_reversals,
                               SUM(decode(transaction_type,'C',txn_amount,0)) payments,primary_card_no,TO_CHAR(statement_date,'MON-RRRR') sdate
                    from credit_card_pymt_dtls 
                    group by primary_card_no,TO_CHAR(statement_date,'MON-RRRR')
                 ) b
             where TO_CHAR(a.statement_date,'MON-RRRR')= b.sdate(+)
               and a.primary_card_no= b.primary_card_no(+)
            ) a,
            (  select SUBSTR(a.card_number,4) card_number,base_segment_number,TO_DATE(account_creation_date,'DDMMYYYY') account_creation_date,
                           a.batch_id, credit_limit credit_limit_current
                from
                       (  select *
                           from ccm_dbf_phtxn_v0
                           where batch_id=  (SELECT to_char(MAX(TO_DATE(SUBSTR(BATCH_ID,1,6),'DDMMRR')),'DDMMRR') FROM CCM_MST_V0)
                        ) a,
                        ( select *
                          from ccm_dbf_chtxn_v0
                          where batch_id=(SELECT to_char(MAX(TO_DATE(SUBSTR(BATCH_ID,1,6),'DDMMRR')),'DDMMRR') FROM CCM_MST_V0)
                        ) b
                where a.card_number=b.card_number
                and TO_NUMBER(ROUND(MONTHS_BETWEEN(SYSDATE,TO_DATE(account_creation_date,'DDMMYYYY')),2)) >=6
                and a.company ='BNK'
            ) b
       where a.primary_card_no = b.card_number
       group by primary_card_no,base_segment_number) atab, card_summary_param btab
    where utilization between utilization_low and utilization_high
    and payment_ratio between  payment_ratio_low and payment_ratio_high
    and SIGN(atab.previous_balance) =btab.previous_balanceWhere I have to put the PARALLEL hint for maximum performance?
    Sorry for asking blindly without doing any R&D. Time is not permitting that...
    Edited by: user11115924 on Apr 29, 2009 5:09 AM
    Sorry for the kiddy aliases.. Query is not written by me..

  • Problem with 0FIGL_VC1 when use constant selection in the query

    Please kindly help me. I have this problem for 2 weeks already.
    When I create a query from virtual cube 0FIGL_VC1 (balance sheets / p&l statements), if I use constant selection in any of key figure, my report could not display financial statment correctly. 
    My report layout
    Columns :  key figures  (including 0FIGL_VC1_CK001)
    Rows:  0GLACCEXT  (financial statement item) << as hierarchy
    Initially, the query is processed correctly.
    However, based on the requirement from my customer, I really have to use "constant selection" for some of my columns. Whenever I do so, the query display incorrectly. (Some nodes of financial statement item just disappear. (it seem like all contra item will disappear.)  
    Please help!

    If I dont use constant selection in the query, data are display correctly.
    But If I use constant selection in the query, some financial statement item dont display any value
    Example :
       Financial statement item(Display in hier)     Period1   Total Period1(Constant selection)
                 A                                                       10            60
                 B                                                       20            60
                 C                                                       30            60
                 D                                                       0              60
    - Financial statement item "D"  has some value.
    - Financial statement item "D"  is in the hierarchy,one gl account has been assigned to more than one group differentiated by debit/credit indicator.
    Please help!!

  • What is the syntax for creating global temporary table using a select query

    hii
    I'm creating a global temporary table using a select query ..how to mention 'on commit preserve rows' that?
    create global temporary table t1 as select * from trn_ordbase on commit preserve rows;
    but this is invalid syntax,so how to mention on commit preserve rows in this???if i dont mention it ,by default its considering as on commit delete rows.
    Please help me out of this problem.

    create global temporary table t1 as select * from trn_ordbase on commit preserve rows;You CANNOT use this syntax.
    http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/sqcmd.htm
    http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/glob_tab.gif
    http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/cre_tabl.gif

  • Re querying a table using ONE Select

    Hello Experts,
    In one hit i want to query a Table2 2 times using oNE select query
    Lets say, i have 2 database tables  : Table1 & Table2.
    & internal tables say itab1 & itab2.
    Lets say they have fields:  fld1 fld 2 fld3 fld4.
    1) I used select * from Table1 into table itab1.
    2) Now i want to get entries from table2 based on itab-fld1 and itab2-fld4
    select * from Table2 into itab2
    FOR ALL ENTRIES in itab1
    where fld1 = itab1-fld1
      and fld2 = *itab2-fld4*  (entries based on
    itab2)
    Please suggest.,
    Thanks
    Ricky

    Hi Ricky,
    it is almost impossible to explain anything if you do not have an example of what you are going to do. When I say example, I don not mean Lets say, i have 2 database tables or Lets say they have fields but a case that everyone understands.
    If you are talking about SAP tables, give the names and fields. If you are talking about user-defined tables, decribe the process, give table and field names and characteristics (data element, domain, check table, search help...) of each field.
    For the question Now please tell me how can i write aliasing the answer is a clear F1.
    Shortly: If you write <tabname> AS <alias> or <fieldname> AS <alias> this means that <tabname> and <fieldname> identifie table and field in the database and <alias> is used for it in the query clause and for the data transfer from database to INTO data object.
    Note: It is always better to ask a question for a specific task. Getting the answer you can use it in all tasks that are comparable to the one you asked for. Asking a bla-bla question ( Lets say... ) will rarely get a useful answer.
    Regards,
    Clermens

  • Nested selects in finder query

    Hi!
    Does anyone know whether one can express nested selects
    with WL QL or EJB QL?
    E.g. if one wants to express something like this in a
    deployment descriptor for an CMP EJB:
    SELECT * FROM tableA WHERE someID IN
         (SELECT someID FROM tableB WHERE someColumn = ?)
    cheers
    -jo

    Hi!
    Does anyone know the status of this issue?
    cheers
    -jo
    On Wed, 02 May 2001 16:31:49 -0700, thorick <[email protected]>
    wrote:
    Hi
    SubQueries are currently not supported. We targeting support for them
    in
    our next Major release (after the next Minor release that's due out
    next)
    thorick

Maybe you are looking for

  • Mail does not allow signed message with .Mac certificate

    Hi all, until a few weeks ago, I was able to send signed or encrypted message with my .Mac account and .Mac certificate. Both of them are still valid, and I can still read all messages I sent as encrypted and/or signed, however, Mail does not show th

  • File to RFC Error com.sap.engine.interfaces.messaging.api.exception.Messagi

    Hi , I am doing File to RFC  Scenario. My file get picked and I able to view the audit log under RWB message monitoring. Here I am getting the error u201CTransmitting the message to endpoint dest://XI_INTEGRATION_SERVER using connection File_http://s

  • SCSI to USB adapter

    Does anyone know a good place I can pick up a reasonably priced SCSI to USB cable for a zip drive and/or scanner? thanks

  • Fits attribute on user id during user creation (Cont)

    Hi Experts, A little time ago , we posted some doubt regarding of how can we fits the attribute userID during user creation on User Interface. The previous discussion was posted here: "Fits attribute on user id during user creation" Link abou our iss

  • Non-fillable PDF

    How can I take the online form and create a PDF that shows the all of the drop down options? In other words, I have clients who will be using these forms in the field and need a paper copy with all the options listed.