Problem: Sequence / currval problem in SQL (using Ora 10.2 / HP-ux)
532673Sep 8 2006 — edited Sep 8 2006Hi all,
The business logic behind my problem
I'm checkin a weblog for same IP adresses and timestamps. If it finds the same IP adress with a timestamp of less than 4 minutes, it's considered to be part of the same session.
If the time extends 4 minutes or finds another IP adress, it's considered to be part of another session.
I created a sequence which has to issue a group key depending on an anlytic functions and a case statement: the currval for same IP and time < 4 minutes and nextval for new IP or > 4 minutes:
In my SQL this looks like:
, (case
when (log_time - (lag(log_time) over (order by C_IP , log_time))) * 60 * 60 < 240
and
lag(C_IP) over (order by C_IP) = C_IP
then ods_tmp_ip4.currval
else ods_tmp_ip4.nextval
end
) as C_IP_4_id
This always creates a new value for C_IP_4_ID.
But when I use this code:
, (case
when (log_time - (lag(log_time) over (order by C_IP , log_time))) * 60 * 60 < 240
and
lag(C_IP) over (order by C_IP) = C_IP
then 'Selecting_currval'
else 'selecting_nextval'
end
) as cur_next_ind
My cur_next_ind displays the tekst "selecting_currval' or "selecting_nextval" at the right times. But the issueing of currvals and nextvals doesn't work as anticipated.
Is this a bug, or am I'am doning something wrong, or otherwise?
Any suggestions anyone? TIA,
Toin,
The Netherlands