ORACLE9I - INTERVAL DATA TYPE

제품 : SQL*PLUS
작성날짜 : 2004-05-28
ORACLE9I - INTERVAL DATA TYPE
=============================
PURPOSE
Oracle9i 부터 추가된 INTERVAL data type에 대해 알아보자.
Explanation
INTERVAL data type은 datetime 기간을 저장하는 type이다.
아래의 syntax를 확인해 보자.
INTERVAL <interval qualifier>
Examples:
INTERVAL YEAR TO MONTH
INTERVAL DAY (6) TO SECOND (5)
INTERVAL type에는 다음의 두 가지 종류가 있다.
1. Year-month interval (INTERVAL YEAR TO MONTH)
연과 월의 기간을 저장하는 type으로 각각 연수,월수를 나타낸다.
Keyword Meaning
YEAR Years
MONTH Months
2. Day-time interval (INTERVAL DAY TO SECOND)
각 DAY, HOUR, MINUTE, and SECOND 를 저장하는 type으로 일반적으로
사용하는 date format으로 저장한다.
Keyword Meaning
DAY Days
HOUR Hours
MINUTE Minutes
SECOND Seconds and possibly fractions of a second
이 type은 생성할 때 각 day와 second의 자리수를 지정해야 한다.
default 로는 day(2), second (6) 으로 지정된다.
Year-month interval type은 다른 type과 함께 비교할 때 다른 data의 각 year, month
와 비교되며, day-time interval의 경우에도 다른 type의 day-time 값과만 비교된다.
3. INTERVAL item의 valid value.
Keyword Valid values
YEAR Unconstrained except by <interval leading field precision>
MONTH 0..11
DAY Unconstrained except by <interval leading field precision>
HOUR 0..23
MINUTE 0..59
SECOND 0..59.9(N) where "9(N)" indicates the number of digits
specified by <interval fractional seconds
precision> in the <interval qualifier>
4. Interval data type의 sample value.
Data type Literal Example
INTERVAL YEAR TO MONTH INTERVAL '01-02' YEAR TO MONTH
INTERVAL DAY(3) TO SECOND(2) INTERVAL '100 10:20:42.22' DAY(3) TO SECOND(2)
Examples
1. sample table생성후 data입력
create table demo_interval ( a INTERVAL YEAR(2) TO MONTH,
b INTERVAL DAY(2) TO SECOND(6));
insert into demo_interval values(INTERVAL'12-01' YEAR TO MONTH,
INTERVAL'50 10:20:20.123' DAY(2) TO SECOND(3));
commit;
SQL> select * from demo_interval;
A B
+12-01 +50 10:20:20.123000
2. 다른 date type의 data와 이 interval type의 data를 더하거나 계산하여 나타낼 수 있다.
SQL> select sysdate, sysdate+a, sysdate+b from demo_interval;
SYSDATE SYSDATE+A SYSDATE+B
2004-05-12 00:11:46 2016-06-12 00:11:46 2004-07-01 10:32:06
Reference Documents
<Note:149118.1>

Nothing could be simpler:
declare
v_interval interval day to second;
begin
v_interval := interval '0' hour;
dbms_output.put_line(v_interval);
end;

Similar Messages

  • Interval data types ODBC driver support

    I have tried both Oracle 10.02.00.03 and Oracle 11.01.00.06 ODBC drivers to get resultset description for interval data type columns with no success. Example,
    CREATE TABLE TEST_INTERVAL
    "COL1" INTERVAL YEAR (2) TO MONTH,
    "COL2" INTERVAL YEAR (1) TO MONTH,
    "COL3" INTERVAL DAY (2) TO SECOND (6),
    "COL4" INTERVAL DAY (0) TO SECOND (0)
    and in an ODBC client like CompareData or WinSQL attempt to retrieve the resultset description for 'select * from test_interval' using SQLColAttribute and SQL_DESC_CONCISE_TYPE, SQL_DESC_LABEL, SQL_DESC_AUTO_UNIQUE_VALUE, etc and get all errors.
    Seems Oracle ODBC drivers do not know how to handle interval data types eventhough ODBC api provides the necessary framework for handling interval data [http://msdn.microsoft.com/en-us/library/ms716506(VS.85).aspx]
    (For example, Informix ODBC driver, Mimer SQL ODBC driver provide complete support for their DBMS interval data types via ODBC)

    Perhaps you ask in the wrong forum? It doesn't seem to be a 'Database - General' question:
    ODBC
    Werner

  • Initializing INTERVAL data type

    I have a situation in which I want to keep track of the amount of time it takes to perform a task that it comprised of a number of steps. I need to get the amount of time to perform each task by subtracting the stop and start times; then these need to be added to a running total to track the total time to perform the task. My PL/SQL code looks something like this:DECLARE
      start TIMESTAMP;
      stop TIMESTAMP;
      task_time INTERVAL DAY TO SECOND;
      total_time INTERVAL DAY TO SECOND;
    BEGIN
      total_time := <an initial value (0)>;      -- How is this done?
      FOR i IN 1 .. <some upper limit> LOOP
        start := <some date and time>;
        stop := <some other date and time later than start>;
        task_time := stop - start;    -- Subtracting TIMESTAMPs results in an INTERVAL data type
        total_time := total_time + task_time;    -- Adding two INTERVALS results in an INTERVAL data type
      END LOOP;
    END;My question, as noted in the code is how do you initialize an INTERVAL data type?
    I have tried "total_time := 0" but I get a compile error because the types are not compatible. I have also tried setting it to "TO_DATE('00:00','hh24:mi')" but this also results in a type compatibility issue.
    Should I be approaching the problem in another way completely?

    Nothing could be simpler:
    declare
    v_interval interval day to second;
    begin
    v_interval := interval '0' hour;
    dbms_output.put_line(v_interval);
    end;

  • Problem when summery the data type of interval day to second

    hi
    i write a program calculate periods of time and summary it then i used interval day to second data type
    oracle support basic 4 math operation (+,-,*,/) on interval
    but although oracle does not support summary function like sum() ,avg(),count()!! this is a problem here
    the walkaround it by use oracle data cartdrage advanced future like follows steps :
    *1- i create type and i call it for ex: DAY_TO_SECOND_SUM_TYPE*
    CREATE OR REPLACE  DAY_TO_SECOND_SUM_TYPE    /*TYPE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        as object
    +(TOTAL INTERVAL day to SECOND , /* type header*/+
    STATIC FUNCTION ODCIAggregateInitialize(SCTX IN OUT DAY_TO_SECOND_SUM_TYPE) return number,
    member function ODCIAggregateIterate( self in out DAY_TO_SECOND_SUM_TYPE,value in interval  day to second) return number,
    member function ODCIAggregateTerminate(self in DAY_TO_SECOND_SUM_TYPE,returnvalue out interval day to second , flags in number) return number,
    member function ODCIAggregateMerge(self in out DAY_TO_SECOND_SUM_TYPE,ctx2 in DAY_TO_SECOND_SUM_TYPE) return number
    +)+
    +/+
    CREATE OR REPLACE TYPE "DAY_TO_SECOND_SUM_TYPE"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            as object
    +(TOTAL INTERVAL day to SECOND ,+
    STATIC FUNCTION ODCIAggregateInitialize(SCTX IN OUT DAY_TO_SECOND_SUM_TYPE) return number,
    member function ODCIAggregateIterate( self in out DAY_TO_SECOND_SUM_TYPE,value in interval  day to second) return number,
    member function ODCIAggregateTerminate(self in DAY_TO_SECOND_SUM_TYPE,returnvalue out interval day to second , flags in number) return number,
    member function ODCIAggregateMerge(self in out DAY_TO_SECOND_SUM_TYPE,ctx2 in DAY_TO_SECOND_SUM_TYPE) return number
    +)+
    create or replace type body DAY_TO_SECOND_SUM_TYPE as /* type body*/
    static function ODCIAggregateInitialize(sctx in out DAY_TO_SECOND_SUM_TYPE) return number is
    begin
    sctx := DAY_TO_SECOND_SUM_TYPE(numtodsinterval(0,'second'));
    return odciconst.Success;
    end;
    member function ODCIAggregateIterate( self in out DAY_TO_SECOND_SUM_TYPE,value in interval  day to second) return number is
    begin
    self.total := self.total value;+
    return odciconst.Success;
    end ;
    member function ODCIAggregateTerminate(self in DAY_TO_SECOND_SUM_TYPE,returnvalue out interval day to second , flags in number) return number is
    begin
    returnvalue := self.total;
    return odciconst.Success;
    end;
    member function ODCIAggregateMerge(self in out DAY_TO_SECOND_SUM_TYPE,ctx2 in DAY_TO_SECOND_SUM_TYPE) return number is
    begin
    self.total := self.total ctx2.total;+
    return odciconst.Success;
    end;
    end;
    +/+
    *2- i create artificial function to summary using that type let as called for ex: ds_sum as follows :*
    create or replace function ds_sum( input interval day to second   ) return interval day to second
    parallel_enable aggregate
    using DAY_TO_SECOND_SUM_TYPE
    +/+
    at last i used the function to summary intervals and its work so good but when the result of calculated summary value exceed the default precision of interval : INTERVAL DAY(2) TO SECOND(6)
    i get an error :
    ORA-01873 the leading precision of the interval is too small
    Cause: The leading precision of the interval is too small to store the specified
    interval .
    Action: Increase the leading precision of the interval or specify an interval with
    a smaller leading precision
    although i can determine the precision of interval the declaration of the new type to maximum like :
    +...........+
    CREATE OR REPLACE TYPE "DAY_TO_SECOND_SUM_TYPE"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            as object
    +(TOTAL INTERVAL day(9) to SECOND(6) ...........+
    +.......................+
    but the problem remain (in fact the error move from one functions of type to another function )
    due i can't determine the precision of data type when i define function in PL/SQL it is illegal*
    HOW CAN I SOLVE THIS PROBLEM AND BE ABLE TO SUMMARY INTERVAL DATA TYPE WHAT EVER THE RESULT OF SUMMARY IS HUGE
    Edited by: user1193723 on Jun 18, 2009 4:35 AM
    Edited by: user1193723 on Jun 18, 2009 4:36 AM
    Edited by: user1193723 on Jun 18, 2009 4:37 AM
    Edited by: user1193723 on Jun 18, 2009 4:38 AM
    Edited by: user1193723 on Jun 18, 2009 4:38 AM
    Edited by: user1193723 on Jun 18, 2009 4:40 AM

    hi,
    Instead of 'interval day to second' in method declaration use internal datatype 'DSINTERVAL_UNCONSTRAINED'.
    There are more unconstrained types in oracle.
    Bartek

  • Oracle Forms New Features - Your input.  Supporting data types

    I am interested to know IF we were to support any new database types in Oracle Forms 11g, which types would you like supported and why. I'd also like to know if you are currently working around the absence of a database type.
    Please note, this is not any kind of commitment to support new data types in Oracle Forms applications but we are interested to know if there is demand and if so, for what types.
    Thanks
    Grant Ronald
    Oracle Forms Product Management
    p.s lets keep the thread focused on the topic so please don't post technical questions or comments about different new features - if you want to, start a new thread - thanks

    Hi Grant,
    support for the "new" - well they exists since 9iR1 ... 2001 - data types TIMESTAMP, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH LOCAL TIME ZONE, INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND would be very helpful.
    Currently it's not possible to use the Data Block Wizard to create a data block for table/view that contains one of these columns.
    (In Forms Builder 10.1.2.3 it fails with a strange error message ... iewbdbc_oracle_to_id ... C:\forms\101220\src\ie\iewbdb.c:724 ...)
    So, one has to create the data block and the items manually. The items have to be CHARS.
    Then forms is able to fetch and display these columns. The user can edit them as normal.
    A WHEN-VALIDATE-ITEM trigger can be used to make sure that the implicit conversion from CHAR to the "new" datatype works.
    For example, an INTERVAL YEAR TO MONTH column (b):
    declare
      l_invalid_interval exception;
      pragma exception_init(l_invalid_interval, -1867);
      l_invalid_month exception;
      pragma exception_init(l_invalid_month, -1843);
      l_dummy interval year(9) to month;
    begin
      l_dummy := to_yminterval(:block2.b);
    exception
      when l_invalid_interval
      then
        message('invalid interval');
        raise form_trigger_failure;
      when l_invalid_month
      then
        message('invalid month');
        raise form_trigger_failure;
      when others
      then
        message(error_text);
        raise form_trigger_failure;
    end;This nasty trick works for most of the "new" datatypes except with TIMESTAMP WITH TIME ZONE.
    In Forms 10.1.2.3 the following WHEN-VALIDATE-ITEM trigger can (incorrectly!) fail:
    declare
      l_dummy timestamp with time zone;
    begin
      l_dummy := to_timestamp_tz(:block2.a);     
    end;It fails with "ORA-01804: failure to initialize timezone information", if the time zone is not like "-11:00", but like "EUROPE/PARIS". Don't know why...
    If we recode our trigger to make a round-trip to the database, it works:
    declare
      l_dummy timestamp with time zone;
    begin
      select to_timestamp_tz(:block2.a)
      into   l_dummy
      from dual;     
    end;We could avoid these tricks, if Forms (and Reports) would support these type natively.
    Thanks, Michael
    PS: The TIMESTAMP and INTERVAL data types should of course be supported as items, parameters, globals and record groups columns.
    Edited by: michael76 on 25.10.2010 01:14

  • What is the data type for time and what to insert

    Hi there
    i had two attributes in a table called start_time and end_time and i want to insert time into these attrbutes e.g 10:00 and 11:00
    How do i do that
    what is oracle's built-in type for time???
    adn how do i insert values in the table(i.e the format)
    thanks

    There is not Oracle type that has just a time. The DATE and TIMESTAMP data types include both the date and the time (TIMESTAMP has millisecond resolution and has optional timezone support). If what you're really interested is a time interval (i.e. 1 hour), there are some INTERVAL data types.
    You have a lot of options for how to specify dates and timestamps along with format masks.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Oracle's 'Interval day to second' data type in Hibernate

    Hi!
    Has anyone implemented Hibernate access to a column in Oracle using 'Interval day to second' data type?
    I've seen this link while searching Google.
    http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/intervaldaytosec/intervaldaytosecond.html#how1
    But I'm clueless about how to implement it using Hibernate.

    I guess this just worked:
    <property name="sampleTime" type="oracle.sql.INTERVALDS">
                <column name="acct_life_time" sql-type="interval_year_to_month" />
    </property>Edit:
    Uh oh. It works on an empty column. I got this error while trying to access one that's not:
    INFO SerializableType:178 - could not read column value from result set: acct3_7_; could not deserialize
    Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: could not deserialize; nested exception is org.hibernate.type.SerializationException: could not deserialize
    Caused by: org.hibernate.type.SerializationException: could not deserialize

  • Saving result from sp_executesql into a variable and using dynamic column name - getting error "Error converting data type varchar to numeric"

    Im getting an error when running a procedure that includes this code.
    I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
    DECLARE @retval AS DECIMAL(12,2)
    DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
    DECLARE @sqlcmd AS NVARCHAR(150)
    DECLARE @paramdef NVARCHAR(150)
    SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
    SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
    SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
    SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
    --default
    SET @retval = 0.0;
    EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
    SELECT @retval
    DECLARE @return_value DECIMAL(12,2)
    EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
    @SpreadKey = 1,
    @MonthNumber = 4
    SELECT 'Return Value' = @return_value
    Msg 8114, Level 16, State 5, Line 1
    Error converting data type varchar to numeric.

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
    This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
    the shoe size, the phone number or something else at run time of this entity. 
    In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point. 
    Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity. 
    Do you know that SQL is a declarative language? This family of languages does not use local variables! 
    Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.  
    Think about how silly this is: 
     SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
    We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental. 
    We need to see the DDL so we can re-write this mess. Want to fix it or not?
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • As to the data type of the data type of the difference between two date type of datas

    Hi,
    I have a question about the data type of the difference between two date type of datas.
    There are two date type of datas as:
    SSHIPMENTS.RECEIVEDATETIME
    SSHIPMENTS.PROMISEDATETIME
    I try to use the following SQL Script in Oracle SQL*Plus as:
    SELECT CASE
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:00:00.000' THEN 'OnTime'
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    The error message of "Invalid Number" for the '000 01:30:00.000' happens.
    I don't know if the data type of the interval is wrong.
    Many Thanks,
    Cathy

    SELECT CASE
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss')) < '010000' THEN 'OnTime'
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss'))< '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    just try it out..

  • How to access complex data type objects in webdynpro

    Hi
    Need help on the detailed procedure to access the complex data type objects.
    I am importing an external wsdl file, its request and response have complex data type objects , how do i access the same as the values are nested in them.
    The structure of request and response at my end is as below:
    request(I level)
    --complextypeobject(II level)
    requestheader(III level)
    field1
    field2
    request
    --response
    messages
    resp1
    resp2
    Any help would be highly appreciated.
    Thanks and Regards,
    Amar Bhagat Challa.

    here you go
    WS Structure
    Request_MI_PortWellOB_MI_PortWellOB
    |-- MT_PortWellOut
       |--agency ( attr)
       |--user (attr)
       |-- well ( node)
         |-- borehole
         |-- downhole
         |-- interval
         |-- surface
    // code to set complex type
              wdContext.nodeRequest_MI_PortWellOB_MI_PortWellOB().bind(new Request_MI_PortWellOB_MI_PortWellOB());
              //        port well object
              Request_MI_PortWellOB_MI_PortWellOB oPWRequest = new Request_MI_PortWellOB_MI_PortWellOB();
              ComplexType_DT_PortWell oPWParameters = new ComplexType_DT_PortWell();
              oPWRequest.setMT_PortWellOut(oPWParameters);
              wdContext.nodeRequest_MI_PortWellOB_MI_PortWellOB().bind(oPWRequest);
              DT_PortWell oPWInputbean =
                   this.wdContext.nodeRequest_MI_PortWellOB_MI_PortWellOB().nodeMT_PortWellOut().currentMT_PortWellOutElement().modelObject().getOriginalBean();
              //       oPWInputbean.setTEST("test");
              //          well object
              DT_CWR_Well oWParameters = new DT_CWR_Well();
              //          all object
              //        surface
              DT_CWR_Surface oSParameters = new DT_CWR_Surface();
              ComplexType_DT_CWR_Surface s = new ComplexType_DT_CWR_Surface();
              //          Borehole
              DT_CWR_BoreHole[] oBParameters = new DT_CWR_BoreHole[wdContext.nodeBoreholedetail().size()];
              //          Downhole
              DT_CWR_DownHole[] oDParameters = new DT_CWR_DownHole[wdContext.nodeDownholedetail().size()];
              //          Interval
              DT_CWR_Interval[] oIParameters = new DT_CWR_Interval[wdContext.nodeIntervaldetail().size()];
              //        add all into well object       
              oWParameters.setSURFACE(oSParameters);
              oWParameters.setBOREHOLE(oBParameters);
              oWParameters.setDOWNHOLE(oDParameters);
              oWParameters.setINTERVAL(oIParameters);
              //       oPWParameters.setWELL(oWParameters );      
              oPWInputbean.setWELL(oWParameters);
              oPWRequest.setMT_PortWellOut(oPWParameters);
              wdContext.nodeRequest_MI_PortWellOB_MI_PortWellOB().bind(oPWRequest);
              wdContext.currentMT_PortWellOutElement().setUSERID("user");
              wdContext.currentMT_PortWellOutElement().setAGENCY("agency");
    Rahul

  • How to generate a set of date type records

    How to generate a set of date-type records, with a fixed interval, starting from a date like 2008-01-01.

    Some thing like this
    SQL> select to_char(to_date('2008-01-01','yyyy-mm-dd') + (level - 1),'DD-MON-YYYY') my_date
      2    from dual
      3  connect by level <= 10
      4  /
    MY_DATE
    01-JAN-2008
    02-JAN-2008
    03-JAN-2008
    04-JAN-2008
    05-JAN-2008
    06-JAN-2008
    07-JAN-2008
    08-JAN-2008
    09-JAN-2008
    10-JAN-2008
    10 rows selected.

  • Timestamp data type on S[range C on E] constant value-based range windows

    Hello,
    My questiong is about how can we use timestamp value on S[range C on E] constant value-based range windows.
    I have a LotEvent which i should collect and sum lastQty data for last ten minutes of market time (sendDate)
    A normal [range 600] query does not work for me because i would like to use the exact time which data has been generated by the market (sendDate).
    Here is the event;
    public class LotEvent{
         private Double totalQty;
         private float lastQty;
         private String symbol;
         private String messageType;
         private Integer dataInterval;
         private String sendDate;
    send date is always in "MM-dd-yyyy HH:mm:ss" format.
    I have tried to use the following query but this gives an error;
    Invalid statement: "select symbol, sum(lastQty) as lastQty, 10 AS dataInterval
    +from lotInputChannel [range INTERVAL "0 0:0:15.0" DAY TO SECOND on >>sendDate<<]+
    group by symbol"
    Cause: Datatype char is not valid for value based windows
    Action: Use a valid datatype for value based windows>
    Here is the CQL;
    <?xml version="1.0" encoding="UTF-8"?>
    <wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application">
    <processor>
    <name>lotProcTenMin</name>
    <rules>
         <query id="tenMin"> <![CDATA[select symbol, sum(lastQty) as lastQty, 10 AS dataInterval 
                from lotInputChannel [range INTERVAL "0 00:10:00.0" DAY TO SECOND on sendDate]
    group by symbol]]> </query>
    </rules>
    </processor>
    </wlevs:config>
    i have tried this cql after changing the sendDate data type to long which is the time in milliseconds value but it did not work.
    select symbol, sum(lastQty) as lastQty, 10 AS dataInterval
    from lotInputChannel [range INTERVAL "0 00:10:00.0" DAY TO SECOND on to_timestamp(sendDate)]
    group by symbol
    The query above does not work also when sendDate is a String in "MM-dd-yyyy HH:mm:ss" format
    At last i tried the following query with sendDate as time in milliseconds (long) value. It works! but i still would like to know how to use timestamp in S[range C on E] queries
    select symbol, sum(lastQty) as lastQty, 10 AS dataInterval
    from lotInputChannel [range *600000* on sendDate]
    group by symbol
    public class LotEvent{
         private Double totalQty;
         private float lastQty;
         private String symbol;
         private String messageType;
         private Integer dataInterval;
         private long sendDate;
    Could anybody please help me with this issue?
    Edited by: user8830791 on 01-Aug-2011 06:39

    It seems that you should configure the channel "lotInputChannel" as an application timestamped channel.
    You can do that as follows -
    - Have "sendDate" as a long and let its unit be milliseconds
    - Use the following child elements of <channel> for the "lotInputChannel"
    <wlevs:application-timestamped is-total-order="true">
    <wlevs:expression>sendDate*1000*1000</wlevs:expression>
    </wlevs:application-timestamped>
    The multiplication by 10^6 is required since the units need to be converted into nanos
    With this, you could use the query -
    select symbol, sum(lastQty) as lastQty, 10 AS dataInterval
    from lotInputChannel [range 10 minutes]
    group by symbol
    Of course, for the above to work, a requirement is that the value of "sendDate" is non-decreasing.
    That is if e1 is before e2 in the "lotInputChannel" then e1.sendDate <= e2.sendDate
    Edited by: Anand Srinivasan on Aug 2, 2011 6:57 AM

  • Rowid data type

    Hi All,
    I pass rowid from select stmt to update stmt in plsql, so update is quicker. There is bunch of if else statements before update is issued.
    Question is I declared v_rowid to be varchar2 and it gives me numeric error. Should I declare it as rowid data type ? Do I have to worry about the size ?
    Thanks for any help
    Vissu

    I am not sure For me it is working
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL>  declare
      2   r rowid;
      3   begin
      4   select rowid into r from t where rownum<2;
      5   end;
      6  /
    PL/SQL procedure successfully completed.
    SQL>
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.2.0.4.0 - Production
    SQL> ed
    Wrote file afiedt.buf
      1   declare
      2   r rowid;
      3   begin
      4   select rowid into r from t1 where rownum<2;
      5*  end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> r
      1   declare
      2   r rowid;
      3   begin
      4   select rowid into r from t1 where rownum<2;
      5*  end;
    PL/SQL procedure successfully completed.
    SQL> Message was edited by:
    devmiral

  • Display data type

    hi,
    how to display oralce's data type from system table is there any system table to fetch the data types for that version i'm using Oracle 11g.
    in sql server we fetch the details by using
    select * from sys.types
    this will return what the data types supported by that version
    Thanks!

    There is a package called STANDARD in the SYS schema that defines many of the standard datatypes and functions.
    e.g.
    CREATE OR REPLACE package SYS.STANDARD AUTHID CURRENT_USER is              -- careful on this line; SED edit occurs!
      /********** Types and subtypes, do not reorder **********/
      type BOOLEAN is (FALSE, TRUE);
      type DATE is DATE_BASE;
      type NUMBER is NUMBER_BASE;
      subtype FLOAT is NUMBER; -- NUMBER(126)
      subtype REAL is FLOAT; -- FLOAT(63)
      subtype "DOUBLE PRECISION" is FLOAT;
      subtype INTEGER is NUMBER(38,0);
      subtype INT is INTEGER;
      subtype SMALLINT is NUMBER(38,0);
      subtype DECIMAL is NUMBER(38,0);
      subtype NUMERIC is DECIMAL;
      subtype DEC is DECIMAL;
      subtype BINARY_INTEGER is INTEGER range '-2147483647'..2147483647;
      subtype NATURAL is BINARY_INTEGER range 0..2147483647;
      subtype NATURALN is NATURAL not null;
      subtype POSITIVE is BINARY_INTEGER range 1..2147483647;
      subtype POSITIVEN is POSITIVE not null;
      subtype SIGNTYPE is BINARY_INTEGER range '-1'..1;  -- for SIGN functions
      type VARCHAR2 is NEW CHAR_BASE;
      subtype VARCHAR is VARCHAR2;
      subtype STRING is VARCHAR2;
      subtype LONG is VARCHAR2(32760);
      subtype RAW is VARCHAR2;
      subtype "LONG RAW" is RAW(32760);
      subtype ROWID is VARCHAR2(256);
      -- Ansi fixed-length char
      -- Define synonyms for CHAR and CHARN.
      subtype CHAR is VARCHAR2;
      subtype CHARACTER is CHAR;
      type MLSLABEL is new CHAR_BASE;
      -- Large object data types.
      --  binary, character, binary file.
      type  BLOB is BLOB_BASE;
      type  CLOB is CLOB_BASE;
      type  BFILE is BFILE_BASE;
      -- Verbose and NCHAR type names
      subtype "CHARACTER VARYING" is VARCHAR;
      subtype "CHAR VARYING" is VARCHAR;
      subtype "NATIONAL CHARACTER" is CHAR CHARACTER SET NCHAR_CS;
      subtype "NATIONAL CHAR" is CHAR CHARACTER SET NCHAR_CS;
      subtype "NCHAR" is CHAR CHARACTER SET NCHAR_CS;
      subtype "NATIONAL CHARACTER VARYING" is VARCHAR CHARACTER SET NCHAR_CS;
      subtype "NATIONAL CHAR VARYING" is VARCHAR CHARACTER SET NCHAR_CS;
      subtype "NCHAR VARYING" is VARCHAR CHARACTER SET NCHAR_CS;
      subtype "NVARCHAR2" is VARCHAR2 CHARACTER SET NCHAR_CS;
      subtype "CHARACTER LARGE OBJECT" is CLOB;
      subtype "CHAR LARGE OBJECT" is CLOB;
      subtype "NATIONAL CHARACTER LARGE OBJEC" is CLOB CHARACTER SET NCHAR_CS;
      subtype "NCHAR LARGE OBJECT" is CLOB CHARACTER SET NCHAR_CS;
      subtype "NCLOB" is CLOB CHARACTER SET NCHAR_CS;
      subtype "BINARY LARGE OBJECT" is BLOB;
      subtype pls_integer is binary_integer;
      type TIME is new DATE_BASE;
      type TIMESTAMP is new DATE_BASE;
      type "TIME WITH TIME ZONE" is new DATE_BASE;
      type "TIMESTAMP WITH TIME ZONE" is new DATE_BASE;
      type "INTERVAL YEAR TO MONTH" is new DATE_BASE;
      type "INTERVAL DAY TO SECOND" is new DATE_BASE;
      SUBTYPE TIME_UNCONSTRAINED IS TIME(9);
      SUBTYPE TIME_TZ_UNCONSTRAINED IS TIME(9) WITH TIME ZONE;
      SUBTYPE TIMESTAMP_UNCONSTRAINED IS TIMESTAMP(9);
      SUBTYPE TIMESTAMP_TZ_UNCONSTRAINED IS TIMESTAMP(9) WITH TIME ZONE;
      SUBTYPE YMINTERVAL_UNCONSTRAINED IS INTERVAL YEAR(9) TO MONTH;
      SUBTYPE DSINTERVAL_UNCONSTRAINED IS INTERVAL DAY(9) TO SECOND (9);
      TYPE UROWID IS NEW CHAR_BASE;
      type "TIMESTAMP WITH LOCAL TIME ZONE" is new DATE_BASE;
      subtype timestamp_ltz_unconstrained is timestamp(9) with local time zone;
      subtype BINARY_FLOAT is NUMBER;
      subtype BINARY_DOUBLE is NUMBER;
      -- The following data types are generics, used specially within package
      -- STANDARD and some other Oracle packages.  They are protected against
      -- other use; sorry.  True generic types are not yet part of the language.
      type "<ADT_1>" as object (dummy char(1));
      type "<RECORD_1>" is record (dummy char(1));
      type "<TUPLE_1>" as object (dummy char(1));
      type "<VARRAY_1>" is varray (1) of char(1);
      type "<V2_TABLE_1>" is table of char(1) index by binary_integer;
      type "<TABLE_1>" is table of char(1);
      type "<COLLECTION_1>" is table of char(1);
      type "<REF_CURSOR_1>" is ref cursor;
      -- This will actually match against a Q_TABLE
      type "<TYPED_TABLE>" is table of  "<ADT_1>";
      subtype "<ADT_WITH_OID>" is "<TYPED_TABLE>";
      -- The following generic index table data types are used by the PL/SQL
      -- compiler to materialize an array attribute at the runtime (for more
      -- details about the array attributes, please see Bulk Binds document).
      type " SYS$INT_V2TABLE" is table of pls_integer index by binary_integer;
      -- The following record type and the corresponding generic index table
      -- data types are used by the PL/SQL compiler to materialize a table
      -- at the runtime in order to record the exceptions raised during the
      -- execution of FORALL bulk bind statement (for more details, please
      -- see bulk binds extensions document in 8.2).
      type " SYS$BULK_ERROR_RECORD" is
              record (error_index pls_integer, error_code pls_integer);
      type " SYS$REC_V2TABLE" is table of " SYS$BULK_ERROR_RECORD"
                                   index by binary_integer;
      /* Adding a generic weak ref cursor type */
      type sys_refcursor is ref cursor;
      /* the following data type is a generic for all opaque types */
      type "<OPAQUE_1>" as opaque FIXED(1) USING LIBRARY dummy_lib
        (static function dummy return number);
      type "<ASSOC_ARRAY_1>" is table of char(1) index by varchar2(1);
      /********** Add new types or subtypes here **********/
      /********** Predefined constants **********/
      BINARY_FLOAT_NAN constant BINARY_FLOAT;
      BINARY_FLOAT_INFINITY constant BINARY_FLOAT;
      BINARY_FLOAT_MAX_NORMAL constant BINARY_FLOAT;
      BINARY_FLOAT_MIN_NORMAL constant BINARY_FLOAT;
      BINARY_FLOAT_MAX_SUBNORMAL constant BINARY_FLOAT;
      BINARY_FLOAT_MIN_SUBNORMAL constant BINARY_FLOAT;
      BINARY_DOUBLE_NAN constant BINARY_DOUBLE;
      BINARY_DOUBLE_INFINITY constant BINARY_DOUBLE;
      BINARY_DOUBLE_MAX_NORMAL constant BINARY_DOUBLE;
      BINARY_DOUBLE_MIN_NORMAL constant BINARY_DOUBLE;
      BINARY_DOUBLE_MAX_SUBNORMAL constant BINARY_DOUBLE;
      BINARY_DOUBLE_MIN_SUBNORMAL constant BINARY_DOUBLE;
      /********** Add new constants here **********/
      /********** Predefined exceptions **********/
      CURSOR_ALREADY_OPEN exception;
        pragma EXCEPTION_INIT(CURSOR_ALREADY_OPEN, '-6511');
      DUP_VAL_ON_INDEX exception;
        pragma EXCEPTION_INIT(DUP_VAL_ON_INDEX, '-0001');
    ..and so it goes on... take a look yourself
    Edited by: BluShadow on 18-Dec-2012 09:32

  • UNDERSTAND THE NEW DATE AND TIME DATA TYPES IN ORACLE 9I

    제품 : SQL*PLUS
    작성날짜 : 2001-08-01
    UNDERSTAND THE NEW DATE AND TIME DATA TYPES IN ORACLE 9I
    ========================================================
    PURPOSE
    Oracle 9i 에서 소개되는 새로운 datetime data type 에 대해 소개한다.
    Explanation
    Example
    1. Datetime Datatypes
    1) TIMESTAMP
    : YEAR/MONTH/DAY/HOUR/MINUTE/SECOND
    2) TIMESTAMP WITH TIME ZONE
    : YEAR/MONTH/DAY/HOUR/MINUTE/SECOND/
    TIMEZONE_HOUR/TIMEZONE_MINUTE( +09:00 )
    or TIMEZONE_REGION( Asia/Seoul )
    3) TIMESTAMP WITH LOCAL TIME ZONE
    : YEAR/MONTH/DAY/HOUR/MINUTE/SECOND
    4) TIME WITH TIME ZONE
    : HOUR/MINUTE/SECOND/TIMEZONE_HOUR/TIMEZONE_MINUTE
    2. Datetime Fields
    1) YEAR/MONTH/DAY/HOUR/MINUTE
    2) SECOND(00 to 59.9(N) is precision) : Range 0 to 9, default is 6
    3) TIMEZONE_HOUR : -12 to 13
    4) TIMEZONE_MINUTE : 00 to 59
    5) TIMEZONE_REGION : Listed in v$timezone_names
    3. DATE 와 TIMESTAMP 와의 차이점
    SQL> select hiredate from emp;
    HIREDATE
    17-DEC-80
    20-FEB-81
    SQL> alter table employees modify hiredate timestamp;
    SQL> select hiredate from employees;
    HIREDATE
    17-DEC-80 12.00.00.000000 AM
    20-FEB-81 12.00.00.000000 AM
    단, 해당 Column 에 Data 가 있다면 DATE/TIMESTAMP -> TIMESTAMP WITH
    TIME ZONE 으로 Convert 할 수 없다.
    SQL> alter table employees modify hiredate timestamp with time zone;
    alter table employees modify hiredate timestamp with time zone
    ERROR at line 1:
    ORA-01439: column to be modified must be empty to change datatype
    4. TIMESTAMP WITH TIME ZONE Datatype
    TIMESTAMP '2001-05-24 10:00:00 +09:00'
    TIMESTAMP '2001-05-24 10:00:00 Asia/Seoul'
    TIMESTAMP '2001-05-24 10:00:00 KST'
    5. TIMESTAMP WITH LOCAL TIME ZONE Datatype
    SQL> create table date_tab (date_col TIMESTAMP WITH LOCAL TIME ZONE);
    SQL> insert into date_tab values ('15-NOV-00 09:34:28 AM');
    SQL> select * from date_tab;
    DATE_COL
    15-NOV-00 09.34.28.000000 AM
    SQL> alter session set TIME_ZONE = 'EUROPE/LONDON';
    SQL> select * from date_tab;
    DATE_COL
    15-NOV-00 12.34.28.000000 AM
    6. INTERVAL Datatypes
    1) INTERVAL YEAR(year_precision) TO MONTH
    : YEAR/MONTH
    : Year_precision default value is 2
    SQL> create table orders (warranty interval year to month);
    SQL> insert into orders values ('2-6');
    SQL> select warranty from orders;
    WARRANTY
    +02-06
    2) INTERVAL DAY (day_precision) TO SECOND (fractional_seconds_precision)
    : DAY/HOUR/MINUTE/SECOND
    : Logon time 확인시 주로 사용
    : day_precision range 0 to 9, default is 2
    SQL> create table orders (warranty interval day(2) to second);
    SQL> insert into orders values ('90 00:00:00');
    SQL> select warranty from orders;
    WARRANTY
    +90 00:00:00.000000
    7. Interval Fields
    - YEAR : Any positive or negative integer
    - MONTH : 00 to 11
    - DAY : Any positive or negative integer
    - HOUR : 00 to 23
    - MINUTE : 00 to 59
    - SECOND : 00 to 59.9(N) where 9(N) is precision
    8. Using Time Zones
    1) Database operation
    - Defined at CREATE DATABASE
    - Can be altered with ALTER DATABASE
    - Current value given by DBTIMEZONE
    2) Session operation
    - Defined with environment variable ORA_SDTZ
    - Can be altered with ALTER SESSION SET TIME_ZONE
    - Current value given by SESSIONTIMEZONE
    3) TIMESTAMP WITH LOCAL TIMEZONE
    - TIME_ZONE Session parameter
    : O/S Local Time Zone
    Alter session set time_zone = '-05:00';
    : An absolute offset
    Alter session set time_zone = dbtimezone;
    : Database time zone
    Alter session set time_zone = local;
    : A named region
    Alter session set time_zone = 'America/New_York';
    Reference Document
    ------------------

    Hi ,
    I am facing the same problem and my scenario is also same (BAPI's).
    So can you please tell me how you overcome this problem .
    Thanks,
    Rahul

Maybe you are looking for

  • Tape initialization error at first time in DB13

    Hi , first time While initializing tapes in DB13 , we are getting error "<b>0003 Error during Tape initialization</b>".At OS ( HP-UX / Oracle), SAP R/3 4.72Enterprise. level backup device initialized.I have enclosed logs ,please suggestto resolve thi

  • Messages in status u0094To Be Deliveredu0094

    I’ve got 13870 messages in status “To Be Delivered” in my Adapter Engine. I’m using the JMS adapter and the detailed view in rwb it says that “JMS message delivered to XI successfully”. In the undetailed view the status says “To Be Delivered” and I’m

  • BAPI to create a parked MRM invoice

    Hi Does anybody know a BAPI that can be used to create a parked MRM invoice? Thanks Ananda

  • FrameMaker 8 demo available anywhere?

    I searched the site and it seems that only FrameMaker 9 is available as a demo download. Is the last version available anywhere else? I emailed the webmasters but they haven't gotten back to me.

  • HttpConnection.getResponseCode generates a Connection Refused exeption

    I have the following problem: I connect to a webserver, this works fine. Then I write data to the webserver, this also works fine. After writing the data, I determine the http response code to see if everything was successfull. Every so often this ge