Index within timestamp column of XML datatype

Team , Thanks for your help in advance !
I'm looking out for some suggestions about creating indexes within XML datatype , Preferably a timestamp . Pasted below sample xml data ..I'm googling it in the interim while some one help me here .
<RingBufferTarget truncated="0" processingTime="0" totalEventsProcessed="2" eventCount="2" droppedCount="0" memoryUsed="1054">
<event name="object_created" package="sqlserver" timestamp="2015-03-09T08:20:17.550Z">
<data name="database_id">
<type name="uint32" package="package0" />
<value>41</value>
</data>
<data name="object_id">
<type name="int32" package="package0" />
<value>933578364</value>
</data>
<data name="object_type">
<type name="object_type" package="sqlserver" />
<value>8277</value>
<text>USRTAB</text>
</data>
<data name="index_id">
<type name="uint32" package="package0" />
<value>0</value>
</data>
<data name="related_object_id">
<type name="int32" package="package0" />
<value>0</value>
</data>
<data name="ddl_phase">
<type name="ddl_opcode" package="sqlserver" />
<value>0</value>
<text>Begin</text>
</data>
<data name="transaction_id">
<type name="int64" package="package0" />
<value>284364642</value>
</data>
<data name="object_name">
<type name="unicode_string" package="package0" />
<value>DUMMY</value>
</data>
<data name="database_name">
<type name="unicode_string" package="package0" />
<value />
</data>
<action name="cpu_id" package="sqlos">
<type name="uint32" package="package0" />
<value>0</value>
</action>
<action name="task_time" package="sqlos">
<type name="uint64" package="package0" />
<value>14322587</value>
</action>
<action name="client_app_name" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>Microsoft SQL Server Management Studio - Query</value>
</action>
<action name="client_hostname" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>VDDBARY</value>
</action>
<action name="database_name" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>TEST_R_D</value>
</action>
<action name="nt_username" package="sqlserver">
<type name="unicode_string" package="package0" />
<value />
</action>
<action name="server_instance_name" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>SQLDEV01</value>
</action>
<action name="server_principal_name" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>ryelug01</value>
</action>
<action name="session_id" package="sqlserver">
<type name="uint16" package="package0" />
<value>99</value>
</action>
<action name="session_nt_username" package="sqlserver">
<type name="unicode_string" package="package0" />
<value />
</action>
<action name="session_resource_group_id" package="sqlserver">
<type name="uint32" package="package0" />
<value>2</value>
</action>
<action name="sql_text" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>USE TEST_R_d
CREATE TABLE DUMMY
id int not null
)</value>
</action>
<action name="username" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>ryelug01</value>
</action>
</event>
<event name="object_created" package="sqlserver" timestamp="2015-03-09T08:20:17.552Z">
<data name="database_id">
<type name="uint32" package="package0" />
<value>41</value>
</data>
<data name="object_id">
<type name="int32" package="package0" />
<value>933578364</value>
</data>
<data name="object_type">
<type name="object_type" package="sqlserver" />
<value>8277</value>
<text>USRTAB</text>
</data>
<data name="index_id">
<type name="uint32" package="package0" />
<value>0</value>
</data>
<data name="related_object_id">
<type name="int32" package="package0" />
<value>0</value>
</data>
<data name="ddl_phase">
<type name="ddl_opcode" package="sqlserver" />
<value>1</value>
<text>Commit</text>
</data>
<data name="transaction_id">
<type name="int64" package="package0" />
<value>284364642</value>
</data>
<data name="object_name">
<type name="unicode_string" package="package0" />
<value>DUMMY</value>
</data>
<data name="database_name">
<type name="unicode_string" package="package0" />
<value />
</data>
<action name="cpu_id" package="sqlos">
<type name="uint32" package="package0" />
<value>0</value>
</action>
<action name="task_time" package="sqlos">
<type name="uint64" package="package0" />
<value>14322583</value>
</action>
<action name="client_app_name" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>Microsoft SQL Server Management Studio - Query</value>
</action>
<action name="client_hostname" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>VDDBARY</value>
</action>
<action name="database_name" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>TEST_R_D</value>
</action>
<action name="nt_username" package="sqlserver">
<type name="unicode_string" package="package0" />
<value />
</action>
<action name="server_instance_name" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>SQLDEV01</value>
</action>
<action name="server_principal_name" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>ryelug01</value>
</action>
<action name="session_id" package="sqlserver">
<type name="uint16" package="package0" />
<value>99</value>
</action>
<action name="session_nt_username" package="sqlserver">
<type name="unicode_string" package="package0" />
<value />
</action>
<action name="session_resource_group_id" package="sqlserver">
<type name="uint32" package="package0" />
<value>2</value>
</action>
<action name="sql_text" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>USE TEST_R_d
CREATE TABLE DUMMY
id int not null
)</value>
</action>
<action name="username" package="sqlserver">
<type name="unicode_string" package="package0" />
<value>ryelug01</value>
</action>
</event>
</RingBufferTarget>
Rajkumar Yelugu

Thanks for the link Visakh !
It helps me getting  started , I applied few tips on to my ongoing stored proc ( Below ) but not a great improvement though  , Thanks for your further assistance .
CREATE TABLE #XML_Hold
ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY , -- PK necessity for Indexing on XML Col
BufferXml XML
INSERT INTO #XML_Hold (BufferXml)
SELECT
CAST(target_data AS XML) AS TargetData --BufferXml
FROM sys.dm_xe_session_targets xet
INNER JOIN sys.dm_xe_sessions xes
ON xes.address = xet.event_session_address
WHERE xes.name = 'Capture DDL Schema Changes'
--RETURN
SELECT GETDATE() AS GETDATE_1
CREATE PRIMARY XML INDEX [IX_XML_Hold] ON #XML_Hold(BufferXml) -- Ryelugu 03/09/2015 - Primary Index
SELECT GETDATE() AS GETDATE_2
--create secondary xml value index
CREATE XML INDEX [IX_XML_Hold_values] ON #XML_Hold(BufferXml)
USING XML INDEX [IX_XML_Hold]
FOR VALUE
SELECT GETDATE() AS GETDATE_3
SELECT
p.q.value('@name[1]','varchar(100)') AS eventname,
p.q.value('@timestamp[1]','datetime') AS timestampvalue,
p.q.value('(./data[@name="object_name"]/value)[1]','varchar(100)') AS objectname,
p.q.value('(./data[@name="object_type"]/text)[1]','varchar(100)') AS ObjectType,
p.q.value('(./action[@name="database_name"]/value)[1]','varchar(100)') AS databasename,
p.q.value('(./data[@name="ddl_phase"]/text)[1]','varchar(100)') AS ddl_phase,
p.q.value('(./action[@name="client_app_name"]/value)[1]','varchar(100)') AS clientappname,
p.q.value('(./action[@name="client_hostname"]/value)[1]','varchar(100)') AS clienthostname,
p.q.value('(./action[@name="server_instance_name"]/value)[1]','varchar(100)') AS server_instance_name,
p.q.value('(./action[@name="nt_username"]/value)[1]','varchar(100)') AS nt_username,
p.q.value('(./action[@name="server_principal_name"]/value)[1]','varchar(100)') AS serverprincipalname,
p.q.value('(./action[@name="sql_text"]/value)[1]','Nvarchar(max)') AS sqltext
FROM #XML_Hold
CROSS APPLY BufferXml.nodes('/RingBufferTarget/event')p(q)
WHERE -- Ryelugu 03/05/2015 -
p.q.value('@timestamp[1]','datetime') >= ISNULL(@Prev_Insertion_time ,p.q.value('@timestamp[1]','datetime'))
AND p.q.value('(./data[@name="ddl_phase"]/text)[1]','varchar(100)') ='Commit'
AND p.q.value('(./data[@name="object_type"]/text)[1]','varchar(100)') <> 'STATISTICS'
AND p.q.value('(./data[@name="object_name"]/value)[1]','varchar(100)') NOT LIKE '%#%'
It appears that filtering  and selecting from #XML_Hold  is TIME taking .
Rajkumar Yelugu

Similar Messages

  • Oracle 10.2.0.4 Index on timestamp column not used when SYSTIMESTAMP Used.

    Hi,
    I have a table A with a column B timestamp(6). The tables contains around 300000 rows..
    I have created index 'idx' on the column B.
    When i compare column 'B' with systimestamp, it does not use the index, whereas if i compare 'B' with sysdate it uses the index.
    Eg :
    select count(*) from a where b<=sysdate;
    The above used the index 'idx' and executed in 1 second
    select count(*) from a where b<=systimestamp;
    The above does not use the index and executed in 19 seconds.
    Any Clue?
    Thanks in Advance

    Oracle is using Internal functions when you use SYSTIMESTAMP:
    Work around will be to use TO_TIMESTAMP as shown below.. Or define a function based index..
    You can check performance problem querying against a "TIMESTAMP WITH TIME ZONE" column link also
    SQL> create table a(b timestamp(6));
    Table created.
    SQL> insert into a
      2  select systimestamp+(level/24) from dual connect by level <= 30000;
    30000 rows created.
    SQL> commit;
    Commit complete.
    SQL> create index ndx on a(b);
    Index created.
    SQL> explain plan for
      2  select count(*) from a where b <= sysdate;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3858831102
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    13 |     1   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |      |     1 |    13 |            |          |
    |*  2 |   INDEX RANGE SCAN| NDX  |     1 |    13 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("B"<=SYSDATE@!)
    Note
       - dynamic sampling used for this statement
    18 rows selected.
    SQL> explain plan for
      2  select count(*) from a where b <= systimestamp;
    Explained.
    SQL>  select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3918351354
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |     1 |    13 |    20  (15)| 00:00:01 |
    |   1 |  SORT AGGREGATE    |      |     1 |    13 |            |          |
    |*  2 |   TABLE ACCESS FULL| A    |     1 |    13 |    20  (15)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_EXTRACT_UTC(INTERNAL_FUNCTION("B"))<=SYS_EXTRACT_UTC(S
                  YSTIMESTAMP(6)))
    Note
       - dynamic sampling used for this statement
    19 rows selected.
    --"Just tried using TO_TIMESTAMP"
    SQL> explain plan for
      2  select count(*) from a where b <= to_timestamp(systimestamp);
    Explained.
    SQL>
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3858831102
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    13 |     2   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |      |     1 |    13 |            |          |
    |*  2 |   INDEX RANGE SCAN| NDX  |     4 |    52 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("B"<=TO_TIMESTAMP(TO_CHAR(SYSTIMESTAMP(6))))
    14 rows selected.Edited by: jeneesh on Oct 23, 2012 11:18 AM

  • TopLink 10.1.3.0 and SQL Server 2008 XML datatype

    We use TopLink 10.1.3.0 and SQL Server 2008 database. We are trying to map a table with a column of XML datatype, but the 'Direct to XMLType' Mapping is disabled in the Workbench.
    Is it possible to map an XML datatype? If so, can you please some guidance on how it can be achieved.
    Thanks for the help.
    Edited by: amehta5 on Nov 4, 2010 4:09 PM

    The Direct to XMLType was desired for the Oracle XMLType. TopLink does not currently support it for SQL Server. You could extend the SQLServerPlatform to add you own support. You must also be able to just map it to a String using a DirectToFieldMapping. If the MW does not let you use the mapping, you can add it in a customizer/amendment method.
    FYI: If you are using TopLink 11, you should be using the eclipselink.jar and ideally using JPA, and not using the Mapping Workbench.
    James : http://www.eclipselink.org

  • Creating Indexes within an XMLType column

    Hi,
    I have following XML document stored as XMLType column,
    <ocaStatus xmlns="http://xmlbeans.apache.org/ocastatus"><status><statusCode>934</statusCode><statusDate>Wed Apr 07 16:05:53 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>934</statusCode><statusDate>Wed Apr 07 15:58:25 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>934</statusCode><statusDate>Wed Apr 07 15:54:02 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>750</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Document Metadata is correct.</comment></status><status><statusCode>934</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>932</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Loaded to Novus</comment></status><status><statusCode>700</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Document is deleted from OCA.</comment></status></ocaStatus>
    I created following Indexes within the XML,
    CREATE INDEX "OCA_DEV"."OCA_STATUS_CODE_INDEX" ON "OCA_DEV"."DOCUMENT_STATUS_XML" (EXTRACTVALUE('/ocaStatus/status/statusCode'));
    CREATE INDEX "OCA_DEV"."OCA_STATUS_DATE_INDEX" ON "OCA_DEV"."DOCUMENT_STATUS_XML" (EXTRACTVALUE('/ocaStatus/status/statusDate'));
    However the problem is that I will be having multiple status within each XML which violates the Indexing.
    Is there any way I can still create the Indexes allowing multiple status values in each XML?
    Thanks in advance.

    Hi,
    You may want to store your document as a schema-based, object-relational XMLType to achieve that.
    Then you'll be able to create indexes on the nested table used to store each "status" element.
    Here's an example based on your sample document.
    1) First, create and register a schema. The following is basic but sufficient here, let's call it "ocastatus.xsd" :
    <?xml version="1.0"?>
    <xsd:schema
    targetNamespace="http://xmlbeans.apache.org/ocastatus"
    xmlns="http://xmlbeans.apache.org/ocastatus"
    elementFormDefault="qualified"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xdb="http://xmlns.oracle.com/xdb">
    <xsd:element name="ocaStatus" type="OCASTATUS_TYPEType"/>
    <xsd:complexType name="OCASTATUS_TYPEType" xdb:SQLType="OCASTATUS_TYPE">
      <xsd:sequence>
       <xsd:element name="status" type="STATUS_TYPEType" xdb:SQLName="status" maxOccurs="unbounded" xdb:SQLCollType="STATUS_V"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="STATUS_TYPEType" xdb:SQLType="STATUS_TYPE">
      <xsd:sequence>
       <xsd:element name="statusCode" type="xsd:double" xdb:SQLName="statusCode" xdb:SQLType="NUMBER"/>
       <xsd:element name="statusDate" xdb:SQLName="statusDate" xdb:SQLType="VARCHAR2">
        <xsd:simpleType>
         <xsd:restriction base="xsd:string">
          <xsd:maxLength value="50"/>
         </xsd:restriction>
        </xsd:simpleType>
       </xsd:element>
       <xsd:element name="userId" xdb:SQLName="userId" xdb:SQLType="VARCHAR2">
        <xsd:simpleType>
         <xsd:restriction base="xsd:string">
          <xsd:maxLength value="50"/>
         </xsd:restriction>
        </xsd:simpleType>
       </xsd:element>
       <xsd:element name="comment" xdb:SQLName="comment" xdb:SQLType="VARCHAR2">
        <xsd:simpleType>
         <xsd:restriction base="xsd:string">
          <xsd:maxLength value="100"/>
         </xsd:restriction>
        </xsd:simpleType>
       </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>Registering...
    BEGIN
    dbms_xmlschema.registerSchema(
      schemaURL => 'ocastatus.xsd',
      schemaDoc => xmltype(bfilename('XSD_DIR','ocastatus.xsd'), nls_charset_id('AL32UTF8')),
      genTypes => true,
      genTables => false
    END;2) Table definition :
    CREATE TABLE oca_status (
      num NUMBER,
      doc XMLTYPE
      XMLTYPE doc STORE AS OBJECT RELATIONAL
       XMLSCHEMA "ocastatus.xsd"
       ELEMENT "ocaStatus"
       VARRAY doc.xmldata."status" STORE AS TABLE oca_status_tab
    CREATE INDEX oca_status_tab_idx1 ON oca_status_tab("statusCode");
    CREATE INDEX oca_status_tab_idx2 ON oca_status_tab("statusDate");3) Inserting document...
    INSERT INTO oca_status (num, doc)
    VALUES(1, xmltype('<ocaStatus xmlns="http://xmlbeans.apache.org/ocastatus">
      <status>
        <statusCode>934</statusCode>
        <statusDate>Wed Apr 07 16:05:53 GMT+05:30 2010</statusDate>
        <userId>u0121845</userId>
        <comment>Sent to LTC</comment>
      </status>
      <status>
        <statusCode>934</statusCode>
        <statusDate>Wed Apr 07 15:58:25 GMT+05:30 2010</statusDate>
        <userId>u0121845</userId>
        <comment>Sent to LTC</comment>
      </status>
      <status>
        <statusCode>934</statusCode>
        <statusDate>Wed Apr 07 15:54:02 GMT+05:30 2010</statusDate>
        <userId>u0121845</userId>
        <comment>Sent to LTC</comment>
      </status>
      <status>
        <statusCode>750</statusCode>
        <statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
        <userId>u0121845</userId>
        <comment>Document Metadata is correct.</comment>
      </status>
      <status>
        <statusCode>934</statusCode>
        <statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
        <userId>u0121845</userId>
        <comment>Sent to LTC</comment>
      </status>
      <status>
        <statusCode>932</statusCode>
        <statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
        <userId>u0121845</userId>
        <comment>Loaded to Novus</comment>
      </status>
      <status>
        <statusCode>700</statusCode>
        <statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
        <userId>u0121845</userId>
        <comment>Document is deleted from OCA.</comment>
      </status>
    </ocaStatus>')
    );Verifying index use (XPath rewrite) ...
    SQL> EXPLAIN PLAN FOR
      2  SELECT * from oca_status x
      3  WHERE existsnode(x.doc, '//status[statusCode="934"]') = 1;
    Explicité.
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1840289382
    | Id  | Operation                     | Name                | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |                     |     1 |  7938 |     4  (25)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL            | OCA_STATUS_TAB      |     1 |  2145 |     4   (0)| 00:00:01 |
    |   2 |  NESTED LOOPS                 |                     |     1 |  7938 |     4  (25)| 00:00:01 |
    |   3 |   SORT UNIQUE                 |                     |     4 |  8580 |     2   (0)| 00:00:01 |
    |   4 |    TABLE ACCESS BY INDEX ROWID| OCA_STATUS_TAB      |     4 |  8580 |     2   (0)| 00:00:01 |
    |*  5 |     INDEX RANGE SCAN          | OCA_STATUS_TAB_IDX1 |     4 |       |     1   (0)| 00:00:01 |
    |   6 |   TABLE ACCESS BY INDEX ROWID | OCA_STATUS          |     1 |  5793 |     1   (0)| 00:00:01 |
    |*  7 |    INDEX UNIQUE SCAN          | SYS_C00243981       |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("NESTED_TABLE_ID"=:B1)
       5 - access("statusCode"=934)
       7 - access("NESTED_TABLE_ID"="X"."SYS_NC0000900010$")
    Note
       - dynamic sampling used for this statement
    25 ligne(s) sélectionnée(s).
    SQL> Regards.

  • Compare date datatype against timestamp column

    Hi,
    I have a table "test" with a TIMESTAMP column as "insert_timestamp".
    I have an application with a query like
    select * from test where insert_timestamp between i_start_date and i_end_date;i_start_date and i_end_date are DATE data type variables.
    When I ran this query, it returned results:
       select * from test where insert_timestamp between sysdate - 1 and sysdate;My question is if it is ok to compare against a TIMESTAMP column in table using DATE data type variables?.
    I am just making sure the app doesn't break during execution due to this.
    Thanks in advance

    yes you can use...
    But with timestamp you get precision till fraction of seconds but not in case of data type...
    So if you have data which differ in fraction of seconds like
    1.0001 sec,1.0003 sec,1.0004 sec,1.0005 sec,1.0006 sec...
    then if i have to get data between 1.0003 and 1.0005 seconds you cannot use a date variable here...
    Ravi Kumar

  • XML Datatypes in Oracle 9i

    My database architect would like to leverage the XML datatype support that is new in Oracle 9i. How can I configure TopLink to directly map object attributes to elements in an XML structure that is stored in an XML-type column?

    Marc,
    Yes. It is possible to map XMLType columns into your object model. It is accomplished using a direct-to-field mapping where the database column is an XMLType and the object model's attribute is a Document or String. In 9.0.3 of Oracle9iAS TopLink you must include the xdb.jar on your classpath, customize your configuration with an extended ConversionManager, and use a DescriptorEventListener.
    ConversionManager: Subclass the provided one and provide a conversion from XMLType to either the underlying DOM Document or XML representation of the string.
    DescriptorEventListener: Implement and register an event listener that will provide aboutToInsert and aboutToUpdate events for the class you are mapping the XML into. In these events you'll need to make use of the provided JDBC connection to convert the Document or String back into an XMLType object. (NOTE: If using Strings I believe you must use Oracle's XML parser to re-build the Document)
    A more detail technical tip will be availble soon and will be available through TopLink's OTN page (http://otn.oracle.com/products/ias/toplink/).
    Doug Clarke
    Product Manager
    Oracle9iAS TopLink

  • ORDER BY timestamp column as a string

    Does any one have any tips/tricks for using an ORDER BY clause for a timestamp column that is a string?
    I am developing a UNION query that combines data from a table and an audit history table to show current data plus historical data.
    I had to convert the timestamp column to a string so the datatypes would match for the UNION query, but now they ORDER BY clause does not work.
    For example:
    SELECT
    location,
    'CURRENT' as VALID_DATE
    FROM
    person
    UNION
    SELECT
    location,
    TO_CHAR(audit_date)
    FROM
    person_audit
    ORDER BY 2 DESC

    Hi,
    user2269823 wrote:
    Using the 'yyyy-mm-dd' format works pretty well when ordering by the string. It looks like when ordering by a string Oracle just looks at the characters sequentially.
    For example:
    2009-1-14
    2008-12-31
    2007-6-6Looks like you have changed the format slightly?
    Consider this
    SQL> select TO_CHAR(sysdate,'FMyyyy-mm-dd')
          , TO_CHAR(sysdate, 'yyyy-mm-dd') from dual;
    TO_CHAR(SY TO_CHAR(SY
    2009-5-28  2009-05-28
    SQL>Looks fine with me, as long as you don't have the FM format model modifer.
    Regards
    Peter

  • XML Datatype as transaction output property

    Hello everyone,
    I'm having some problems while using the XML datatype as an output for a transaction and would like your input on this.
    I've created a transaction that has one output property set as a XML. This transaction reads information from a SAP BAPI call and I assigns the response XML to the output parameter. I've checked the output value with a trace block and it is ok.
    This transaction is called from within another transaction, but when I read the output parameter after the transaction block is executed, the output parameter is empty...
    The only work-around this problem that I have found it to encode the XML as a string and then decode it in the outer transaction, but that just doesn't seem like the right thing to do... There must be a reason to have a XML datatype!
    Thanks in advance,
    Marcelo

    Marcelo,
    I too tried this on 12.1.8 build 20 and this seems to be working for me.
    Here's what I did, I am calling BAPI_ALM_ORDER_DETAIL in the "called" transaction. This has an output property called "outXML" of type XML.
    I assign the response of the BAPI to outXML after the BAPI is executed.
    I tried a tracer here and all's well.
    In the "calling" transaction I have a tracer after the Transaction call where  am able to see the respose from the called transaction.
    Thanks
    Udayan

  • How to compare index names and columns from different user?

    I am using below query to compare two indexes from 2 different users but even though index name and columns are same... result shows me they are different.. what I am doing wrong? Thanks
    WITH t AS
            (SELECT COUNT (DISTINCT index_owner || index_name || indexed_cols)
                       cnt
               FROM (  SELECT index_owner,
                              index_name,
                              listagg (column_name, ',')
                                 WITHIN GROUP (ORDER BY column_position)
                                 indexed_cols
                         FROM dba_ind_columns
                        WHERE index_name='XPKTBL_A'
                     GROUP BY index_owner, index_name))
    SELECT CASE
              WHEN cnt > 1 THEN 'Indexes are different'
              WHEN cnt = 0 THEN 'Indexes dont exist'
              WHEN cnt > 1 THEN 'Indexes are identical'
           END
              commnt
      FROM t
    Result:
    Indexes are different
    but Actually if you check below they are same After when I run this query:
    SELECT index_owner,
             index_name,
             listagg (column_name, ',') WITHIN GROUP (ORDER BY column_position)
                indexed_cols
        FROM dba_ind_columns
       WHERE index_name='XPKTBL_A'
    GROUP BY index_owner, index_name;
    Result:
    Index_owner
    Index_name
    Index_cols
    USER1
    XPKTBL_A
    FIELD_A1
    USER2
    XPKTBL_A
    FIELD_A1

    Hi,
    Erhan_toronto wrote:
    I am using below query to compare two indexes from 2 different users but even though index name and columns are same... result shows me they are different.. what I am doing wrong? Thanks
    WITH t AS
            (SELECT COUNT (DISTINCT index_owner || index_name || indexed_cols)
    So index_owner is 'USER1' in one case, and 'USER2' in the other; right?
    A string that starts with 'USER1' will be distinct from a string that starts with 'USER2', no matter what the rest of the string contains.  Maybe you don't want to compare the owners, or maybe you meant to use some other column (such as table_name) instead of index_owner).
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE, CREATE INDEX and CONNECT statements), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to create index on xmltype column

    I have a table having only one column xmlcontent (xmltype). This table stores xml data of about 10GB size. I'm using extract value to move the data to staging tables.
    How can I create index on xmltype column?
    Create index indexname on table (column) doesn't seem to work.
    Sample xmlstructure is given below
    <Root>
    <Type>Insert</Type>
    <Date>2006-12-29</Date>
    <Source>8</Source>
    <id>data</id>
    <key_flds>
    <fld><id>Key1</id><val>C</val></fld>
    <fld><id>Key2</id><val>429672</val></fld>
    <fld><id>Key3</id><val>8</val></fld>
    </key_flds>
    </Root>
    I need to do extract value on all tags and move them to corresponding relational tables.

    Hi, you need to create them using something like this (what I have used and work rather well - if I did not load the xml into an xml table, the processing took about 10 minutes, while the indexed xml table took just a few seconds). statute_xml is the table name and sxmldoc is the xml column/field.
    create index desc_idx on statute_xml
    (sxmldoc.existsNode('/SimpleTypeCompanion/EnumerationValue/@description'))
    create index sid_idx on statute_xml
    (sxmldoc.existsNode
    ('/SimpleTypeCompanion/EnumerationValue/Text')
    create index effdate_idx on statute_xml
    (sxmldoc.existsNode
    ('/SimpleTypeCompanion/EnumerationValue/@effectiveDate')
    Hope this helps.
    Ben

  • How to append the timestamp in log4j.xml

    Hi,
    Has anybody know how to configure the timestamp in log4j.xml??
    It would be great, if you could update the right parameter name in my log4.xml which appears below to display timestamp in my log file Master.log!
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration
      xmlns:log4j="http://jakarta.apache.org/log4j/">
      <!-- Order of child elements is appender*, logger*, root?. -->
      <!-- Appenders control how logging is output. -->
      <appender name="CM" class="org.apache.log4j.FileAppender">
         <param name="File" value="Master.log"/>
         <param name="Threshold" value="DEBUG"/>
         <param name="Append" value="true"/>
         <param name="MaxFileSize" value="1MB"/>
         <param name="MaxBackupIndex" value="1"/>
        <layout class="org.apache.log4j.PatternLayout">
          <!-- {fully-qualified-class-name}:{method-name}:{line-number}
                - {message}{newline} -->
          <param name="ConversionPattern" value="%C:%M:%L - %m%n"/>
        </layout>     
      </appender>
      <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <param name="Threshold" value="INFO"/>
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%C:%M:%L - %m%n"/>
        </layout>
      </appender>
      <!-- Logger hierarchy example:
           root - com - com.ociweb - com.ociweb.demo - com.ociweb.demo.LogJDemo
      -->
      <!-- Setting additivity to false prevents ancestor categories
           for being used in addition to this one. -->
      <logger name="com.tf" additivity="true">
        <priority value="DEBUG"/>
        <appender-ref ref="CM"/>
      </logger>
      <!-- Levels from lowest to highest are
           trace, debug, info, warn, error, fatal & off. -->
      <!-- The root category is used for all loggers
           unless a more specific logger matches. -->
      <root>
        <appender-ref ref="stdout"/>
      </root>
    </log4j:configuration>

    Hello Sir,
    I have configured Log4j.xml for my project and it is able to generate the log file properly with the timestamp,but it is showing the the following error messaged at weblogic console!
    log4j:ERROR Parsing error on line 3 and column 8
    log4j:ERROR Element type "log4j" must be declared.
    log4j:ERROR Parsing error on line 15 and column 13
    log4j:ERROR The content of element type "appender" must match "(errorHandler?,param*,layout?,filter*,appender-ref*)".
    log4j:ERROR Parsing error on line 16 and column 57
    log4j:ERROR Attribute "priority" must be declared for element type "category".
    log4j:ERROR Parsing error on line 19 and column 25
    log4j:ERROR Attribute "priority" must be declared for element type "root".log4j:ERROR Parsing error on line 39 and column 12
    log4j:ERROR The content of element type "logger" must match "(level?,appender-ref*)".
    log4j:WARN No such property [maxFileSize] in org.apache.log4j.DailyRollingFileAppender.
    log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.DailyRollingFileAppender.
    Here is my Log4j.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration
    xmlns:log4j="http://jakarta.apache.org/log4j/">
    <!-- Order of child elements is appender*, logger*, root?. -->
    <!-- Appenders control how logging is output. -->
    <appender name="CM" class="org.apache.log4j.DailyRollingFileAppender">
         <param name="File" value="Customer_Master.log"/>
         <param name="Threshold" value="DEBUG"/>
         <param name="Append" value="false"/>
         <param name="DatePattern" value="'.'yyyy-MM-dd"/>
         <param name="MaxFileSize" value="1MB"/>
         <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
    <!-- {fully-qualified-class-name}:{method-name}:{line-number}
    - {message}{newline} -->
    <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
    </layout>
    </appender>
    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
    <param name="Threshold" value="INFO"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%C:%M:%L - %m%n"/>
    </layout>
    </appender>
    <!-- Logger hierarchy example:
    root - com - com.ociweb - com.ociweb.demo - com.ociweb.demo.LogJDemo
    -->
    <!-- Setting additivity to false prevents ancestor categories
    for being used in addition to this one. -->
    <logger name="com.tf" additivity="true">
    <priority value="DEBUG"/>
    <appender-ref ref="CM"/>
    </logger>
    <!-- Levels from lowest to highest are
    trace, debug, info, warn, error, fatal & off. -->
    <!-- The root category is used for all loggers
    unless a more specific logger matches. -->
    <root>
    <appender-ref ref="stdout"/>
    </root>
    </log4j:configuration>
    It would be great,if you could correct the above xml file and avoid getting the error message from Weblogic console.
    Thanks in advance,
    kumar

  • Searching CLOB column of XML documents with leading wildcard - Performance

    Hi, our table has a text indexed CLOB column of XML documents and when performing a search with a leading wild card, we never retrieve any results.
    The query looks like this:
    select id from <table> where contains(columnname, '(%12345)') > 0;
    I cant even generate an explain plan from this query. I killed it after 39 minutes.
    If the query changes to:
    select id from <table> where contains(columnname, '(12345%)') > 0;
    I get an explain plan immediately with a cost=2 and when I execute the query, I get results in less than a second.
    I'd appreciate any thoughts of what I should check or what the problem might be.
    Thanks! Doug

    Can you provide a script that reproduces the case. I am unable to reproduce the problem with just some small sample data, as shown below. That means that there is nothing wrong with the syntax, but you may be having problems due to the size of your data or other parameters that have not been mentioned.
    SCOTT@10gXE> CREATE TABLE your_table (id NUMBER, columnname CLOB)
      2  /
    Table created.
    SCOTT@10gXE> insert into your_table
      2  select 1, dbms_xmlgen.getxml
      3             ('select deptno, dname,
      4                   cursor (select empno, ename
      5                        from      emp
      6                        where  emp.deptno = dept.deptno ) employee
      7               from   dept
      8               where  deptno = 10')
      9  from   dual
    10  /
    1 row created.
    SCOTT@10gXE> SELECT * FROM your_table
      2  /
            ID COLUMNNAME
             1 <?xml version="1.0"?>
               <ROWSET>
                <ROW>
                 <DEPTNO>10</DEPTNO>
                 <DNAME>ACCOUNTING</DNAME>
                 <EMPLOYEE>
                  <EMPLOYEE_ROW>
                   <EMPNO>7782</EMPNO>
                   <ENAME>CLARK</ENAME>
                  </EMPLOYEE_ROW>
                  <EMPLOYEE_ROW>
                   <EMPNO>7839</EMPNO>
                   <ENAME>KING</ENAME>
                  </EMPLOYEE_ROW>
                  <EMPLOYEE_ROW>
                   <EMPNO>7934</EMPNO>
                   <ENAME>MILLER</ENAME>
                  </EMPLOYEE_ROW>
                 </EMPLOYEE>
                </ROW>
               </ROWSET>
    SCOTT@10gXE> CREATE INDEX your_idx ON your_table (columnname)
      2  INDEXTYPE IS CTXSYS.CONTEXT
      3  /
    Index created.
    SCOTT@10gXE> EXEC DBMS_STATS.GATHER_TABLE_STATS ('SCOTT', 'YOUR_TABLE')
    PL/SQL procedure successfully completed.
    SCOTT@10gXE> SET AUTOTRACE ON EXPLAIN
    SCOTT@10gXE> select id from your_table where contains (columnname, '(%839)') > 0
      2  /
            ID
             1
    Execution Plan
    Plan hash value: 2832585188
    | Id  | Operation                   | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |            |     1 |   888 |     0   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| YOUR_TABLE |     1 |   888 |     0   (0)| 00:00:01 |
    |*  2 |   DOMAIN INDEX              | YOUR_IDX   |       |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("CTXSYS"."CONTAINS"("COLUMNNAME",'(%839)')>0)
    SCOTT@10gXE> SET AUTOTRACE OFF

  • [JS] Simple question: Is importing XML from variable of XML datatype still not possible?

    Hi,
    Am I correct assuming that there is still no way to import XML into an XML element, directly from a variable of data-type XML?
    Will I still need to save data to disk, just to be able get it into the XML structure?
    Thanks,
    Andreas

    I totally agree. I look for this improvement once in a while, when I do changes and improvements in my code. I hoped I just hadn't noticed some other way to do it "in memory". It seems very unnecessary with this disk access.
    I filed a feature request at https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform.
    Perhaps more people wish for the same... and evntually the XML import functions will be able to handle an XML datatype object as argument.
    Best regards,
    Andreas

  • Timestamp column  when reversed in ODI ,Logical Length increases to 11

    Hi
    I have a Timestamp Column in Oracle Database. When i see in SQL Developer
    I see DataType: Timestamp(6),But when I reverse in ODI the Logical length Increases
    to 11 and this gives an error when I execute my interface.
    Like that I have Many timestamp column in my project and for the Interface to work
    I have to manually decrease the length from 11 to 6,then it works fine.
    Is there any workaround.
    Thanks in Advance.

    Hi,
    Trying to help you. :-)
    Try to use Datatypes options in ODI. Go to Topology mgr->Physical Arch, elapse Oracle and just play around Data types (try to create a datatype for timestamp or else edit the existing one)and give TIMESTAMP(%L).
    May be you can find a solution.
    All the Best.:)

  • How much space a Date , time , TimeStamp column occupy?

    Hi
    what is size of a Date , Time and TimeStamp type ?
    i mean how much bytes they require ?
    Thanks

    Apologies if this posts more than once. I got server errors.
    Laurent:
    Sysdate and systimestamp are actually different types than a date or timestamp column.
    SQL> CREATE TABLE dt (dt DATE, ts TIMESTAMP);
    Table created.
    SQL> INSERT INTO dt VALUES(sysdate, systimestamp);
    1 row created.
    SQL> COMMIT;
    Commit complete.
    DUMP(DT)
    Typ=12 Len=7: 120,106,6,2,17,43,10
    SQL> SELECT DUMP(ts) FROM dt;
    DUMP(TS)
    Typ=180 Len=11: 120,106,6,2,17,43,10,28,185,249,48
    SQL> SELECT DUMP(sysdate) from dual;
    DUMP(SYSDATE)
    Typ=13 Len=8: 7,214,6,2,16,50,17,0
    SQL> SELECT DUMP(systimestamp) from dual;
    DUMP(SYSTIMESTAMP)
    Typ=188 Len=20: 7,214,6,2,20,50,30,0,48,111,78,168,252,0,5,0,0,0,0,0I seem to recall reading somewhere that sysdate is actually a representation of the C struct_t time structure, while a date column is Oracle's internal format. It looks like something similar is going on with systimestamp, and with the date and timestamp casts you are doing.
    The inserts into the table above were done minutes before the selects, but definitely within the same hour. The byte values have no correlation, between the date field and sysdate, nor between the timestamp field and systimestamp, while the the date and timestamp fields are identical to the second. Similarly, the sysdate and systimestamp dumps are identical to the second.
    The vsize function reports the physical storage required for the expression passed. My guess would be that it is implicitly casting sysdate and systimestamp to the equivalent internal representation before calculating the size.
    John

Maybe you are looking for

  • Display trouble in IE

    Hello All, I have a problem with how my website displays in IE that doesn't occur in any other browser that I've tested it in, either on Mac (my platform) or Windows. I have a header in each of my pages build with a single table with some imbedded im

  • Problem with AIX 5.1 JDK1.4 WLS 8.1.2

    I am getting "No LoginModules configured " after upgrading to WLS 8. My application can work under WLS 7 (AIX and NT) and WLS 8 ( NT only ). I have tried to force my own security policy but it still does not work. Attached with this email are all the

  • Almost a year ago...Safari still can't do Yahoo News Video

    I posted a note almost a year ago trying to get help on getting Safari to play news video from Yahoo. Well looks like Safari hasn't improved much. I tried viewing this news video from Yahoo and nothing play. Has anyone had any luck whatsover to get n

  • Difficulty importing from iPhone 3GS

    Forgive me if this is a repeated topic... I have a first-gen MacBook Pro, running iPhoto 6 and OS 10.6.6. Anytime I try to import photos from my iPhone 3GS (running OS 4.2), iPhoto will import a few pictures and then freeze and not import any more. I

  • CAn EJB do persistance without hibernate?

    Hai All..... My doubt is that 'Can EJB do persistance without hibernate or any other tools'? Can EJB do persistance alone?? Please Help