Tuesday, April 3, 2012

Sequence-less key generation

Sometimes you need a distinct key, but don't want the added overhead of consulting a sequence or are attempting to make your code as light as possible (read: less object dependencies) for portability.
There are obvious downsides to this method, but it has it's use cases.
In my case, I have a procedure that needs to get a 'key' for a bunch of dbms_scheduler jobs it's about to kick off so that it can monitor them and register/get alerts.
I generate this key @ the start of the procedure and then use it as my key for the rest of the process. Could this procedure be kicked off @ the exact same time and therefore generate the same key? Yes. Do I care? No, not in this case.
SELECT to_char(SYSTIMESTAMP AT TIME ZONE 'GMT', 'DDMMYYYYHH24MISSFF3') FROM dual;

No comments:

Post a Comment