Time comparison in database

I'm developing a attendance record for my company and I have the following issues.
The table looks like this.
Table name: Attendance,
Structure is like this,
staffID      int(11)      
date      date
time_in time
time_out time
Date      Time In Time Out
2006-10-05     09:31:00     18:29:00
2006-10-06     09:41:00     16:39:00
Number of late: 2
Total late seconds: 187200
As I would like to compare the time_in against 09:30:00 and get a sum of the amount.
MySQL statement is like this,
SELECT * FROM attendance where staffid = '" . $staffid . "' AND time_in > '09:30:00'
However the return time is 187200. I wonder how they calculate this and if the sql statement is the correct one.

OK, I've modified customer average function found here,
http://www.oracle.com/technology/oramag/oracle/06-jul/o46sql.html
CREATE OR REPLACE TYPE SumInterval
AS OBJECT (
runningSum INTERVAL DAY(9) TO SECOND(9),
STATIC FUNCTION ODCIAggregateInitialize
  ( actx IN OUT SumInterval
  ) RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateIterate
  ( self  IN OUT SumInterval,
    val   IN     DSINTERVAL_UNCONSTRAINED
  ) RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateTerminate
  ( self         IN  SumInterval,
    returnValue  OUT DSINTERVAL_UNCONSTRAINED,
    flags        IN  NUMBER
  ) RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateMerge
  (self IN OUT SumInterval,
   ctx2 IN     SumInterval
  ) RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateDelete
  ( self  IN OUT SumInterval,
    val   IN     DSINTERVAL_UNCONSTRAINED
  ) RETURN NUMBER  
CREATE OR REPLACE TYPE BODY SumInterval AS
STATIC FUNCTION ODCIAggregateInitialize
  ( actx IN OUT SumInterval
  ) RETURN NUMBER IS
  BEGIN
    IF actx IS NULL THEN
      dbms_output.put_line('NULL INIT');
      actx := SumInterval (INTERVAL '0 0:0:0.0' DAY TO SECOND);
    ELSE
      dbms_output.put_line('NON-NULL INIT');
      actx.runningSum := INTERVAL '0 0:0:0.0' DAY TO SECOND;
    END IF;
    RETURN ODCIConst.Success;
  END;
MEMBER FUNCTION ODCIAggregateIterate
  ( self  IN OUT SumInterval,
    val   IN     DSINTERVAL_UNCONSTRAINED
  ) RETURN NUMBER IS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('Iterate ' || TO_CHAR(val));
    IF val IS NULL THEN
        /* Will never happen */
        DBMS_OUTPUT.PUT_LINE('Null on iterate');
    END IF;
    self.runningSum := self.runningSum + val;
    RETURN ODCIConst.Success;
  END;
MEMBER FUNCTION ODCIAggregateTerminate
  ( self        IN  SumInterval,
    ReturnValue OUT DSINTERVAL_UNCONSTRAINED,
    flags       IN  NUMBER
  ) RETURN NUMBER IS
  BEGIN
    dbms_output.put_line('Terminate ' || to_char(flags) || to_char(self.runningsum));
    returnValue := self.runningSum;
    RETURN ODCIConst.Success;
  END;
MEMBER FUNCTION ODCIAggregateMerge
  (self IN OUT SumInterval,
   ctx2 IN     SumInterval
  ) RETURN NUMBER IS
  BEGIN
    self.runningSum := self.runningSum + ctx2.runningSum;
    RETURN ODCIConst.Success;
  END;
MEMBER FUNCTION ODCIAggregateDelete
  ( self  IN OUT SumInterval,
    val   IN     DSINTERVAL_UNCONSTRAINED
  ) RETURN NUMBER IS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('Delete ' || TO_CHAR(val));
    IF val IS NULL THEN
        /* Will never happen */
        DBMS_OUTPUT.PUT_LINE('Null on delete');
    END IF;
    self.runningSum := self.runningSum - val;
    RETURN ODCIConst.Success;
  END;
END;
/* create the aggregate interface function*/
CREATE OR REPLACE FUNCTION sum_interval
  ( x DSINTERVAL_UNCONSTRAINED
  ) RETURN DSINTERVAL_UNCONSTRAINED
    PARALLEL_ENABLE
    AGGREGATE USING SumInterval;after running this script you should be able to get result like this,
SQL> select sum_interval(numtodsinterval(time_in-to_date('9:30:00','HH24:MI:SS'),'day')) from att;
SUM_INTERVAL(NUMTODSINTERVAL(TIME_IN-TO_DATE('9:30:00','HH24:MI:SS'),'DAY')
+000000000 00:12:00.000000000Message was edited by:
nurhidayat

Similar Messages

  • Database time comparisons from RAT

    I am using Real Application Testing to test moving to a new server and I am a little confused on the “database time” comparisons. I ran the capture for 5 minutes and 54 seconds, the database time for the CAPTURE shows 33 minutes and 29 seconds, when I replayed it the REPLAY shows database time for 6:09 but the actual duration was only 5:57.
    So this tells me that it took about the same amount of time to play back the workload but I don’t understand the database time. Can somebody help me out with this? Thanks.

    I have not done RAT but my guess is the CAPTURE time is the cumulative time consumed by sessions on database for the given workload.

  • Problem while inserting Date/Time in Oracle Database

    Hai,
    i want to insert the date and time in a date column. here, i am using java.sql.Date and java.sql.Time to assign the date in Prepared Statement.
    PreparedStatement psmt=con.prepareStatement("insert into test(ex_date) values(?)");
    java.util.Calendar c=Calendar.getInstance();
    c.set(2002,2,21,10,10,00);
    java.sql.Date d=new Date(c.getTime().getTime());
    java.sql.Time t=new Time(c.getTime().getTime());
    psmt.clearParameters();
    psmt.setDate(1,d);
    psmt.setDate(1,t);
    psmt.executeUpdate();
    Above program is inserted the Date and time in the database as the following "1900/2/21 10:10 AM"
    but i am giving the year as 2002. it inserted the year as 1900. what is the problem with the code?
    please let me know
    Thanks in advance.
    Regards
    sankarjune14

    Hai Franco,
    i put the wrong code. Here, is the Original Code.
    PreparedStatement psmt=con.prepareStatement("insert into test(ex_date) values(?)");
    java.util.Calendar c=Calendar.getInstance();
    c.set(2002,2,21,10,10,00);
    java.sql.Date d=new Date(c.getTime().getTime());
    java.sql.Time t=new Time(c.getTime().getTime());
    psmt.clearParameters();
    psmt.setDate(1,d);
    psmt.setTime(1,t); // Last time i put psmt.setDate(1,t);
    psmt.executeUpdate();
    and, the getTimeInMillis() method is a protected method in java.util.Calendar class. how can we use it
    please give me some other idea to insert the date and time in oracle database.
    Thanks in advance
    sankarjune14

  • Add time field in database table

    Hi Gurus,
    I am trying to add a time field in database table. I know i can add it by using append structure.
    but my problem is when records r creating in database table, the time field also populate with respective system time automatically. i think i need to use events but i have no idea how to use.
    is there any other method available?
    is there any system field for time stamp as date + time?
    Regards
    Giri

    Rob,
    its not updating by table maintainance generator.
    I want to add Time field in table ESTDH. 
    when a new record updated while report version generated the time field also populate with system field.
    is it possible?
    can anybody help me?
    Regards
    Giri

  • Generate query  at a time &  connect  two database ?

    Hi
    Could u help me? it is necessary  that  
    I have  two database ( RSHPL,RSPL)  and both data base have  same table name and same fieldname (Table Name :-OITM, Fieldname :ONHAND ,pk- ITEMcode,) 
    At first I tell u what I want?
    I want to generate query  at a time &  connect  two database and same table name(OITM)  to select the TOTAL VALUE of this  field(ONHAND) and pk-key is Itemcode.  
    Is it Possible? If  Possible  plz  write this query and send me.

    Hi,
    I don't think its possible to write a query from within SAP that allows you to get data from another SAP database. 
    I have used SQL Reporting Services to report on data from multiple databases, and this works very well for many of my clients.  It depends on what you want to do with the data, do you need to display it on the screen in SAP and it to a field or will a report suffice?
    Regards,
    Adrian

  • Timer in the database

    Hello, I have a question about the timer in the database.
    I have a job that has a priority of 1. That job needs to run from time to time.( that is to run once and then sleep for a while.) The sleeping time is provided by another job. I am using DBMS_LOCK.sleep().
    When the database is almost idle, if I set the sleeping time is 2 seconds, then it is accurate. But when the database has some workload (that means there are other jobs running), and the cpu util is not very high (around 70%). If I set the sleeping time as 2 sec, I found the actual sleeping time is almost 3 sec.
    Are there any better ways to improve the accuracy? How about I set the timer on another idle machine, and that machine sends a request to the database and then the database response that request?
    Great thanks.

    Hi,
    I don't think that the actual time taken by dbms_lock.sleep should vary that much with the load on the database. You can use plsql profiling or tracing to see where the time is really being taken up.
    How are you using another job to provide the sleep time to the first job ? If you are using a table maybe you might be able to get a better response using dbms_pipe instead.
    Depending on where your bottleneck is using another idle machine to do the scheduling may provide a better worst response time. But the average response time may be worse because of network latency.
    Hope this helps,
    Ravi.

  • Installation date/time of a database !!

    How can i determine the installation date/time of my databases? I can forget to note the date and time of my database instances. After some time since we have one than more databases, it becomes important to remember thier installation sequence. Thank you very much for your comments.

    If you have never recreated/restored/reincarnated the database, then CREATED column from v$database should tell you when you created the database.
    If you are looking for the date/time of installation of Oracle home, check the logs under OraInventory.

  • Time Comparison PHP

    Hi There
    I am trying to create a time comparison for a website I am building.
    I have the following so far
    <?php
    $date=$_POST ['daydropdown'];
    $month=$_POST ['monthdropdown'];
    $year=$_POST ['yeardropdown'];
    $datevalue="$date/$month/$year";
    $booking=strtotime ("now + 24 hours");
    if ($date_value > $booking)
    echo ("lovey");
    else
    echo ("tut tut");
    ?>
    which is pulling its date info from
              <form action="timetest.php" method="post">
              <table>
      <tr>
        <td class="tableheight">
          Party Size</td>
        <td>
          <select name="partysize" size="1" id="partysize">
          <option>1</option>
          <option selected="selected">2</option>
          <option>3</option>
          <option>4</option>
          <option>5</option>
          <option>6</option>
          <option>7</option>
          <option>8</option>
          <option>9</option>
          <option>10</option>
          <option>11</option>
          <option>12</option>
          <option>13</option>
          <option>14</option>
          <option>15</option>
          <option>16</option>
          <option>17</option>
          <option>18</option>
          <option>19</option>
          <option>20</option>
        </select>
        </td>
      </tr>
      <tr>
        <td class="tableheight">Date</td>
        <td>
    <select name="daydropdown" id="daydropdown">
    </select>
    <select name="monthdropdown" id="monthdropdown">
    </select>
    <select name="yeardropdown" id="yeardropdown">
    </select>
    </td>
      </tr>
      <tr>
        <td class="tableheight">Time</td>
        <td><select name="time">
          <option>12 noon</option>
          <option>12:15pm</option>
          <option>12:30pm</option>
          <option>12:45pm</option>
          <option>1:00pm</option>
          <option>1:15pm</option>
          <option>1:30pm</option>
          <option>1:45pm</option>
          <option>2:00pm</option>
          <option>2:15pm</option>
          <option>2:30pm</option>
          <option>2:45pm</option>
          <option>3:00pm</option>
          <option>3:15pm</option>
          <option>3:30pm</option>
          <option>3:45pm</option>
          <option>4:00pm</option>
          <option>4:15pm</option>
          <option>4:30pm</option>
          <option>4:45pm</option>
          <option>5:00pm</option>
          <option>5:15pm</option>
          <option>5:30pm</option>
          <option>5:45pm</option>
          <option>6:00pm</option>
          <option>6:15pm</option>
          <option>6:30pm</option>
          <option>6:45pm</option>
          <option>7:00pm</option>
          <option>7:15pm</option>
          <option>7:30pm</option>
          <option>7:45pm</option>
          <option>8:00pm</option>
          <option>8:15pm</option>
          <option>8:30pm</option>
          <option>8:45pm</option>
          <option>9:00pm</option>
          <option>9:15pm</option>     
    </select></td>
      </tr>
      <tr>
        <td class="tableheight">First Name</td>
        <td><input name="firstname" type="text" placeholder="Your First Name" /></td>
      </tr>
      <tr>
        <td class="tableheight">Surname</td>
        <td><input name="surname" type="text" placeholder="Your Last Name"/></td>
      </tr>
      <tr>
        <td class="tableheight">Email Address</td>
        <td><input name="email" type="email" placeholder="Your Email Address"/></td>
      </tr>
      <tr>
        <td class="tableheight">Confirm Email </td>
        <td><input name="confirm" type="email"  placeholder="Confirm Email"/></td>
      </tr>
      <tr>
        <td class="tableheight">Contact Number</td>
        <td><input name="contactnumber" type="text" placeholder="Your Contact Number"/></td>
      </tr>
      <tr>
        <td style="padding-top:0px"><input name="Book Now" type="submit" value="Book Now" /></td>
        <td></td>
      </tr>
    </table>
              </form>
              <script type="text/javascript">
    //populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
    window.onload=function(){
    populatedropdown("daydropdown", "monthdropdown", "yeardropdown")
    </script>
    What I want to happen is if a booking for a table is made for more than 24hours in advance then its fine and sends the reservation to the restaurant aka "Lovely" where as if its for within the next 24 hours then "tut tut" they are told to ring the restaurant.
    Does anyone have any pointers for me please.
    G

    You need to change the $datevalue variable to a timestamp like you did with $booking.
    $dateTried = strtotime($datevalue); 
    Then you can compare them.
    if ($dateTried < $booking) {      // this is what to do if the time chosen was within 24 hours } else {      // this is what to do if the time chosen was a valid value (24 hours or more from current time) } 
    BTW, it looked like your form fields are populated using JavaScript. If I were you I would switch that to be PHP driven. The code will be very similar in PHP as your JavaScript code, but it will work for all your visitors, not just the ones that have JavaScript enabled.
    -Jason
    Sorry the code didn't line up. I used the wrong code insert options.
    Message was edited by: UteFanJason

  • Stored Procedure using Date/Time Comparison

    I’m running SQL Server 2012. I need to write a procedure that will send out emails based on a date/time comparison.
    In my table, ‘tickets’, I have a smalldatetime column ‘ticket_date’ and another column ‘responded’ which is a bit field. I need to check the current date to see if 24 hours has passed from the ticket_date. If 24 hours has passed and responded is 0, then
    I need to email a manager ( I already have the code for  emailing with SMTP).
    The next step is to see if 48 hours has passed from the ticket_date and if responded is 0.
     If this is true, then I need to email someone else.
    I don’t want to include weekends in my time comparison. My procedure will only run Mon – Fri. 
    Thanks in advance!

    Check the below sample and hope this will help you:
    DECLARE @Tickets TABLE (TicketID INT, TicketDate SMALLDATETIME, Responded BIT)
    INSERT INTO @Tickets
    SELECT 1, '01/10/2015 10:00AM', 0 UNION ALL
    SELECT 2, '01/13/2015 12:00PM', 1 UNION ALL
    SELECT 3, '01/12/2015 05:30PM', 0 UNION ALL
    SELECT 4, '01/09/2015 08:00AM', 1
    SELECT *, '24 Hour' AS TicketCase
    FROM
    @Tickets
    WHERE
    Responded = 0
    AND DATEDIFF(HOUR, TicketDate, CURRENT_TIMESTAMP) <= (CASE DATEPART(WEEKDAY, TicketDate) WHEN 7 THEN 48 WHEN 1 THEN 24 ELSE 0 END) + 24
    UNION ALL
    SELECT *, '48 Hour' AS TicketCase
    FROM
    @Tickets
    WHERE
    Responded = 0
    AND DATEDIFF(HOUR, TicketDate, CURRENT_TIMESTAMP) >= 24
    AND DATEDIFF(HOUR, TicketDate, CURRENT_TIMESTAMP) <= (CASE DATEPART(WEEKDAY, TicketDate) WHEN 7 THEN 48 WHEN 1 THEN 24 ELSE 0 END) + 48
    Output
    TicketID | TicketDate | Responded | TicketCase
    3 | 2015-01-12 17:30:00 | 0 | 24 Hour
    1 | 2015-01-10 10:00:00 | 0 | 48 Hour
    You can make the separate SQL statements and email to proper people based on 24 hour or 48 hour case. 
    Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

  • Date and Time comparisons...

    Hi! and regards to all.... I´m trying to get the interval from a table depending on current date and time (sysdate), but i´m having problems when comparing date where first one is greater than second one...
    My table is defined and populated as...
    HRA_ID HRA_INTERV HRA_INICIO HRA_FIN
    1 15 01/01/2008 08:00:00 a.m. 01/12/2020 10:00:00 p.m.
    2 30 01/01/2008 10:01:00 p.m. 01/12/2020 07:59:00 a.m.
    Whend doing comparison between 8:00am to 10:00pm no problem is found and the data 15 is returned... but when comparing in the second interval (10:01pm to 7:59am next day) problems are come.. I supose is because of different days are considered in my sql statement... nevertheless i would like to receive comments...
    My sql statement is:
    SELECT HRA_INVERV
    FROM UBI_HORARIOS A
    WHERE TO_DATE(TO_CHAR(SYSDATE,'HH24:MI:SS'),'HH24:MI:SS')
    BETWEEN (TO_DATE(TO_CHAR(A.HRA_INICIO,'HH24:MI:SS'),'HH24:MI:SS'))
    AND
         (TO_DATE(TO_CHAR(A.HRA_FIN,'HH24:MI:SS'),'HH24:MI:SS'))
    Your suggestions are welcome...

    Thanks Justin!!, and EXACTLY!!!... That was the first error I found when my supervisors gave me the database ralational diagram... But in this case fields with data type TIME are not allowed.. So, what I´m trying to to is trim the date parte of the field (01/01/2008, etc,etc) and JUST USE TIME INTERVALS... That´s why I´m using to_char and to_date... in order to ELIMINATE DATE PARTS AND USE JUST THEIR TIME PERIODS... But being honest.. i don´t know if there´s another function could help...

  • Time Comparison

    Dear Friends,
    I need your valuable suggestion to proceed.
    Functional Flow :-
    My client will have a Construction project with a budgeted hours to finish and the Manager will assign Employees to this project. they need to know all the budgted hours are allocated to Employees to finish the work.
    Technical
    for example the budgeted hour will be in the format of 50:30 (Means 50 hrs and 30 minutes) and Workers will be allocated to this project like
    Monday 8:00 to 17:15
    Tuesday 9:00 to 16:45
    Tables := Projects Column Budgeted_hours varchar2(6)
    Assignments Column Allocated_hours varchar2(6)
    My question is how to compare the budgeted hours and allocated_hours of the workers to see whether all the budgeted hours are allocated to workers as I am storing these all values in Varchar2. Why I am using Varchar2 is that, they want to have this ':' sign with time slot.
    Can anyone help me how to do this. Whether I need to change varchar to Date ? if so the data will be inserted with date and time which is not correct for this situvation. Need help
    Please write to me at [email protected]
    Regards
    SJK
    thanks
    Sjk

    I would suggest you store elapsed time as a number of days e.g. 50:30 hours = 50.5/24 days = 2.1041666667 days. You'd need to write some simple PL/SQL database functions to parse and convert data between the numeric stored format and the desired input/output character format. The reasons for this are
    1) arithmetic becomes simple e.g. adding another 8 hours to the budgeted 50.5 hours
    2) where appropriate, it coincides with Oracle's way of handling date arithmetic (the difference between two DATEs is a NUMBER of days.
    If you can determine an employee's total number of allocated hours, then the comparison you mentioned becomes easy: unallocated = budgeted - allocated. You can also
    Your problem introduces lots of complexity due to the fact that a project day is not the same as a 24 hour calendar day (e.g. employee shift is only 8 hours, 5 days a week). Any calculation involving start or end dates will have to take the project calendar and work shifts into account. I suggest you invest some deep thought into the fundamental data manipulations needed by your project, and create a package of simple functions and procedures to form the foundation for higher level operations. Here's one example:
    FUNCTION SHOW_AS_HHMM (p_durn IN NUMBER) RETURN VARCHAR2 IS
    l_hours_n NUMBER;
    l_hours_c VARCHAR2(16);
    l_minutes_c VARCHAR2(2);
    BEGIN
    -- convert days into hours
    l_hours_n := p_durn * 24;
    -- convert hours into characters
    l_hours_c := to_char (trunc (l_hours_n));
    -- convert fraction of hours into minutes characters
    l_minutes_c := to_char (round ((l_hours_n - trunc (l_hours_n)) * 60));
    return l_hours_c || ':' || l_minutes_c;
    EXCEPTION
    WHEN OTHERS THEN
    raise;
    END show_as_hhmm;

  • Connecting to the database taking long time to connect database server

    Hi
    When I execute procedure i am getting the below message at bottom of the Oracle SQL Developer
    "Connecting to the database"
    it is taking more than 10 min plz guide

    Hi
    have you installed a normal Oracle Client also on your Host? normal Oracle Client
    Did you connect with host:port:sid or with a Oracle Naming Service? through TNS Service
    Can you test tnsping <alias> yes, It is working fine
    Did other user have the same problem? yes
    Did you connect through WAN or LAN connection? LAN (Intranet)
    Can you tell more about you client/database setup?
    Database setup:
    OS: Window 2008 server
    version: 11.1.0
    Client: 11.1.0
    OS: Window 2008 server
    Now I am not able to execute single select query which table contains 6 records and 15 columns it is taking long time I have waited 30 min still no resutls
    only one table is behaving like this remaining is working fine
    Edited by: user9235224 on Oct 6, 2012 7:06 PM

  • Use of current time for polling Database Adapter query

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

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

  • Report takes long time in different database version

    Dear Mates,
    I have been in serious problem from last one month. Still i don't get any solution. Come to the problem.
    I have a program where, database version is *9i R2*. Here one report are base on a database function and works perfectly. It takes 30/35 seconds to preview.
    I take this schema backup by EXP command and import it to database version XE and also database version *10G R2* with IMP command. import is successful. Others report still preview as it is at 9i. But my mentioned reports didn't come as same. Now it takes 3 Hrs. :(.
    I run explain plan and the out put is bellow. What should i do now ? If you want to check the query i can also post it. If any one have experience regarding this, please help me.
    Plan hash value: 3745590339
    | Id  | Operation                      | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |             |  9454 |  1874K|   207  (55)| 00:00:03 |
    |   1 |  SORT GROUP BY                 |             |  9454 |  1874K|   207  (55)| 00:00:03 |
    |*  2 |   HASH JOIN                    |             |  9454 |  1874K|   205  (55)| 00:00:03 |
    |*  3 |    INDEX FAST FULL SCAN        | IND_AD_ID   |  9454 |   120K|   201  (55)| 00:00:03 |
    |   4 |    INLIST ITERATOR             |             |       |       |            |          |
    |   5 |     TABLE ACCESS BY INDEX ROWID| ACC_DTL     |  1351 |   250K|     3   (0)| 00:00:01 |
    |*  6 |      INDEX RANGE SCAN          | IND_AD_FLAG |     8 |       |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("ACC_LEDGER"."LG_AD_ID"="ACC_DTL"."AD_ID")
       3 - filter("ACC_BALANCE"("ACC_LEDGER"."LG_AD_ID",:UNIT,:PROJ)<>0)
       6 - access("ACC_DTL"."AD_FLAG"=6 OR "ACC_DTL"."AD_FLAG"=7 OR "ACC_DTL"."AD_FLAG"=8
                  OR "ACC_DTL"."AD_FLAG"=18 OR "ACC_DTL"."AD_FLAG"=19)
    Note
       - dynamic sampling used for this statementupper explain plan is from database 10g R2
    bellow r from 9i R2
    | Id  | Operation                      |  Name        | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT               |              |       |       |       |
    |   1 |  SORT GROUP BY                 |              |       |       |       |
    |   2 |   CONCATENATION                |              |       |       |       |
    |   3 |    NESTED LOOPS                |              |       |       |       |
    |   4 |     TABLE ACCESS BY INDEX ROWID| ACC_DTL      |       |       |       |
    |*  5 |      INDEX RANGE SCAN          | IND_AD_FLAG  |       |       |       |
    |*  6 |     INDEX RANGE SCAN           | IND_AD_ID    |       |       |       |
    |   7 |    NESTED LOOPS                |              |       |       |       |
    |   8 |     TABLE ACCESS BY INDEX ROWID| ACC_DTL      |       |       |       |
    |*  9 |      INDEX RANGE SCAN          | IND_AD_FLAG  |       |       |       |
    |* 10 |     INDEX RANGE SCAN           | IND_AD_ID    |       |       |       |
    |  11 |    NESTED LOOPS                |              |       |       |       |
    |  12 |     TABLE ACCESS BY INDEX ROWID| ACC_DTL      |       |       |       |
    |* 13 |      INDEX RANGE SCAN          | IND_AD_FLAG  |       |       |       |
    |* 14 |     INDEX RANGE SCAN           | IND_AD_ID    |       |       |       |
    |  15 |    NESTED LOOPS                |              |       |       |       |
    |  16 |     TABLE ACCESS BY INDEX ROWID| ACC_DTL      |       |       |       |
    |* 17 |      INDEX RANGE SCAN          | IND_AD_FLAG  |       |       |       |
    |* 18 |     INDEX RANGE SCAN           | IND_AD_ID    |       |       |       |
    |  19 |    NESTED LOOPS                |              |       |       |       |
    |  20 |     TABLE ACCESS BY INDEX ROWID| ACC_DTL      |       |       |       |
    |* 21 |      INDEX RANGE SCAN          | IND_AD_FLAG  |       |       |       |
    |* 22 |     INDEX RANGE SCAN           | IND_AD_ID    |       |       |       |
    Predicate Information (identified by operation id):
       5 - access("ACC_DTL"."AD_FLAG"=19)
       6 - access("ACC_LEDGER"."LG_AD_ID"="ACC_DTL"."AD_ID")
           filter("ERP"."ACC_BALANCE"("ACC_LEDGER"."LG_AD_ID",TO_NUMBER(:Z),TO_N
                  UMBER(:Z))<>0)
       9 - access("ACC_DTL"."AD_FLAG"=18)
      10 - access("ACC_LEDGER"."LG_AD_ID"="ACC_DTL"."AD_ID")
           filter("ERP"."ACC_BALANCE"("ACC_LEDGER"."LG_AD_ID",TO_NUMBER(:Z),TO_N
                  UMBER(:Z))<>0)
      13 - access("ACC_DTL"."AD_FLAG"=8)
      14 - access("ACC_LEDGER"."LG_AD_ID"="ACC_DTL"."AD_ID")
           filter("ERP"."ACC_BALANCE"("ACC_LEDGER"."LG_AD_ID",TO_NUMBER(:Z),TO_N
                  UMBER(:Z))<>0)
      17 - access("ACC_DTL"."AD_FLAG"=7)
      18 - access("ACC_LEDGER"."LG_AD_ID"="ACC_DTL"."AD_ID")
           filter("ERP"."ACC_BALANCE"("ACC_LEDGER"."LG_AD_ID",TO_NUMBER(:Z),TO_N
                  UMBER(:Z))<>0)
      21 - access("ACC_DTL"."AD_FLAG"=6)
      22 - access("ACC_LEDGER"."LG_AD_ID"="ACC_DTL"."AD_ID")
           filter("ERP"."ACC_BALANCE"("ACC_LEDGER"."LG_AD_ID",TO_NUMBER(:Z),TO_N
                  UMBER(:Z))<>0)
    Note: rule based optimizationEdited by: HamidHelal on Oct 12, 2011 6:42 PM

    yes..
    SELECT ALL ACC_LEDGER.LG_AD_ID, ACC_DTL.AD_NAME, abs(ACC_BALANCE(ACC_LEDGER.LG_AD_ID, :UNIT, :PROJ) )BAL,
    CASE WHEN ACC_BALANCE(ACC_LEDGER.LG_AD_ID, :UNIT, :PROJ)>0  AND ACC_DTL.AD_FLAG IN(6 ,18) THEN
                'RECEIVABLE'
               WHEN  ACC_BALANCE(ACC_LEDGER.LG_AD_ID, :UNIT, :PROJ)<0  AND ACC_DTL.AD_FLAG IN(6,18)  THEN
                'PAYABLE'
                 WHEN ACC_BALANCE(ACC_LEDGER.LG_AD_ID, :UNIT, :PROJ)>0  AND ACC_DTL.AD_FLAG IN(7,8,19)  THEN
                'PAYABLE'
                WHEN ACC_BALANCE(ACC_LEDGER.LG_AD_ID, :UNIT, :PROJ)<0  AND ACC_DTL.AD_FLAG IN(7,8,19)  THEN
                'RECEIVABLE'
                END AS BALANCE_TYPE,
    ACC_DTL.AD_CODE, ACC_DTL.AD_FLAG
    FROM ACC_DTL, ACC_LEDGER
    WHERE ACC_DTL.AD_FLAG IN (6, 7, 8,18,19)
    AND (ACC_LEDGER.LG_AD_ID = ACC_DTL.AD_ID)
    AND ACC_BALANCE(ACC_LEDGER.LG_AD_ID, :UNIT, :PROJ)<>0
    GROUP BY ACC_LEDGER.LG_AD_ID, ACC_DTL.AD_NAME, ACC_DTL.AD_CODE, ACC_DTL.AD_FLAG
    ORDER BY   ACC_DTL.AD_FLAG , ACC_DTL.AD_NAME;here ACC_BALANCE is the database function name..

  • Insert a value of type Date/Time into a database

    I am trying to insert a value of type date time into an access database. What is the format needed to insert the date/time.
    Thanks,
    -Amos

    I had all kinds of problems getting a datetime inserted into a SQl Server DB. Probably similar so this is what I do:
    String date = new String("01/01/97 12:00:00");
    stmt.setObject(1, date);
    I tried using TimeStamp's but found I got an occasional Fractional Truncation exception back from the driver. Never had a problem inserting a String using the setObject() method though.
    Hope this helps

Maybe you are looking for

  • Site to Site VPN with Overlapping network and other network Access..

    Hi all, i need to setup a site to site Tunnel to a remote site. My remote site got the network which has overlapped with one of our network(192.168.10.0/24) in my site. remote site dont need to access this network(192.168.10.0/24) in my site ,but the

  • Host command not working properly

    Hi, I am using oracle forms 10.1.2.0.2. In my form, I need to call a unix shell script. { Oracle forms will run on application server. Unix will run in a development server. (Both the servers are different) From forms, if I click a button, it should

  • It is possible to change the Inhibit signal to active high (7344 controller)?

    Normal the controller 7344 generate an Inhibit signal active low. We can receive this signal from the UMI 7764, and send it to the motor drive. We have a Nanomotion drive type AB-5. For that type of drive the is the Enable signal that is active low.

  • How to use the DISPLAY RECORD Setup Command in an etext file?

    Hi All, How to use the DISPLAY RECORD Setup Command in an etext file? I want to display a <NEW RECORD> conditionally. The condition will be based on the data coming through from the xml file. Please help me with an example. The BI User guide also doe

  • Can receive mail, see first lines but blank when opened....

    Hi there, I have been using my iPod Touch without problem for months. Got it updated last week and now I have a problem with my mail. I can receive new mail and the first few lines are displayed, but when I click on it to open it and read it, all the