Trouble Finding a Date



  • I'm currently working on such a problem (PL/SQL) and it seems that (at least in my case),



    declare

      r_foo%rowtype;

    begin

      select * into r from (select * from foo order by bar) where rownum=1;

      process_foo(r);

    end;



    is faster than the loop-exit construct and also gives correct results. But it is ugly ;-)



  • @Mike Dimmick said:

    The Kerberos authentication protocol used in Active Directory domains requires that client machines have as small as possible time offset from the server - this allows the protocol to have short-lived validity on packets, preventing captured packets from being replayed. In a domain, by default, workstations and member servers get their time from the domain controller. The IT department should ensure that the DCs are synchronised with an external source.

    I'm using a similar time-sensitive authentication method (in-house application), but I just have the client get the time from the server first, so it can use that as its timestamp. Bit more network traffic, but with client running op to 10 minutes difference here it saves a lot of trouble.

    Drak



  • <FONT style="BACKGROUND-COLOR: #efefef">The Real WTF i see in this world is a developer trusting a clock on a client machine. If you are doing time critical tasks (or even doing an invoice for an accounting package), a bad date will kill you.</FONT>

    <FONT style="BACKGROUND-COLOR: #efefef">NNTP is fine, but users can change the data at will, or their clocks can skew.</FONT>

    <FONT style="BACKGROUND-COLOR: #efefef">Anyone who has written a multi-user, time critical system and used the local PC's time needs a WTF.</FONT>

    The incorrect use of the data access, in this case, is a WTF.

    <FONT style="BACKGROUND-COLOR: #efefef"></FONT> 



  • >You are wrong Alex.

    >In VB6 a and b will be Variants and c an Integer.

     

    Thanks, I thought I had lost it.

     

    T.



  • I think he wrote it this way because as stated in the intro, he wanted a date

    He converts to varchar(30) in the hope this will somehow give him a 30 year old date.

    He also is hoping for many dates so sets up the loop, but as soon as gets one he's happy so he exits the for loop - he doesn't want to double date you know.

    What's a little bit worrying is that he doesn't specify the sex he's after



  • "There was a rounding issue with some (very large) dollar amounts. "

    It sounds like you were using floating point to represent dollars and cents.  That's almost always a mistake, if not a wtf, due precisely to the kind of rounding errors that you describe.



  • "No, they fixed that in VB.NET."

     

    you mean they BROKE it in VB.NET.

     

    If code was relying on this behaviour as would be quite reasonable previously, doing this BREAKS code.

     

    Any other organisation updating a language works VERY hard to ensure that they do NOT break old code, MS go out of their way to break old code.

    Think of PERL 3/4/5 etc?

    Think of

    #include <stdio>

    vs

    #include <stdio.h>

    I know says mickeysoft, lets make all these OTHER developers revisit billions of lines of code.

    that will keep them busy while we get onto the next big thing.



  • @loneprogrammer said:

    @memorex said:
    Also- -FREQUENTLY- clocks skew too much and you
    can't rely on IT to get their act together, so you pick a time
    authority like the most important DB and get on with it.


    Don't you know IT staff have more important things to do than to walk
    around the office, setting computer clocks to the right time?






    No, but they could at least set the domain server to synchronize with,
    I don't know, the Navy (or someone else with an ATOMIC clock).



    One setting on one computer and everybody on the network has accurate time when they log in.



    But in a distributed app, knowing the server time could be very
    important.  There is nothing wrong with the concept, except I
    wouldn't bother formatting the date on the server, and I would
    certainly not use a DataSet for one value.



  • @Anonymous said:

    @loneprogrammer said:


    If you have ever gotten the message from make(1) that says "file has
    modification time in the future" you would know sub-second accuracy is
    NOT overkill for a workstation.






    When would this ever be an issue, assuming that you use some sort of VCS?


    If your files are mounted from an NFS server that has a different time,
    then you can have "future" timestamps from files that were just created.




  • The intro reminds me of my favourite dilemma for females looking for a male in IT:

        The odds are good, but the goods are odd

    (think I read it on bash sometime)



    :P






  • querying a tier 1 ntp server from deep within a network is a big nono.
    Best practices stipulate that an internal DC should query an upstream
    ntp server...minimally something like the authoritative ns or nominally
    the ISP's designated tier2 server.



  • Re: check time on server because client might be off...



    It's actually a fairly common practice to try to work around license
    expiration by setting the clock on your machine back a few days.



  • @loneprogrammer said:

    If your files are mounted from an NFS server that has a different time,
    then you can have "future" timestamps from files that were just created.


    I'd say this is bad coding on Make's part, demanding perfect time sync
    across network shares, especially given that some protocols/filesystems
    have 1-2s maximum skew windows.



    @fatgeekuk said:
    you mean they BROKE it in VB.NET.


    Hi mistah troll. ^_^



    Not sure if you've compared VB6 vs VB.Net, but they're quite different
    languages. The only reason that bug made it beyond VB2 was the need for
    backward compatibility; when they created a whole new language and made
    it look a little like VB, they re-evaluated all backward-compatible
    syntax and threw out the unintuitive ones that caused a lot more
    mistakes they fixed. (Compare this to the need to recode most large
    linux apps every new even version and/or library upgrade.)



    So don't get your britches all in a bunch.



    p.s. #include <algorithm> has worked fine in the last few
    versions of MSVC, I don't know what planet you live on, but #include
    <stdio> has never been standard C++; you have to use #include
    <cstdio>. Just because it's an extension a few compilers use
    doesn't make it a standard.



  • @ammoQ said:

    I'm currently working on such a problem (PL/SQL) and it seems that (at least in my case),



    declare

      r_foo%rowtype;

    begin

      select * into r from (select * from foo order by bar) where rownum=1;

      process_foo(r);

    end;



    is faster than the loop-exit construct and also gives correct results. But it is ugly ;-)




    Can't you do

    select top 1 * from foo order by bar

    in PL/SQL? You can in TRANSACT-SQL, and I believe TOP is standard...



  • Actually I do a getDate on the SQL box at application start up right now, because it's time sensitive, and if the clock on the PC is out by a few minutes there will be rather large problems.



  • @Candle said:

    how about:
    select * into r from foo where [] order by bar limit 1;

    thus you only get the one row selected, this can be quite useful when you want to select a random row from a table:
    select * from [table] order by rand() limit 1



    @Maurits said:

    Can't you do

    select top 1 * from foo order by bar

    in PL/SQL? You can in TRANSACT-SQL, and I believe TOP is standard...





    Thanks for your proposals, but unfortunately none of the above works in Oracle (at least not in 8i nor 9i). It's done like this:



    select * from (select * from table order by xxx) where rownum=1;



  • @Candle said:

    select * from [table] order by rand() limit 1




    Does this work?  Doesn't in TRANSACT-SQL - Rand() is generated once, not once per row.



    I've run into this when trying to put random defaults on a
    column.  Do a multi-row INSERT and they all get the same value for
    their random data.



  • some times you need a central time authority for stations... While minutes might matter, I can't imagine that whole days are that important...

    It does seem like a wasteful way to get the date tho, why not just HTTP to a reliable server and check the date/time header <evil chuckle>??



  • Nope, it's not what, it's when.



  • @Anonymous said:

    "There was a rounding issue with some (very large) dollar amounts. "

    It sounds like you were using floating point to represent dollars and cents.  That's almost always a mistake, if not a wtf, due precisely to the kind of rounding errors that you describe.

    Nope, we were storing dollar amounts as Currency, but we were multiplying and dividing them by floats.


  • Hah!  In my group there are only three Steves, and four girls!  [:D]

    However, one of them is a lesbian... [:S]

     



  • @Candle said:

    how about: select * into r from foo where [] order by bar limit 1;

    what dialect of SQL is that? T-SQL has "top 1", not "limit 1"



  • @Alex Papadimoulis said:

    To clarify ...Dim a,b,c As Integer

    VB6: Declares "c" as an Integer, "a" and "b" as Variant




    How very, very silly.

    And the SQL thing is actually defensible if you don't know anything about the network where it's being deployed; indefensible otherwise.


  • @sas said:

    Hah!  In my group there are only three Steves, and four girls!  [:D]

    However, one of them is a lesbian... [:S]



    There you are then! Balance is maintained! (Tho it's a little hard on the lesbian girl). If one of the Steves leaves, expect one of the girls to be run over by a bus, or something.


  • @memorex said:

    This is valid if the DB has the time that's critical to the rest of the system, and since you normally do things like insert a record using getDate(), then all those dates, etc, have the DB's time.

    Except of course you'd let the database insert it.

    However my last system did get the date from the database, because it's important that the client is roughly the same (validation and imports)



  • Brillant! [:P]


Log in to reply