Date/Time sequence generation

Hello,
NB: database is currently Oracle 8i (circumstances), migration to Oracle 9i is planned but not imminent.
I have timestamped data logged to a database. The logging of the data
occurs every second, but to reduce space constraints unless data falls
outside a deadband it is not logged to the database.
I'm looking for routines or methodology to fill in the missing data using
SQL or PL/SQL (I have already written Java to do this on the client
side but my gut feeling is that server side manipulation of the data in
PL/SQL or even straight SQL would be more efficient)
For example, given the following data where the time stamp is
YYYYMMDDHH24MISS:
Timestamp TagValue
20030328080000 -10
20030328080005 0
20030328080010 -10
20030328080020 -20
I would need to produce:
Timestamp TagValue
20030328080000 -10
20030328080001 -10
20030328080002 -10
20030328080003 -10
20030328080004 -10
20030328080005 0
20030328080006 0
20030328080007 0
20030328080008 0
20030328080009 0
20030328080010 -10
20030328080011 -10
20030328080012 -10
20030328080013 -10
20030328080014 -10
20030328080015 -10
20030328080016 -10
20030328080017 -10
20030328080018 -10
20030328080019 -10
20030328080020 -10
Data in this example has changed frequently but in real life the data
does not change for days. The purpose of filling in the holes in the data
is to allow complete reuse of the client side code which depends on the
data being in the 1 second format. Previously data was logged to a
custom binary file and when retrieved it was automatically put into the
1 second format. The logging is being ported to and Oracle backend
and I'm involved with updating of the client.
Long winded description boils down to:
Given two arbitrary timestamps, how do I generate all timestamps
between them using a given interval (i.e. above we use 1 second,
however request might be for 5 second, 1 minute, or 1 hour data
interval)??
Doing this on the server side will allow easy migration to the current
client and then easy update of the client as many of the routines which
currently iteratively process the data could be replaced by simple
queries (averages, sums, dates when certain events occurred, etc).
Thanks.
-- John

This is kind of ugly, but it does the job.
SQL> SELECT TO_CHAR(ev_dt,'yyyymmddhh24miss'),val
  2  FROM t;
TO_CHAR(EV_DT,        VAL
20030328080000        -10
20030328080005          0
20030328080010        -10
20030328080020        -20
SQL> SELECT dt,NVL(val,(SELECT val
  2                     FROM t
  3                     WHERE ev_dt = (SELECT MAX(ev_dt)
  4                                    FROM t
  5                                    WHERE ev_dt <= TO_DATE(dt,'yyyymmddhh24mi
ss')))) val
  6  FROM (SELECT TO_CHAR(start_dt + ((rownum -1)/24/60/60),'yyyymmddhh24miss')
dt
  7        FROM (SELECT MIN(ev_dt) start_dt, MAX(ev_dt) last_dt
  8              FROM t),
  9             (SELECT 1
10              FROM dba_tables
11              WHERE rownum <= (SELECT ((MAX(ev_dt) - MIN(ev_dt))*24*60*60)+2
12                               FROM t))
13        WHERE start_dt+(ROWNUM/24/60/60) <= last_dt+(1/24/60/60)) a, t b
14  WHERE TO_DATE(a.dt,'yyyymmddhh24miss') = b.ev_dt(+);
DT                    VAL
20030328080000        -10
20030328080001        -10
20030328080002        -10
20030328080003        -10
20030328080004        -10
20030328080005          0
20030328080006          0
20030328080007          0
20030328080008          0
20030328080009          0
20030328080010        -10
20030328080011        -10
20030328080012        -10
20030328080013        -10
20030328080014        -10
20030328080015        -10
20030328080016        -10
20030328080017        -10
20030328080018        -10
20030328080019        -10
20030328080020        -20
21 rows selected.No guarantees on performance on a big table.
TTFN
John

Similar Messages

  • TS3297 My 2nd generation ipod touch is giving me the following error when I try accessing Itunes or the app store. "Cannot connect to the Store. A secure connection could not be established. Please check your date & time settings"  I am on a secure networ

    My 2nd generation ipod touch is giving me the following error when I try accessing Itunes or the app store. "Cannot connect to the Store. A secure connection could not be established. Please check your date & time settings"  I am on a secure networkl.

    Can't connect to the iTunes Store
    Make sure that time zone is correct in addition to date and time

  • Files/clips import sequence not according to date/time

    When I import files/clips the sequence of is all muddled-up it looks the last files/clips according to the date/time are positioned first and first files last - why would this be and how can I resolve the problem?

    There may be another case, at administration level: if you have several SPO workprocesses, the sequence of printing may not be respected: SPO 1 processes DO while SPO 2 processes INV for example. A solution to this is to use "print sequentially" flag in output device definition (this may not work at exceptional moments, when SPO workprocess exceptions occur, this is detailed in SAP notes).

  • Lookout Warning - logged data out of time sequence

    Hello,
     what mean a warning :You have logged data out of time sequence. Repeated instances of logging "backwards" in time can result in overly large database files, and even data corruption.
    When we use Lookout 6.1 and the Logger object to write data to citadel DB.
    Pavel Rucka. 

    For example, last time you logged value 10 at 10:00:00, then now you log a new value at 9:58:00, you will get the warning.
    If the time datamember of Logger is not set, it will use the system time when it logs. The warning will happen when your system time is set back.
    This is just a warning. The data will still be logged.
    Ryan Shi
    National Instruments

  • Single image sequence generation. ?

    Hello, ..
    Essentially, I'm looking to find the best solution, to the idea of building sequences where and with using - importing, different sequencial, single images.
    — To be clearer perhaps, I'm a Weather student / enthusiast, and this would be toward generating a sequence / different sequences .. of hourly weather-satellite obtained images.
    To this point, or up until very recently, and in fact for several years previous, I have - in fact, been able to do this fairly simply, with using an older version of QuickTime (older logo, I think that main version offered still, through "Tiger".) and, with once I've dropped a first or more initial image more in particular, into the application, then merely dragging and dropping whichever others into its main viewer-window, checking save, and naming the file.
    — Perhaps, unorthodox. But, it's worked just fine for the idea.
    — And, of course, this idea can't be used with the newer version/s of QuickTime.
    "very recently": .... Today, and with having been using this method of "simple sequence" generation, together with older version of QuickTime, on my relatively new "iMac", and running Snow Leopard, Mac OS X v. 10.6.8 - all up to date, ....
    .. I've found that I'm no longer able to access the older version of the application.  (I think this advent, might be related to a "MacKeeper" clean-up that I did recently. ....)
    — In fact, the main reason that I can't say more exactly, which version it is - or was, in fact.
    Beyond this question more general, I'm thinking — (Something, I think that I'd read at one point in the past.) — that I can in fact do what I've suggested above, with / within QuickTime Pro.
    Hope this is clear - at all.
    Any help. ?
    Appreciate your response and time.

    Opening an "image sequence" (folder of sequentially named same dimension files) is a feature found only in QuickTime Player Pro.
    Beginning with Snow Leopard the OS includes QuickTime Player X (in Lion it is 10.1) in the Applications folder and QuickTime 7.6.6 is moved to the Utilities folder.
    QuickTime X has its own feature set but can't be upgraded to "Pro".

  • How to keep date time line in  collected alert message in linux platform

    Hi Friends,
    In linux server for 11g oracle. how do I keep date time line for each error message?
    example as
    cat alert_test.log | grep 'ORA'
    grep 'ORA' alert_test.log
    I like output as
    Mon Aug 20 01:54:29 2012
    ORA-01560 caused by SQL...........
    I know we can use diag... But I want to some linux command for my debug.
    Thanks
    newdba

    Another option is to make your alert log accessible as an external table.
    Demo here:
    http://www.morganslibrary.org/reference/externaltab.html
    Find "alert log" on the page. Add a numeric column to the table and create a sequence and you can put in a surrogate row number that will allow you to pull sections using LEAD and LAG as you please.

  • Aperture 3.2: renaming based on date/time doesn't work properly

    While importing I rename my photos based on the date/time they were taken.
    In Aperture 3.1.3 this worked perfectly fine; for photos taken within the same second Aperture added an index number for the second, third etc. photo automatically.
    In Aperture 3.2 this doesn't work any longer; Aperture simply doesn't import photo number 2, 3 etc. of that particular one second.
    Note: I store the original files outside the aperture library, all run under snow leopard on an iMac i7. And as I said this worked fine under 3.1.
    Does anyone have an idea?

    Thanks all for the response
    Leonie, here are the details of what I do/experience:
    a) Aperture message after import
    b) I import pairs and rename them as follows “IMG_{Image Date}_{Image_Time}” (I know all the disadvantages of this but old habits are hard to break… and for me it still works fine)
    c) Difference of the images that are imported / not imported is solely the hundredth of the second when they were taken. Of my test series only the first image has been imported:
    DSC_4903.jpg(2011/10/19 22:49:50.08)
    DSC_4904.jpg(2011/10/19 22:49:50.25)
    DSC_4905.jpg(2011/10/19 22:49:50.43)
    DSC_4906.jpg(2011/10/19 22:49:50.60)
    DSC_4907.jpg(2011/10/19 22:49:50.80)
    d) I import via the import panel: Import in new project – storefiles in particular folder (not Aperture library) – subfolder ‘imageyear/month” – rename as described above – import both
    Doug, after some trial and error I agree with your thoughts, Aperture apparently simply lost its automatic indexes ‘-1’, ‘-2’ etc. and – what is good - doesn’t overwrite the first with the second and the third image... As you suggest there are different options to make the images unique. Most simple would be to add {index #} or {sequence #} or {counter}, all would do and I probably will choose one of them. Or I will downgrade back to 3.1.3 (do have backups) and wait until Apple fixes this.
    Kirby, turnoff “Don’t import duplicates” was a good idea but didn’t solve it. But your naming convention actually ensures the uniqueness of the files.
    Michael

  • FCP 6 - How to sort clips (photos) by Date/Time (only)?

    Hello All;
    I am trying to do something farily simple (I think) but it doesn't seem to be working.
    Here's my situation - I am creating a video slide show in FCP consisting probably of about 250 photos from about four different sources but all taken over about 4 days. I imported all of them into a single bin of FCP. I simply want to order each of those photos by the DATE/TIME. If I right-click, I am only able to order by filename or size. However, it I right-click and select "view as list", I am able to reorder by date but it even though it does reorder by date, they are still sorted by filename so this isn't what I want.
    Anyone know an easy way (preferably) that i can order a directory exclusively by date/time irrespective of the filename or any other item which I can then move into a FCP timeline ?
    Thanks.
    Tim

    Get a copy of [File Sequencer|http://www.johnnarun.com/file_sequencer>.
    Place your photos into a folder and set it to List View, sorted by creation date.
    Start File Sequencer and determine a starting number, then point it at the folder of images.
    You can then import the images into FCP in the right order. They will be sorted by their new name.
    It's pretty much self-explanatory to use but you might want to do this on a small batch of copies of your images first, to get the hang of it.

  • Updating EXIF date/time in XML files (Bridge CS4)

    Is there a way to re-read the EXIF date/time information from RAW camera files and update that existing information in the XML files?

    To my knowledge not with Bridge, maybe with a script.
    Basically the problem occurs while using multiple camera's that have not all the same correct date and time. To my experience the quickest way is to bite the bullet once and using the filters for date time for each dslr and apply labels to each dslr, then manual select the correct sequence and rename the whole bunch with a sequence number in front of all the filenames so you can use filename to sort the correct order.
    And after this of course check next time all date and time settings before starting a new job :-)

  • How to serialize the IDoc of DEBMAS by time sequence?

    Hi experts,
    We want to transfer customer master data from one client to the other.
    We have carried out the serialization distribution for message type DEBMAS
    and actived the change point.
    Scenario:
    time 1 : We created one "NEW" customer 100436.
    time 2 : We assigned the Head Office of "existed" customer100435 as 100436
    The time of the distribution job was arrived,
    the job started to run and failed to change "existed" customer 100435
    even though "NEW" customer 100436 has created sucessfully.
    We think the IDoc should be processed by time sequence,
    but it seems not.
    Did you think it is processed by customer key ascendence ?
    How do we define the process sequence of the IDoc?
    Any advice will be appreciated.
    Regards,

    But what if i want to check the format of date that my
    database supports ?
    Actually situation is :
    I am making a form designer by which user will inset
    date to a particular column. okay.
    now the format of date must match with the underlying
    format of database. Then only query will be
    successfull. Is it not so.?No.
    Basically you will be doing the following:
    Browser -> java.util.Date
    java.util.Date -> JDBC -> database
    JDBC does the 'conversion' work for you, you just need to put it in the java.util.Date.
    suppose database table-> column's format is
    YYYY/DD/MM Databases don't store dates like that. They usually (probably always) store it as a signed integer value which is relative to a specific date/time.
    When you use a database tool to look at the value the database tool converts it from the number to a format that looks familar to you.
    and user enters date in the format
    DD/MM/YYYY, then i will have show an error message to
    the user that the format of date that he has entered
    is wrong. No need for that.
    The user does need to put the date in in a form that you understand. So you can convert it to a java.util.Date.
    java.text.SimpleDateFormat can help with that.

  • Sort by EXIF Date/Time

    Would be nice to be able to srt by EXIF Date Time Original or EXIF Date Time Digitized. The existing file based Date Time Create or Date Time Modified may not be accurate. Some of our events (like a wedding) have photographs taken from a number of photographers and some of those files have been copied at some point before getting to editing, so the file Date Time Created is no longer correct. The file Date Time Modified sometimes works for us, but may not be reliable either. Right now we have a program that copies the file Date Time Modifies to the file Date Time Created, which usually works ok. Using the EXIF data would let us sort all of the aggregated shots by their original create date so that they are in the proper shoot sequence, without having to deal with all of this.

    Does anyone know how to sort files in bridge( or any other program0by time created?

  • 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.

  • Date/Time On Main Menu

    Hey, Apple!
    Can you guys add the current date/time to the main menu of the Apple TV (2nd generation) with the next iOS update? The Apple TV is the only iOS device I own which doesn't display the current date/time.
    Thanks!

    Yes, I could but that's so last century.

  • Need to arrange photos according to date/time taken, three synced cameras

    Hello, we recently shot a wedding using three different cameras (with inner clocks synced).  Now I need to combine them into one folder and arrange in correct sequence according to date/time taken.  Can't figure this out.  Using Photoshop full version.

    Put them in one folder and in Bridge Sort by date created.

  • How to control time sequence for handshaking

    Hi all,
      I am reading some material about using VISA to control the data input/output to external device (in serial or parallel port). For some device, it needs a precise time sequence for handshaking to 30 nanosecond, I wonder if it is possible to control from OS level to make such short time interval? I am using Labview 2011 and Windows7 32 bits

    Greetings phlins
    In general, software time operations in Windows won't go beyond 1ms. Even if you use an RT OS, accuracy won't go further than micro seconds. Only FPGA or hardware timed tasks can handle nanoseconds. This is regarding digital operations in general.
    You may want to check this document:
    http://digital.ni.com/public.nsf/allkb/D37754FFA24F7C3F86256706005B9BE7
    It talks about the supported baud rates for NI-VISA. With this, just make the conversión to the actual time each baud rate handles and compare it to your requirements.
    Finally, when you said this handshaking is for a device, have you considered searching for a device driver? There are many device drivers available for LabVIEW, if i may ask, wich external device are we talking about?  
    Luis J.
    Applications Engineer
    National Instruments

Maybe you are looking for

  • Problem with Mail For Exchange over Nokia E7-00 (a...

    Hi, I have a problem with my nokia E7-00 (Symbian Anna). Until recently it worked fine with my terminal synchronization with GMAIL via Mail For Exchange. I synchronized the mail (including folders / labels I have on my account), address book and cale

  • READ_TEXT IN FORM AND PERFORM

    Hi all. I have an issue in Scripts. we are using standard program as print progarm and a zform as form. we want to print some text in themain window of the form. for that one I created a new progarm for form and perform. in taht form i am using this

  • License key won't "stick"

    Hi, I'm administering a Contribute site for about 20 users. I installed and licensed all of my authors' copies of 3.0 without incident with one exception: one user's license key won't "stick"--she's prompted for the license number every time she open

  • I have an error 1015 what do i do

    i have error 1015 what do i do

  • Cisco UCS C220-M3 Server doesn't boot after adding Intel I350 Quad Port NIC

    Hello, We have purchased 2 Cisco UCS C220-M3 rack mounted servers (Single Processor) that have a dual port I350 LOM. We also purchased two Intel I350 Quad Port NICs to expand the available ports on each server from 2 to 6. The problem we are facing i