Using the query - amount weekly, daily, max & time

Hi guys,.

I came looking for help with this query, I should use to create a new table. At first I just thought I needed to store the weekly amount and some other information, but then told me that I need the sum for the week and the hourly figure higher this week with time. I managed to make all columns except rush hour causing me issues.

The DESC table is as follows: http://i38.tinypic.com/8yt0.png

My query result has need of the following:
Db_name (direct copy of the table)
TYPE (direct copy of the table)
YEAR (cropped from TD_HR - first 4 characters)
WEEK (cropped from TD_HR and then converted to the IW format)
TOTAL (weekly column TOTAL amount)
HOURLY_PEAK (the largest AMOUNT for a given time during a week)
PEAK_TIME (time of the highest sum for the week)

I have everything show except PEAK_TIME. Sample data:
DB_NAME     TD_HR             TOTAL   TYPE
CSAHEPA     2008-07-24 16     35     CON
CSAHEPA     2008-07-24 15     4     CON
CSAHEPA     2008-07-24 16     19     CON
CSAHEPA     2008-07-24 17     3651     CON
CSAHEPA     2008-07-24 16     7     CON
CSAHEPA     2008-07-24 17     113     CON
CSAHEPA     2008-07-24 17     534     CON
CSAHEPA     2008-07-24 17     289     CON
CSAHEPA     2008-07-24 17     12     CON
CSAHEPA     2008-07-24 16     52     CON
My current (terribly inefficient) query is the following:
select DB_NAME, YEAR, WEEK, sum(SUM), TYPE, sum(WEEKLY_PEAK) from (
select DB_NAME, SUBSTR(TD_HR, 1, 4) year, to_char(to_date(SUBSTR(TD_HR, 1, 10), 'RRRR-MM-DD'), 'IW') week, sum(TOTAL) sum, TYPE, 0 WEEKLY_PEAK
from CORCON01_HOUR_CHG_TOTALS
group by DB_NAME, SUBSTR(TD_HR, 1, 4), to_char(to_date(SUBSTR(TD_HR, 1, 10), 'RRRR-MM-DD'), 'IW'), TYPE
union all
select db_name, year, week, 0 sum, type, max(peak) weekly_peak from (
select DB_NAME, SUBSTR(TD_HR, 1, 4) year, to_char(to_date(SUBSTR(TD_HR, 1, 10), 'RRRR-MM-DD'), 'IW') week, TYPE, sum(total) peak, CONCAT(INITCAP(TO_CHAR(TO_DATE(rpad(td_hr, 10),'yyyy-mm-dd'),'dy')), substr(td_hr,11))||':00' peak_time
from CORCON01_HOUR_CHG_TOTALS
group by DB_NAME, SUBSTR(TD_HR, 1, 4), to_char(to_date(SUBSTR(TD_HR, 1, 10), 'RRRR-MM-DD'), 'IW'), TYPE, CONCAT(INITCAP(TO_CHAR(TO_DATE(rpad(td_hr, 10),'yyyy-mm-dd'),'dy')), substr(td_hr,11)))
group by db_name, year, week, type)
group by db_name, year, week, type
The final column data are given in the 2nd query here as:
CONCAT (INITCAP (TO_CHAR (TO_DATE (rpad (td_hr, 10), "yyyy-mm-dd"), "dy")), substr(td_hr,11)) |': 0 0' peak_time
Any help (get the last column included and/or improvement of the effectiveness of the query) is greatly appreciated.

Mike

This?

with  results as (select db_name,
                         to_date(td_hr, 'yyyy-mm-dd hh24') td_hr,
                         total,
                         type
                  from   CORCON01_HOUR_CHG_TOTALS),
final_results as (select db_name,
                         td_hr,
                         type,
                         sum(total) sum_total
                  from   results
                  group by db_name,
                           td_hr,
                           type)
select db_name,
       to_char(td_hr, 'yyyy') year,
       to_char(td_hr, 'iw') week,
       type,
       sum(sum_total) week_sum_total,
       max(sum_total) peak_sum_total,
       to_char(max(td_hr) keep (dense_rank first order by sum_total desc), 'yyyy-mm-dd hh24') peak_hour
from   final_results
group by db_name,
         to_char(td_hr, 'yyyy'),
         to_char(td_hr, 'iw'),
         type;

DB_NAME          YEAR WEEK TYPE       WEEK_SUM_TOTAL PEAK_SUM_TOTAL PEAK_HOUR
---------------- ---- ---- ---------- -------------- -------------- -------------
CSAHEPA          2008 30   CON                  4716           4599 2008-07-24 17
CSAHEPA          2008 39   CON                   611            555 2008-09-24 16

(And why, oh why, you store your dates as VARCHAR2?) ({noformat} * sobs * {noformat})

Tags: Database

Similar Questions

  • List of virtual machines in TIME using the query service

    Someone been able to use the query service to produce a range of virtual machines in a paralytic? I don't see all the attributes on the VclQueryadminVMField that reference the vApp.

    I log in the org of system.

    Any help would be appreciated.

    Name of the action: getVAppVms

    Entry: VAPP (vCloud:VApp)

    Output: Array / vCloud:VM

    Script:

    var vcdHost = vApp.getHost();
    var vms = new Array();
    
    var queryService = vcdHost.getQueryService();
    expression = new VclExpression(VclQueryVMField.CONTAINER, vApp.getReference().href, VclExpressionType.EQUALS);
    filter = new VclFilter(expression);
    params = new VclQueryParams();
    params.setFilter(filter);
    
    var resultSet = queryService.queryRecords(VclQueryRecordType.VM, params);
    while (resultSet != null) {
        var records = resultSet.getRecords(new VclQueryResultVMRecord());
        System.log(records.length + " VM records found");
        for each (var record in records) {
         var vmRef = new VclReference();
         vmRef.href = record.href;
         vmRef.name = record.name;
         vmRef.type = record.type;
         vms.push(vcdHost.getEntityByReference(VclEntityType.VM, vmRef));
        }
        resultSet = resultSet.getNextPage();
    }
    
    return vms;
    

    This is what made our team (more precisely - Christophe)

  • Inserting data by using the query

    Hello

    In a book, I read the Sub statement:

    Inserting data by using the query (DML)

    If the user wants to transfer data from a table to another table in the insert statement are used independently of data that can be processed or not processed form.

    Can someone clarify what is the significance of this (processed or unprocessed form).


    Thank you.

    Why don't you ask the author of the book.

    How can we know what the author means when you take a quote out of context and don't provide any reference so that we can see exactly what is shown to you.

    I can only imagine that they are referring to data that are queried directly, "like what", another table, or who was interrogated and manipulated before be inserted.

  • the search for empty cells by using the query designer

    Hello

    I'm trying to exclude empty cells in a field (by using the Query Builder), and I did:

    xDocumentSource < match > "CDL".

    < AND >

    < NOT > (xRelatedMsgid < match > "" "")

    but it does not work. I tried "NULL", but it does not work either. Could someone tell me how to do it (or where I can find examples of queries).

    Kind regards

    Iwona

    https://blogs.Oracle.com/Kyle/entry/searching_for_null_values_ucm

  • Can I use the total amount of resources (cpu/ram) of two esxi hosts if I place a cluster so that a single VM gets all resources?

    I use vCenter 5.1 with two esxi 5 guests, both exactly the same (Evga SR - 2 pc with two Intel x 5670 each) with the exception of the disk storage. Processor x 5670 a 12 hearts if HT is enabled. Since then, I have 4 of these processors that would be 48 cores. Each processor is clocked at 4 GHz for a total of 16 GHz. Each host would also 24GO of total Yes 48 GB of ram.

    I doubt that this is possible, but what I want to do is to install a virtual machine like Win 7 x 64 and give all these resources to it... all of them (perhaps leave some carrots and ram aside for guests of esxi, of course). This vm is run to 16 GHz? It would be nice if we could create a cluster with a Setup like this and give the "total available resources' for a single virtual machine running on a esxi host.

    I doubt that this is possible because I've tried that before and it wouldn't let me create a virtual machine with this number of nuclei or ram because he said that they were not available or something... as if to suggest that I can only use the total amount of resources to AN esxi host.

    There may be another way I could give this 16 GHz machine?

    Could not assign more resources to a host to a virtual computer.

  • I have a total of cells which can go up to any amount.  I also have a Grand total of cells using the total amount of cells, BUT it must be a total which is &lt; = 20

    I have a total of cells which can go up to any amount. I also have a GRAND total of cells using the total amount of cells, BUT it must be a total which is < = 20.  So in other words. He TOTAL = 31 total can only = 20.   If the TOTAL = 8 total would equal 8.

    Thank you!

    Custom calculation script for "GRAND total":

    var total = + this.getField ("TOTAL") .value;

    Event.Value = Math.min (total: 20);

  • Using the QUERY parameter in exp/expdp

    Hi, I've faced a nite last question.
    IM currently using Oracle 10 g (10.2.0.4) OS - MS Windows Server 2003

    I want a dump of tables to export multiple schemas. say (acb.m1, pqr.b2, xyz.b1)

    Each table has a minimum lines of 2,000,000,

    And I want to just the initials 10 rows in each table of export

    Is it possible that I can do this...

    Please answer.
    Thanks in advance

    Export tables in multiple schemas is not supported in Data Pump until 11.1.0.7. So if you're on 10g, you will need to run multiple commands expdp. For only 10 lines of each table, use the query parameter

    Query = "where rownum"<>

    This will apply to all the tables you export.

    I hope this helps.

    Dean

    Published by: Dean WINS January 30, 2012 08:42

  • Not able to change the password by using the query. Select APPS.fnd_web_sec

    Not able to change the password by using the query.
    Select APPS.fnd_web_sec.change_password ('username', 'password') 'RES' double;

    Can someone tell why and what privileges and subsidies have flexibility to the user non-apps while it can change the password using fnd_web_sec.change_password.



    Concerning

    the information above does not solve my problem, I get the message

    Because you do not have permission on all objects that are referenced by the API (see below).

    Select FND_WEB_SEC. CHANGE_PASSWORD ('MARSHAD', 'mohammad @123') "RES" of the double

    *

    ERROR on line 1:

    ORA-00942: table or view does not exist

    ORA-06512: at the 'APPS '. FND_CORE_LOG', line 25

    ORA-06512: at the 'APPS '. FND_CORE_LOG', line 432

    ORA-06512: at the 'APPS '. FND_PROFILE', line 110

    ORA-06512: at the 'APPS '. FND_SSO_MANAGER", line 227

    ORA-06512: at the 'APPS '. FND_WEB_SEC', line 1425

    ORA-06512: at line 1...

    can you please list me what are the grants and other Jules Destrooper I should give to a user so that he can change password.

    I don't have the list of objects and you should get yourself by consulting the site code and eTRM API.

    by changing the DDT in the user non-apps after the grant, will, it may be able to change the password.please tell this syntax is correct or not.
    Select applications. FND_WEB_SEC. CHANGE_PASSWORD ('user', 'pwd') "RES" of the double

    What is the point of using 'FND_WEB_SEC. CHANGE_PASSWORD' and not FNDCPASS or FND_USER_PKG API?

    Thank you
    Hussein

  • DataPump import by using the query

    Hello

    I need to import data by filtering using the query. can anyone help?

    Thank you

    Hello
    example of

    expdp HR/hr = emp QUERY:'"WHERE dept_id > 10 AND sal > 10000"' NOLOGFILE = y DIRECTORY = dpump_dir1 DUMPFILE = exp1.dmp

    Impdp HR/hr DIRECTORY = dpump_dir1 DUMPFILE = expfull.dmp QUERY = departments:'WHERE department_id «»< 120"'="" nologfile="">

    See this link

    http://download.Oracle.com/docs/CD/B13789_01/server.101/b10825/dp_import.htm

  • IMPDP | Possible using the query option

    HI PPL,

    I wanted to know if IMPDP is possible by using the query option, as I took full expdp dump of the mentioned table and want to import only select lines.

    Impdp arup/arup directory = demo_dir dumpfile = employees.dmp
    Query = employees:------"" where salary\ > 10000\ order of salary "tables used ="

    version: 10 gr 2
    platform: UNIX

    concerning

    Obviously, it will be slow if you are using the query option, because IMPDP must import only the data that meets the criteria; It of why we export only limited data (one or two tables as needed) and import them completely.

    Concerning
    Girish Sharma

  • Problem in the export using the QUERY functionality

    Problem in the export using the QUERY functionality


    I'm trying to export some rows in a table using the query functionality
    and I have some errors... I'm using the syntax is

    system@orcl QUERY = scott.emp expdp: '"WHERE emp_no = 123455" '
    DIRECTORY = data_pump_dir DUMPFILE = data_pump.dmp
    LOGFILE = data_pump_12345.log INDEX = n

    Can someone tell me please the problem with that statement

    I also tried to use the simple export

    exp file system@orcl = orcl_export.dmp log = orcl_export.log
    tables = Scott.EMP index = QUERY = n------"WHERE emp_no\ = 123455\"

    and this error

    EXP-00008: ORACLE error 904
    ORA-00904: identify invalid

    My os is Solaris
    Please let me know what the problem

    Hello

    Try to create parfile and use that, otherwise, you will need to escape each clause correctly to run exp or expdp successfully.

    test.par

    tables=emp
    query="WHERE emp_no=123455"
    
    or
    tables=myobjects
    query="WHERE owner='SYS'"
    
    $> exp username/password parfile=test.par
    
    Export: Release 10.2.0.1.0 - Production on Thu Mar 19 10:17:48 2009
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining Scoring Engine options
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    
    About to export specified tables via Conventional Path ...
    . . exporting table                      MYOBJECTS      22650 rows exported
    Export terminated successfully without warnings.
    

    Concerning

    Published by: OrionNet on March 19, 2009 10:21

  • attempts to cancel the query discoverer - it takes long time to cancel...

    Hello world

    I cancelled a beak of query. It took a long time to run

    Now it takes a long time to cancel

    The admin is out to lunch...

    all advice, pls, thx, sandra

    Hi, Sandra
    In general, the reason for the cancellation of a query is that it has worked too long - right?

    Behind the scenes, one of two things happening, either:

    1. the request was to have a hard time finding data and is always looking, or
    2. the query found some data but not enough to satisfy the query governor parameters

    For these, depending on the amount of data has so far been recovered, discoverer must these data somewhere. This is called a cache. The data you put in a cache more must be allowed to come out it should you decide not to go forward. This is probably what has happened to you.

    Also, when you cancel a query you are generally posed a question about whether discoverer must keep the last change but does not return any data. If you click Yes in response to this question is usually what triggers the compensation of the cache. Most of the time I just click No, even if I made a little change. I tend to get my quick return query.

    Finally, if your discoverer worksheet is a crosstab or use Page elements, or even both at the same time, it is one of the causes of a long-running query. In these scenarios, discoverer has buckets to calculate and he has no idea how many buckets to until he has read all the data.

    My Discoverer 10 g manual and in my training I speak on the motion of The Twilight Zone. These are queries than ever or never looks back all the data and either expire or must be stopped manually. Sometimes these runaway queries trying to return each row of data in the database, but more generally, they are caused by the use of overcasual of page elements or tables double entry.

    Let us hope that this logbook help
    Best wishes
    Michael

  • Satellite L100-179 - cannot use the full amount of RAM

    Hello

    I have the laptop above and for some time have been under Windows XP with the RAM, he came with, I have now bought 2 sticks of 1 GB, after checking the max RAM allowed, the problem is that when I install Windows reports that 896 MB of RAM installed.

    Latest version of the BIOS is installed and I changed the setting MAXMEM in Windows, but still no go. These two circuits are fully operational (installed on another laptop and the right amount is shown), my question is how do repair this laptop to recognize the full amount of RAM I have installed.

    Concerning

    Hey Buddy,

    It is difficult to say something... What new bought exactly RAM modules?
    I mean, theoretically, that they are not compatible

    How much RAM will appear in the BIOS?
    Perhaps of missing memory capacity is reserved for the graphics card and internal devices.

  • 3000N200 R &amp; R backup takes hours and using the large amount of disk space. Can anyone help?

    The weekly backup of Rescue and Recovery has suddenly started to take hours when I haven't changed anything and uses a large amount of hard disk space. I tried to remove some previous backups and it and it seemed to work OK and then all of a sudden decides to do the same thing. I tried a previous restore point and it helped for a while and now just made a backup taking 4 hours and 20 GB of hard drive space. It is a fault and has nothing to do?


  • How can improve on the slow update using the query / * + NO_XML_DML_REWRITE * /?

    We have an update query recently brought to my attention that turns very slowly on Oracle 11.2.0.1 against a secure XML binary files table using

    Update / * + NO_XML_DML_REWRITE * / set object_value = croutreach.action: 1 where actn_id =: 2.
    I am told the majority/close to the majority of the ~ 16 fields are updated. This table has also many predefined virtual columns with index fn based on them.

    My first inclination was to this redesign using updatexml Oracle. I was told, the / * + NO_XML_DML_REWRITE * / index would also be required here.

    Update / * + NO_XML_DML_REWRITE * /.
    < tble_name > a
    Set a.object_value = updatexml (a.object_value...).

    Last year our dba have been mandated by Oracle Support to use this trick, as the update has not been updated off any msgs of error records.

    + 1. Hoping to find out if anyone met with this indication in some capacity and what has their experience been? +

    Trying to optimizie this update statement, I'll start from scratch is not using the / * + NO_XML_DML_REWRITE * / hint and will take effect in using the updatexml with establishing a xmlindex.

    + 2. Hoping to receive suggestions on creating the good xmlindex - find an informal index. If getting a few good performance with the xmlindex; in an attempt to remove some of the use of the virtual column. +

    + 3. Any suggestions on living with virtual columns in conjunction with xmlindexes? See the definition of table action and Associates ivirtual columns and indexes. This picture seems more indexed... +.
    REATE
      TABLE "CROUTREACH"."ACTION" OF XMLTYPE
      (
        CONSTRAINT "ACTN_ID_PK" PRIMARY KEY ("ACTN_ID") USING INDEX PCTFREE 10
        INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT
        1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1
        FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE
        DEFAULT) TABLESPACE "ACME_DATA" ENABLE
      )
      XMLTYPE STORE AS SECUREFILE BINARY XML
      (
        TABLESPACE "ACME_DATA" ENABLE STORAGE IN ROW CHUNK 8192 CACHE READS LOGGING
        NOCOMPRESS KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1
        MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT)
      )
      ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
      (
        *"ACTION_DEF_URN"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                 
    /action/srvContextPointer/outreachActionDefInfo/@actionDefUrn                                               
    '
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        *"STAT_DT"* AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                              
    /action/@status_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE))),
        *"ACT_DEF_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                              
    /action/srvContextPointer/outreachActionDefInfo/@actionDefId'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(20))),
        *"CORRL_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                              
    /action/correlationId'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        *"STAT_RSN"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                                  
    /action/statusReason'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(30))),
        *"ACT_APPNT_DT"* AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                  
    /action/actionAppointment/appointment_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE))),
        *"UPDT_DT"* AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                              
    /action/@update_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE))),
        *"CRET_DT"* AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                              
    /action/@create_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE))),
        *"ACT_SEQ"* AS (CAST(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                    
    /action/srvContextPointer/outreachActionDefInfo/@sequence'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2)) AS NUMBER(10))),
        *"SERVICE_DEF_URN"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03";                                                          
    /action/srvContextPointer/serviceDefUrn'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(100))),
        *"ASSIGN_TEAM_CD"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                  
    /action/assignment/@teamCategoryCode'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        *"ASSIGN_STAFF_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                  
    /action/assignment/staffProfileId'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        *"ACTION_TYPE"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)                                                      
    declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance"; (::)                                                      
    local-name-from-QName(QName("http://www.cigna.com/acme/domains/actions/2010/03",/action/@xsi:type))                                                                  
    '
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        *"ACTN_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03";/action/@id'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        *"STATUS"*AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03";/action/@status'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(20))),
        *"ACME_MBR_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03";/action/acmeMemberId'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50)))
      )
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
      (
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      )
      TABLESPACE "ACME_DATA" ;
    CREATE UNIQUE INDEX *"CROUTREACH"."SYS_C0014547"* ON "CROUTREACH"."ACTION"
      (
        "SYS_NC_OID$"
      )
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
      (
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      )
      TABLESPACE "ACME_DATA" ;
    CREATE UNIQUE INDEX *"CROUTREACH"."SYS_IL0000082156C00003$$"* ON "CROUTREACH".
      "ACTION"
      (
        PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576
        MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST
        GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
        TABLESPACE "ACME_DATA" PARALLEL (DEGREE 0 INSTANCES 0) ;
    CREATE UNIQUE INDEX *"CROUTREACH"."ACTN_ID_PK"* ON "CROUTREACH"."ACTION" (
      "ACTN_ID") PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(
      INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
      FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
      CELL_FLASH_CACHE DEFAULT) TABLESPACE "ACME_DATA" ;
      CREATE
        INDEX *"CROUTREACH"."ACTION_STAT_RSN_IDX"* ON "CROUTREACH"."ACTION"
        (
          "STAT_RSN"
        )
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        (
          INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
          0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
          CELL_FLASH_CACHE DEFAULT
        )
        TABLESPACE "ACME_DATA" ;
      CREATE
        INDEX *"CROUTREACH"."ACTION_UPDT_DT_IDX"* ON "CROUTREACH"."ACTION"
        (
          "UPDT_DT"
        )
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        (
          INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
          0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
          CELL_FLASH_CACHE DEFAULT
        )
        TABLESPACE "ACME_DATA" ;
      CREATE
        INDEX *"CROUTREACH"."ACTION_CRET_DT_IDX"* ON "CROUTREACH"."ACTION"
        (
          "CRET_DT"
        )
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        (
          INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
          0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
          CELL_FLASH_CACHE DEFAULT
        )
        TABLESPACE "ACME_DATA" ;
      CREATE
        INDEX *"CROUTREACH"."ACTION_STAT_DT_IDX"* ON "CROUTREACH"."ACTION"
        (
          "STAT_DT"
        )
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        (
          INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
          0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
          CELL_FLASH_CACHE DEFAULT
        )
        TABLESPACE "ACME_DATA" ;
      CREATE
        INDEX *"CROUTREACH"."ACTION_MBRID_TYP_STAT_IDX"* ON "CROUTREACH"."ACTION"
        (
          "ACME_MBR_ID",
          "ACTION_TYPE",
          "STATUS"
        )
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        (
          INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
          0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
          CELL_FLASH_CACHE DEFAULT
        )
        TABLESPACE "ACME_DATA" ;
      CREATE
        INDEX *"CROUTREACH"."ACT_ACTDEF_URN_IDX"* ON "CROUTREACH"."ACTION"
        (
          "ACTION_DEF_URN"
        )
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        (
          INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
          0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
          CELL_FLASH_CACHE DEFAULT
        )
        TABLESPACE "ACME_DATA" ;
      CREATE
        INDEX *"CROUTREACH"."ACTION_ACT_DEF_ID_STATUS_IDX"* ON "CROUTREACH"."ACTION"
        (
          "ACT_DEF_ID",
          "STATUS"
        )
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        (
          INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
          0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
          CELL_FLASH_CACHE DEFAULT
        )
        TABLESPACE "ACME_DATA" ;
    Any suggestions much appreciated.

    Kind regards
    Richard Blanchard

    Hi Rick,

    Thanks for adding the sample.

    First note: you use namespaces by default, different in the example of XML and the request - this a misspelling due to your mask real names?

    In any case, I see two problems with the UPDATE statement:

    (1) unless it is really part of the id, do not double-cover the value:

    @id="'888a80be-d69f-464d-b3f7-85b6209f918e'"
    

    must be:

    @id="888a80be-d69f-464d-b3f7-85b6209f918e"
    

    or as a variable binding (see below)

    (2) just like other XML features, XMLExists supports the names. You must declare any namespace as you lower to use XQuery in the expression (in this case, the default namespace).

    It works for me:

    SQL> create table action of xmltype
      2  xmltype store as securefile binary xml
      3  ;
    
    Table created.
    
    SQL> insert into action
      2  values (
      3   xmltype('
      4  
     13     abcdefghijklmnop
     14     qrstuvwxyz
     15     
     16        urn:coderunner:Medical:Definition:ServiceService:11111:7
     17        
     18           Access Profile~Why did you access the profile?~Reason for access?
     19        
     20     
     21  ')
     22  );
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> UPDATE action
      2  SET object_value =
      3      updatexml( object_value
      4               , '/action/@status'
      5               , 'triggered'
      6               , 'xmlns="http://www.xxxxxx.ddd/mmm/domains/actions/2010/03"' )
      7  WHERE XMLExists( 'declare default element namespace "http://www.xxxxxx.ddd/mmm/domains/actions/2010/03"; (::)
      8                   /action[@id=$action_id]'
      9                   passing object_value
     10                         , 'dfdfdfdfdfddfdfdfdfdfdf' as "action_id"
     11                   )
     12  ;
    
    1 row updated.
    
    SQL> SELECT XMLCast(
      2           XMLQuery('declare default element namespace "http://www.xxxxxx.ddd/mmm/domains/actions/2010/03"; (::)
      3                     /action/@status'
      4                     passing object_value returning content)
      5           as varchar2(30)
      6         ) as status
      7  FROM action
      8  ;
    
    STATUS
    ------------------------------
    triggered
    

Maybe you are looking for

  • icon dock or desktop for specific combinations of library/itunes

    My wife and I have different iTunes libraries on our iMac, but I'm looking for an easier way to switch between libraries to Option - < click iTunes > and then search for the library on the right. I prefer to create a script (shell, terminal command l

  • Install the older version of the Flash plugin

    XP/SP 3 running with FF 4.0.1. V 11 Flash is not supported, so I downloaded and installed from the Adobe Flash 10.3 archive. Installation seems successful, control panel he sees, but he does not appear in FF.Try to install the exe of the plugins wind

  • Some problems with Qosmio G30-179 - remote and TV

    Hello, (I am French and my English is bad) I have a Qosmio G30-179 and I can't use my remote when the computer's power on. But I can use the remote to turn on my computer and I can use it when I use the TV and media keys (on the right of the power bu

  • Canoe use microphone on my Satellite L450/136

    Me seems to have no microphone, if victory explains his work, but no one can hear me.Yes it s snub and it s do not cut. Plugs of a thing in the past if I plugged my head phones forwards, or is any device, I have 2 legends, but they no longer appear.

  • PXI controller

    Hey,. I want to get a TestSystem with hardware. I started with a PXI/SCXI chassis, but fallen into chassis SMU (compatible PXI, due to recommendations OR) and configuration (sales Assistant) started this system with Ao module, etc. but suddenly, a po