Problem with a query of xmlt

Hello

I need to query this xml file:

< a > < action id = "1" > < alarm id = "1000" > 3 < / alarm > < alarm id = '1001' > 2 < / alarm > < alarm id = "31" > 2 < / alarm > < / action > < Code action = "3" > < alarm id = "16" > 5 < / alarm > < / has >

I need to add the action/@id attribute to this query:
select aa.hour,
       to_number(extract(value(xa),'alarm/@id')) alm_,
       to_number(extract(value(xa),'alarm/text()')) freq_
  from t_alarm_stats aa,
       xmltable('$XML/a/action/alarm' passing aa.x_alarm AS "XML") xa
 where aa.id_device = 3194
   and aa.hour > trunc(sysdate-1);
I have now the recordset is fine enough:

time, id_alarm and frequency of the alarm:
28/03/2011 01:00 1000 3
28/03/2011 01:00 1001 2
28/03/2011 01:00 31 2
28/03/2011 01:00 16 5

I need to also add the corresponding action/@id, but I don't know how to navigate to a higher level of my xml so that the Recordset:

time, action id, id_alarm and frequency of the alarm:
28/03/2011 01:00 1 1000 3
28/03/2011 01:00 1 1001 2
28/03/2011 01:00 1 31 2
28/03/2011 01:00 3 16 5

Y at - it the possibility to do this with 1 query?

Thanks in advance,
Samuel

Hello

This should do it:

select aa.hour
     , xa1.action_id
     , xa2.alarm_id
     , xa2.alarm_freq
from t_alarm_stats aa,
     xmltable('$XML/a/action'
       passing aa.x_alarm AS "XML"
       columns action_id number  path '@id',
               alarms    xmltype path 'alarm'
     ) xa1,
     xmltable('/alarm'
       passing xa1.alarms
       columns alarm_id   number path '@id',
               alarm_freq number path '.'
     ) xa2
where aa.id_device = 3194
and aa.hour > trunc(sysdate-1)
;

Tags: Database

Similar Questions

  • Problem with hierarchical query in function PL\SQL

    I have a simple table containing the ID of the parent

    -Create table

    create the table1 table:

    (

    ID NUMBER (12) not null,

    year number 4.

    month NUMBER (2),

    parent_id NUMBER (12)

    );

    -Create/recreate primary, unique and foreign key constraints

    change the table1 table:

    Add primary key constraint PK_TABLE1 (ID);

    change the table1 table:

    Add the foreign key constraint FK_TABLE1_PARENT (PARENT_ID)

    reference TABLE1 (ID);

    data:

    Insert into TABLE1 (id, year, month, parent_id)

    values (5, 2015, 12, 3);

    Insert into TABLE1 (id, year, month, parent_id)

    values (6 (2015), 12, 4);

    Insert into TABLE1 (id, year, month, parent_id)

    values (3 (2015), 11, 1);

    Insert into TABLE1 (id, year, month, parent_id)

    values (4 (2015), 11, 2);

    Insert into TABLE1 (id, year, month, parent_id)

    values (1, 2015, 10, null);

    Insert into TABLE1 (id, year, month, parent_id)

    values (2 (2015), 10, null);

    commit;

    and query

    with h as

    (select t.id, t.year, t.month, CONNECT_BY_ROOT t.id as parent_id from table1 t

    where t.year = 2015 and t.month = 12

    and CONNECT_BY_ROOT t.year = 2015 and CONNECT_BY_ROOT t.month = 10

    connect by prior t.id = t.parent_id)

    Select * from:

    Join table1 t left t.id = h.parent_id;

    It works, but when I put this request in the procedure pl\sql

    create or replace procedure is get_report (p_cur_out on sys_refcursor)

    Start

    Open the p_cur_out for

    with h as

    (select t.id, t.year, t.month, CONNECT_BY_ROOT t.id as parent_id from table1 t

    where t.year = 2015 and t.month = 12

    and CONNECT_BY_ROOT t.year = 2015 and CONNECT_BY_ROOT t.month = 10

    connect by prior t.id = t.parent_id)

    Select * from:

    Join table1 t left t.id = h.parent_id;             

    end get_report;

    /

    They do not compile. And in the fall, with the exception

    Errors of compilation for the PC of the PROCEDURE. GET_REPORT

    [Error: PL/SQL: ORA-00600: internal error code, arguments: [qctcte1], [0], [], [], [], [], [], [], [], [], []]

    Online: 6

    Text: with h as

    Error: PL/SQL: statement ignored

    Online: 6

    Text: with h as

    My version of oracle

    1Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
    2PL/SQL Release 11.2.0.3.0 - Production
    3CORE Production 11.2.0.3.0
    4AMT for Linux: Version 11.2.0.3.0 - Production
    5NLSRTL Version 11.2.0.3.0 - Production

    What is the problem with my request? Or database? How to solve this problem?

    If you have access to MOS, you can search the reason of it. If you are using left join syntax instead of joining ANSI, owner Oracle procedure compiles and returns the result.

  • problem with the query insert masking character @.

    Hi the gems...

    I do through xml schema, run... means using a batch file, I'll call the xml files and the xml file contains the names of files containing all the DDLs and LMD...

    No problem with the DDL...

    now when I run the LMD, all are working well except a few insert scripts...

    Insert into TABLE_NAME (EVENT_ID, EVENT_DESC, EVENT_MESSAGE_TEMPLATE, EVENT_MESSAGE_SUBJECT) values (4, 'abcdefgh',)
    'Hi,
    Order details:
    @Order_ID #.
    @Instrument_ID #.
    This is an automated email. Please do not reply.',
    "executed");

    This kind of scripts insert failed with the error "[ora: sqlplus] SP2-0310: could not open the file" Order_ID #, .sql.

    This problem is due to the @ character before the data...

    problem doesn't happen when I run the script explicitly, xml perform only the origin of the problem

    So, I need to know if there is a way to hide the sign @...

    Please help... Thanks in advance

    user12780416 wrote:
    "[ora: sqlplus] SP2-0310: could not open the file" Order_ID #, .sql.

    In SQL * more the @ character means: run a script. That would explain the error message.
    The real problem is that your chain is written on several lines. A string like this might work:

    {code}
    Insert into TABLE_NAME (EVENT_ID, EVENT_DESC, EVENT_MESSAGE_TEMPLATE, EVENT_MESSAGE_SUBJECT) values (4, 'abcdefgh',)
    "Hi," | Chr (10)
    ||' Order of details :'|| Chr (10)
    |' @Order_ID #' | Chr (10)
    |' @Instrument_ID #' | Chr (10)
    ||' This is an automated email. Please do not respond. »
    "executed");
    {code}

    But it might not be a usable workaound.
    As you create the string insert sort, you might be able to replace all line breaks in the present with you own custom lines.

    Replace (yourEventMessage, Chr (10), "' |) Chr (10): "')

  • What is the problem with this query in the source

    A blank page is region 2. Region1: enter rec_no (-rec_no is varchar2) region2:hide and show that displays one record based on rec_ no region1 entered.
    The problem is that I get the following error

    ORA-06550: line 1, column 7: PLS-00428: an INTO clause in this SELECT statement

    Here's my simple query in a process of pl/sql
    Start
    Select rec_no, rec_name from mytable where rec_no = upper(:P16_rec_no);
    end;

    Why? The same query works under the sql command.

    what I'm trying to accompolish here, it is because he has given huge if I want to display hide also multiples, regions and allow users to update each region as a result. Help, please. It kills me that I just can't understand what is causing the problem to the query. Thank you.

    Hello

    The list is set to the field EMPLOYEE_ID itself? What is the primary key of the table? In my example, DEPTNO is the primary key and I used the element generated by the wizard page to display the list. The parameters of the Source of the item itself or the column DEPTNO and database so that the process "process line...". "to identify the updated row.

    Andy

  • Problem with the query in the form of customization mode

    Hi all

    Can you please help me I'm getting problem while doing the customization form

    Scenario:

    Marter dot org form that I need to display the default value in the field of the unit of MEASURE value is null

    I succeed while doing all the steps below

    Condition tab:
    ----------------------
    Trigger the same: ONCE - NEW - ITEM - INSTANCE
    Trigger object: MTL_SYSTEM_ITEMS. INVENTORY_ITEM_MIR

    Action tab:
    ------------------
    Type: property
    type of object: agenda
    Trigger object: MTL_SYSTEM_ITEMS. PRIMARY_UNIT_OF_MEASURE_MIR
    Property name: VALUE
    Value: null

    but the problem is when I try to query (F11) the form, I'm not able to ask please help me with the of this

    Thank you
    EABR

    The problem is, you assign a value to an element when the form is opened, so the form will update mode, so the system not allowing you to make the request (f11). If you clear the value that has been missed, you'd be able to F11.

    So instead set the VALUE, try the INITIAL_VALUE property and let me know if this worked for you.

    Thank you
    Pradeep

  • PROBLEM WITH SQL QUERY.

    Hi all

    I am executing the following query, which I use to retrieve unique records.


    SELECT OH. ORDER_ID, OH. ORDER_DATE, OH. GRAND_TOTAL, OSI. DESCRIPTION ACE ORDER_STATUS,
    PMT. DESCRIPTION AS PAYMENT_METHOD, TR. AS PAYMENT_STATUS DESCRIPTION
    OF ORDER_HEADER OH INNER JOIN ORDER_PAYMENT_PREFERENCE OPP ON OH. ORDER_ID = OPP. ORDER_ID and
    OPP. CREATED_DATE = (SELECT MAX (CREATED_DATE) OF ORDER_PAYMENT_PREFERENCE WHERE THE ORDER_ID = OH. ORDER_ID)
    PAYMENT_METHOD_TYPE PMT, STATUS_ITEM SO, STATUS_ITEM OSI
    WHERE OPP. PAYMENT_METHOD_TYPE_ID = PMT. PAYMENT_METHOD_TYPE_ID AND
    OPP. BATCH = IF. BATCH AND OH. BATCH = OSI. BATCH AND
    (OH. BATCH = "ORDER_CREATED" | OH. BATCH = "ORDER_HOLD") AND
    OH. "CREATED_STAMP > = ' 2011-12-03 11:41:04.

    Problem I am facing is, for some a few order_ids we have several entries in ORDER_PAYMENT_PREFERENCE with CREATED_DATE even where query return me of duplicate records.
    I applied OPP. "CREATED_DATE = (SELECT MAX (CREATED_DATE) OF ORDER_PAYMENT_PREFERENCE WHERE THE ORDER_ID = OH. ORDER_ID)' forced to get the record, unique, but as I said to few recordings, we have several lines in ORDER_PAYMENT_PREFERENCE corr. ORDER_ID single and multiple records have same CREATED_DATE.

    Can you suggest a few changes, the query to retrieve unique records.

    I know I'm a very abstract information, shortly I'll provide table structure and little info I want in this query.
    It's because of the tight work schedule.


    Thank you
    Jagdeep Singh

    Hello

    Basically, you need to convert a number in his order inside each created_date order_payment_preference. However, if you have more than one created_date which is him even you'll actually choose one of them at random unless you specify an order more squeezed by the clause. For example, you might have a numeric value from a sequence that could be added to determine which input was really the most recent. In any case the following should give you an idea what I mean...

    SELECT
          order_id,
          order_date,
          grand_total,
          order_status,
          payment_method,
          payment_status
    FROM
        (
            SELECT oh.order_id,
                   oh.order_date,
                   oh.grand_total,
                   osi.description AS order_status,
                   pmt.description AS payment_method,
                   si.description AS payment_status
                   ROW_NUMBER() OVER(PARTITION BY opp.order_id ORDER BY opp.created_date DESC) rn
            FROM   order_header oh
                   JOIN order_payment_preference opp ON oh.order_id = opp.order_id
                   JOIN payment_method_type pmt ON opp.payment_method_type_id = pmt.payment_method_type_id
                   JOIN status_item si ON opp.status_id = si.status_id
                   JOIN status_item osi ON oh.status_id = osi.status_id
            WHERE
            AND    oh.status_id IN('ORDER_CREATED','ORDER_HOLD')
            AND    oh.created_stamp >= '2011-12-03 11:41:04'
        )
    WHERE
         rn = 1    
    

    Some notes if - it is not a good idea to mix the styles of the junction between ansi and oracle style, it makes it difficult to follow. Just choose one or the other.

    OH.STATUS_ID='ORDER_CREATED' || OH.STATUS_ID='ORDER_HOLD'
    

    Makes no sense. I took a guess that you meant, OR then I converted to an IN clause that will do the same job.

    HTH

    David

  • Dynamic problem with lookup-query for the purpose of resource request

    Hi all
    I need to set up several IOM user exchange mailboxes, I can set up AD account and account of the mailbox without any problem, but only for the first ad and Exchange account. For the second and third, etc. I get the error: "Invalid login name" during Exchange of account provisioning. I discovered that this problem exists with Exchange Connector - it is not able to collect correct GUID. So in my xml Dataset I use dynamic query Lookup to select manually correct Alias, the login name and GUID. The query for the GUID is the sequel (I cloned RO for AD and Exchnage):

    AttributeReference available-in-bulk = "true" length = "32" widget = 'search query' type = 'String' attr-ref = "Object GUID" name = "Object GUID" >
    * < lookupQuery search-query = "select distinct UD_KFUSER_OBJECTGUID GUID, ud_KFUSER_uid like UD_KFUSER UD_KFUSER, orc orc Login, sta sta where UD_KFUSER.orc_key = orc.orc_key and orc.usr_key = ' $Form data." Take ' and UD_KFUSER. "UD_KFUSER_AD = 27 and orc.orc_status = STA.sta_status AND STA.sta_bucket! = 'Cancelled'" display-field = "GUID" save-field = "Object GUID" / > *.
    * < / AttributeReference > *.


    My questions are:

    1. I have to type * to run the query in the user interface, without * I got error:

    + < 17 February 2012 11:12:22 THIS > < error > < oracle.adfinternal.view.faces.config.ric +.
    h.RegistrationConfigurator > < BEA-000000 > < ADF_FACES - 60096:Server Exception durin
    PPR, #10 g
    oracle.iam.platform.canonic.base.NoteException: an error occurred during executin
    g the search query.
    to oracle.iam.platform.canonic.agentry.GenericEntityLookupActor.perform)
    GenericEntityLookupActor.java:337)
    Is this right?

    2. when I got correct values (from the search query) - they are missing on the details of the application and form of RO - what Miss me?

    I use OIM 11.1.1.5, in my xml dataset I use correct attr-Ref (labels), when I type the values manually, they are propagated to form RO and Exchange mailbox is created.
    Best
    MP

    I not had no problem when writing search query.
    This works very well for me.
    The request will be filled for the field, so why choose *?
    I used as

  • What is the problem with this query? My head is numb!

    Can someone tell me why this request;

    < cfquery datasource = "manna_premier" name = "qGetstats" >
    SELECT the user name,
    UserFirstName,
    UserLastName,
    LastLogin,
    TotalLogins,
    UserZone,
    TM_Name
    USERS
    WHERE UserID = ' #. TM_log UserID # '.
    < / cfquery >

    generates this error message;

    Run database query error.

    [Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] Too few parameters. 1 expected.
    The error occurred in D:\Inetpub\mannapremier\TM_log_report2.cfm: line 28
    26 :         TM_Name
    27 : FROM Users
    28 : WHERE UserID = "#TM_log.UserID#"
    29 : </cfquery>
    30 : 
    

    SQLSTATE07002
    SQLSELECT the user ID, UserFirstName UserLastName, LastLogin, TotalLogins, UserZone, TM_Name FROM USERS WHERE UserID = '10120.
    VENDORERRORCODE-3010
    DATASOURCEmanna_premier

    I see that my variable WHERE comes through but the domain name is not working. I'm sure that the answer is obvious, but it drives me crazy!

    Help, please!

    I tried and got this result;

    No, you now use different data. Now, the user ID is empty, while she was 10120 first.

    The only problem seems to be double quotes. To check this, test with

    WHERE UserID = 10120
    

    I'm assuming that the userID field to be an integer. If it is text, then use single quotes (not!), as in

    WHERE UserID = '#TM_log.UserID#'
    
  • Problem with the query.

    I created these queries, but is based on the number of files w_Candidates_Pending, w_Candidates_Pending_Revoked this status I have to set one flag either 1, 2 or 3.

    1 = when 1 or more records for a candidate given pending status,.

    2 = when 1 or more records for a candidate given awaiting status revoked.

    3 = in another State.

    Can u please help me add County in the query and count on the basis, I put 1 one flag.

    WITH w_Pending AS

    (SELECT resource_status_id

    OF ems.resource_status

    WHERE resource_status_desc = 'pending '.

    ),

    w_Pending_Revoked AS

    (SELECT resource_status_id

    OF ems.resource_status

    WHERE resource_status_desc = 'revoke pending. "

    ),

    w_Candidates_Pending AS

    (SELECT DISTINCT ec.ems_candidate_id,

    Eres.resource_status_id,

    Eres.candidate_id

    Of ems_candidate ec,.

    employee_resources eres

    WHERE ec.ems_candidate_id = eres.candidate_id (+)

    AND eres.resource_status_id = (SELECT resource_status_id FROM w_Pending)

    AND eres.through_date IS NULL

    ),

    w_Candidates_Pending_Revoked AS

    (SELECT DISTINCT ec.ems_candidate_id,

    Eres.resource_status_id,

    Eres.candidate_id

    Of ems_candidate ec,.

    employee_resources eres

    WHERE ec.ems_candidate_id = eres.candidate_id (+)

    AND eres.resource_status_id = (SELECT resource_status_id FROM w_Pending_Revoked)

    AND eres.through_date IS NULL

    )

    SELECT DISTINCT CND.ems_candidate_id,

    CND. Name,

    EEJ.ems_job_id,

    (SELECT CASE WHEN COUNT (1) = 0 THEN ELSE 'ADD' END 'n')

    OF wCP w_Candidates_Pending

    WHERE wCP.candidate_id = cnd.ems_candidate_id) pending_flag;

    (SELECT CASE WHEN COUNT (1) = 0 'N' THEN ELSE 'REVOKE' END)

    OF w_Candidates_Pending_Revoked wCPR

    WHERE wCPR.candidate_id = cnd.ems_candidate_id) pending_revoked_flag

    OF ems.ems_candidate cnd.

    EMS.employee_resources err,

    EMS.ems_jobs EJE,

    Rsg EMS.resources_group,

    EMS. Groups grp

    WHERE cnd.ems_candidate_id = err.candidate_id

    AND eej.ems_job_id = cnd.ems_job_id (+)

    AND err.resource_group_id = rsg.resource_group_id

    AND rsg.group_id = grp.group_id

    AND err.through_date IS NULL

    AND IN grp.group_id

    (SELECT DISTINCT grpe.group_id

    Groups_employee grpe, employee emp

    WHERE grpe.person_id = emp.person_id

    AND grpe.person_id = i_logged_in_person_id);

    Maybe

    Select ems_candidate_id,

    name,

    ems_job_id,

    cases where count_pending > 0 and count_pending_revoke is null

    then 1

    When count_pending_revoke > 0 and count_pending is null

    then 2

    When count_pending > 0 and count_pending_revoke > 0

    then 3

    end indicator

    (Select cnd.ems_candidate_id,

    CND. Name,

    EEJ.ems_job_id,

    RSS.resource_status_id,

    RSS.resource_status_desc,

    ROW_NUMBER() over (partition of cnd.ems_candidate_id

    order of rss.resource_status_desc

    ) rn,.

    sum (case rss.resource_status_desc when 'waiting' then 1 end) on

    (cnd.ems_candidate_id order of value null partition

    lines between unbounded preceding and following unlimited

    ) count_pending,.

    sum (case rss.resource_status_desc when 'pending Revoke' then 1 end) on

    (cnd.ems_candidate_id order of value null partition

    lines between unbounded preceding and following unlimited

    ) count_pending_revoke,.

    Count (*) over (partition by order cnd.ems_candidate_id by null

    lines between unbounded preceding and following unlimited

    ) count_candidate_rows

    of ems.ems_candidate cnd.

    EMS.employee_resources err,

    EMS.ems_jobs EJE,

    Rsg EMS.resources_group,

    GRP EMS. Groups,

    EMS.resource_status rss

    where cnd.ems_candidate_id = err.candidate_id

    and eej.ems_job_id = cnd.ems_job_id (+)

    and err.resource_group_id = rsg.resource_group_id

    and rsg.group_id = grp.group_id

    and err.through_date is null

    and grp.group_id in (select distinct)

    GRPE.group_id

    of groups_employee grpe.

    employee emp

    where grpe.person_id = emp.person_id

    and grpe.person_id = i_logged_in_person_id

    )

    and err.resource_status_id = rss.resource_status_id

    )

    where rn = 1

    Concerning

    Etbin

  • What is the problem with this query?

    Hello

    I need some advice on how to change the following query (with perhaps some analytical function) to speed it up. Currently, it takes 6 + minutes. This query is executed in response to a request from the front-end application and 6 + min is certainly unacceptable.

    I am trying to provide as much information I can think, but if more information is needed, please let me know.

    I have a table called "wave_result". It contains millions of rows. PK is Wave_Id, Version_nbr, node_nbr and prod_nbr. For each 'wave_id + node_NBR + prod_nbr' there are several versions (version_nbr). In the following query, I try to extract a line with MAX version_nbr for combination of ' wave_id + node_NBR + prod_nbr.

    H3. Request:
    SELECT ip1.fnln_cat,
                ip1.sub_cat,
                ip1.bus_cat,
                NVL (SUM (ip1.lsu), 0) val
        FROM ideal_prod ip1, ideal_store s, wave_result wr
       WHERE  wr.wave_id = 51
             AND wr.prod_nbr = ip1.prod_nbr
             AND wr.wave_id = ip1.wave_id
             AND wr.version_nbr =
                    (SELECT MAX (wr1.version_nbr)
                       FROM wave_result wr1
                      WHERE   wr1.wave_id = wr.wave_id
                            AND wr1.node_nbr = wr.node_nbr
                            AND wr1.prod_nbr = wr.prod_nbr)
             AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
             AND s.wave_id = wr.wave_id
             AND s.node_nbr = wr.node_nbr 
    GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat
    H3. Rank of charges:
    ========
    "wave_result" is the largest table with millions of rows.
    Table                Total Rows       Rows for wave_id = 51
    Ideal_prod           188K             38K
    Ideal_store          3K               574
    Wave_result          90M              19M
    H3. Stats
    are updated almost daily by the DBA (not sure if that's a good or bad).

    H3. Explain the Plan:
    =========
    SELECT STATEMENT ALL_ROWS Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
         12 HASH GROUP BY Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
              11 VIEW VIEW SYS.VM_NWVW_2 Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
                   10 FILTER 
                        9 HASH GROUP BY Cost: 330,737 Bytes: 2,425,603 Cardinality: 14,881 
                             8 HASH JOIN Cost: 327,183 Bytes: 41,233,784 Cardinality: 252,968 
                                  1 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKIDEAL_STORE Cost: 4 Bytes: 13,202 Cardinality: 574 
                                  7 HASH JOIN Cost: 327,178 Bytes: 35,415,520 Cardinality: 252,968 
                                       5 HASH JOIN Cost: 198,619 Bytes: 18,764,328 Cardinality: 183,964 
                                            3 TABLE ACCESS BY INDEX ROWID TABLE APAPOPR.IDEAL_PROD Cost: 939 Bytes: 2,272,380 Cardinality: 37,873 
                                            4 TABLE ACCESS FULL TABLE APAPOPR.WAVE_RESULT Cost: 197,063 Bytes: 7,974,414 Cardinality: 189,867 
                                       6 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKWAVE_RESULT Cost: 82,467 Bytes: 721,495,854 Cardinality: 18,986,733 
    H3. Sample data:
    ===========
       For wave_id = 51
                     there are 28466854 rows in "wave_result" table
    
       For wave_id = 51 and node_nbr = '0201' and  prod_nbr = '0226960'
                     there are 3 rows in "wave_result" table
    H3. Version of database information are below to:
    =========================
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE            11.1.0.7.0                        Production
    TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Thank you very much!!

    Concerning
    For wave_id = 51
                     there are 28466854 rows in "wave_result" table
    
       For wave_id = 51 and node_nbr = '0201' and  prod_nbr = '0226960'
                     there are 3 rows in "wave_result" table
    

    As you mentioned that this particular request is called by a front screen, how different search criteria you get it to show on the front end?
    Assuming that if the user is searching just of wave_id = 51 which lines returns to 28466854, it is certainly not a good approach to go look up many records to put end Front end is very light and can not hold many records and will be finally the web server will throw off out of memory exception. Always a limit on the number of records that you retrieve from the database and display it on the front plane.
    OR
    The second case where the user makes a search by wave_id, node_nbr and prod_nbr, even if she returns to 3 lines, behind the scens, he still made a full scan on the wave_result table. If we go with analytical function, we can reduce a sweep of extra table on the wave_result table. Also the table has millions of lines and the max (version_nbr) seems to be a frequently used on this table sub query. While inserting a record into the table wave_result, you must probably have a calculated value that will tell you its value max and you will choose just the rank of this value, instead of at each time max(). something like below...

    SELECT ip1.fnln_cat,
                ip1.sub_cat,
                ip1.bus_cat,
                NVL (SUM (ip1.lsu), 0) val
        FROM ideal_prod ip1, ideal_store s, wave_result wr
       WHERE ipl.wave_id = 51
             AND wr.prod_nbr = ip1.prod_nbr
             AND wr.wave_id = ip1.wave_id
             AND wr.wave_id = s.wave_id
             AND wr.node_nbr = s.node_nbr
             AND wr.precomputed_max_value = 'MAX'
             AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
    GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat;
    
  • Problem with database querying adapter

    Hi all

    The polling option treats all rows from a table at a time rather than use the polling frequency. I used an option to update a field (logical deletion) where I've initialized unread value = ' n "and read the value = 'Y'." Now, the problem is that I have to query a single row in the table for every 60 seconds (the second row should be transformed only after 60 seconds), but all the lines are treated at the same time. Can someone let me know what could be the problem?

    I put in the db adapter options:
    Polling frequency: 60 seconds
    Lines by Document XML and database: 1
    Lines per transaction database: 1
    JDBC, query & Timeout options: 60

    Thank you

    Please see the below URL, this can help you.

    http://www.albinsblog.com/2012/10/DB-adapter-message-throttling-in-Oracle.html#.UQI3_fLDiuk

    Concerning
    Albin I
    [http://www.albinsblog.com/]

  • Problem with the query and date

    I'm trying to show only the specific results in my query based on the following:

    If the 'agreedate' is greater than today's date, less than 60 days, show it. Otherwise I don't want results.

    I always get the results of the last year and I don't know why.

    Here is my code:

    <!-the value date today less than 60 days. This works and shows the correct date->

    < cfset invitelimit = #now () # >
    < cfset invitelimit = #DateFormat (DateAdd (would be ', - 60, invitelimit), 'dd-mm-yyyy') #.

    <! - query items from the db and try to catch only to those with a more agreedate then the invitelimit date - >


    < name cfquery = "qinvite" datasource = "#Application.ds #" >

    SELECT DISTINCT * from team a

    INNER JOIN followed b ON a.id = b.team_id
    INNER JOIN termsagreement c ON a.login = c.login

    WHERE c.agreedate > #invitelimit # AND b.comp_id = 0

    Group By a.teamname

    < / cfquery >

    First of all.  Confirm that the "argeedate" column is a datetime column.  Not another type of data that would be much more difficult to work with.

    Secondly, you should provide an appropriate database datetime value.  The easiest way would be with the tag.

    I.E.

    WHERE

    c.agreedate > AND

    b.comp_id =

  • Problem with select query that includes a date

    I fought with it for about 4 hours - Yes, quite literally... I was never good with stuff to date. I have a brain block.

    In any case, here's the situation:

    I have an Access database that has a date/time field. There is no time, just a date in the format dd/mm/yyyy.

    This table is a list of classes held for three years. I want to do a query that displays only the classes that have completed after January 1st of this year. I don't want to put the 01/01/2010 in the query itself because I want it to work again next year.

    It's the current query:

    < name cfquery = "classes" datasource = "" #DSN # "dbtype ="ODBC">"

    SELECT classesTitles.ClassTitle, classesTitles.ClassDesc, classCatagories.catagoryName, classes.classStart, classes.classEnd, classes.classNotes, owners.fName, owners.lName, classTime.timeSlot, classes.classID, classes.classLimit

    FROM classCatagories INNER JOIN (((classes INNER JOIN classesTitles ON classes.classTitle = classesTitles.classTitleID) INNER JOIN classTime WE classes.classTime = classTime.timeID) INNER JOIN owners WE classes.classInstructor = owners.ownerID) ON classCatagories.catagoryID = classesTitles.ClassType

    WHERE the classes.classEnd < 01/01 / #DatePart ("yyyy", now())) #.

    ORDER BY classes.classStart, classCatagories.catagoryName, classTime.timeSlot, classesTitles.ClassTitle

    < / cfquery >

    I don't get any results, but I should get a list of each class that has an end date before 1 January of this year - about 200 cases.

    When I swap around the place where clause:

    < name cfquery = "classes" datasource = "" #DSN # "dbtype ="ODBC">"

    SELECT classesTitles.ClassTitle, classesTitles.ClassDesc, classCatagories.catagoryName, classes.classStart, classes.classEnd, classes.classNotes, owners.fName, owners.lName, classTime.timeSlot, classes.classID, classes.classLimit

    FROM classCatagories INNER JOIN (((classes INNER JOIN classesTitles ON classes.classTitle = classesTitles.classTitleID) INNER JOIN classTime WE classes.classTime = classTime.timeID) INNER JOIN owners WE classes.classInstructor = owners.ownerID) ON classCatagories.catagoryID = classesTitles.ClassType

    WHERE classes.classEnd > 01/01 / #DatePart ("yyyy", now())) #.

    ORDER BY classes.classStart, classCatagories.catagoryName, classTime.timeSlot, classesTitles.ClassTitle

    < / cfquery >

    I get EACH class in the database, and I should get only about 50

    The classes are long about 8 weeks, the dates of beginning and end are in the database in the form of date/time fields, so I need to show everything that ends in 2010, regardless of when it began.

    I'm sure it's something pressing, but he's avoiding me.

    Thank you

    Michelle

    Your field format date in access is irrelevent to the situation at hand.  Use objects appropriate date instead of trying to build an appropriate string.  On 1 January of the current year, the createdate() of coldfusion functions and year() now() are your friends.  Then, a message from Adam was not clear, use cfqueryparam with the resulting variable.

  • problem with a query

    Hello experts,

    I know that is not the exactly the right forum but I'm having some trouble in a query
    select retailer_num, retailer_name 
    from lotto_retailers 
    where agent_status_id = 2
    and salesrepid= :criteria.rep_id
    UNION
    SELECT '0', '**ALL**'
    FROM lotto_retailers 
    where agent_status_id = 2
    and salesrepid= :criteria.rep_id
    ORDER BY 1
    I created a text field in the forms of oracle with a list of values

    I want to have an option "ALL" where it will select all retailer_num based on my salesrep_id condition.this does not seem to work.
    can someone help please

    Thank you

    You look at something like this:

    select retailer_num, retailer_name
    from lotto_retailers
    where agent_status_id = 2
    and salesrepid= (CASE WHEN upper(:criteria.rep_id) = 'ALL' then salesrepid ELSE :criteria.rep_id END)
    ORDER BY 1
    
  • Problem with the query result set * STILL a QUESTION *.

    Summary

    What I am tring to do is to return output to the data points that currently have no values.

    * Here it is sample data for reasons explaining my question (my data set is MUCH bigger)

    xTable
    YEAR    PEOPLE    ITEMS    TYPE_NUMBER TYPE_DESC    CLASS
    2010       1                 1              REG              1 
    2010        2        3         2             MISC             1
    2010        5        4         3             WEEK           1
    2010                             1             REG              2
    2010                             2             MISC             2
    2010                             3             WEEK           2
    2009       1                 1              REG              1 
    2009        2        3         2             MISC             1
    2009        5        4         3             WEEK           1
    2009                             1             REG              2
    2009                             2             MISC             2
    2009                             3             WEEK           2
    
    ... (there's over 100 other unique CLASS values)
    Desired output
    YR     PEOPLE   ITEMS   TOTAL PEOPLE  TOTAL_ITEMS
    2010         -            -            -                        -                         --  (Class 2 result set)
    
    /* FYI, If i wanted the class 1 result set it would look like this:
    YR     PEOPLE   ITEMS   TOTAL PEOPLE  TOTAL_ITEMS
    2010        8       7             16                    14                       -- (Class 1 result set)*/
    Oracle: 10.2 G
            select 2010 as yr,
                         nvl(f.people,'-') as people
                         nvl(f.items,'-') as items  
                         nvl(to_char(sum(f.people)),'-') as total_people,
                         nvl(to_char(sum(f.items)),'-') as total_items,
                         from Xtable,
                              (2010 as yr,
                              sum(items)as items
                              sum(people) as people
                              from xTable
                              where person_id = 99999
                              and   type_number in (1,2,3)
                              and year = 2010
                              and class = 2 
                              or class = 1
                              ) f
                         where person_id = 99999
                         and type_number in (1,2,3)
                         and yr = f.yr
                         and (year <= 2010 or year = 2010)
                         and (class = 2 or class = 1)
                         group by 
                         f.people,
                         f.items
    Currently, the query above will return no rows.

    Published by: user652714 on February 2, 2010 13:04

    How about this?

    SQL> WITH    xTable AS
      2  (
      3          SELECT 2010 AS YEAR, 1 AS PEOPLE, 0 AS ITEMS, 1 AS TYPE_NUMBER, 'REG' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      4          SELECT 2010 AS YEAR, 2 AS PEOPLE, 3 AS ITEMS, 2 AS TYPE_NUMBER, 'MISC' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      5          SELECT 2010 AS YEAR, 5 AS PEOPLE, 4 AS ITEMS, 3 AS TYPE_NUMBER, 'WEEK' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      6          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 1 AS TYPE_NUMBER, 'REG' AS TYPE_DESC, 2 AS CLASS FROM DUAL UNION ALL
      7          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 2 AS TYPE_NUMBER, 'MISC' AS TYPE_DESC, 2 AS CLASS FROM DUAL UNION ALL
      8          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 3 AS TYPE_NUMBER, 'WEEK' AS TYPE_DESC, 2 AS CLASS FROM DUAL
      9  )
     10  -- END SAMPLE DATA
     11  SELECT  YEAR
     12  ,       NVL(TO_CHAR(SUM(PEOPLE)),'-')    AS PEOPLE
     13  ,       NVL(TO_CHAR(SUM(ITEMS)),'-')     AS ITEMS
     14  ,       CLASS
     15  FROM    xTable
     16  WHERE   CLASS IN (1,2)
     17  AND     YEAR = 2010
     18  GROUP BY YEAR
     19  ,       CLASS
     20  ORDER BY CLASS DESC;
    
                    YEAR PEOPLE ITEMS CLASS
    -------------------- ------ ----- -----
                    2010 -      -         2
                    2010 8      7         1
    

Maybe you are looking for