Write a recursive function in Oracle SQL -


order_id                                transact_time aaa                                     24-jul-17 04.05.54.491000000 pm aaa                                     24-jul-17 04.05.54.496000000 pm aaa                                     24-jul-17 04.05.54.504000000 pm bbb                                     24-jul-17 04.05.54.491000000 pm bbb                                     24-jul-17 04.05.54.497000000 pm bbb                                     24-jul-17 04.05.54.505000000 pm ...                                     ... 

this data (order id , transaction_time) being published table every hour or so.

i trying create function (or sql query) in oracle sql ensure every subsequent transaction time greater or equal previous entry.

basically second entry in aaa cannot have older transaction time first entry in aaa , on.

i guidance on how can go writing function. 1 idea found write recursive function, tried i'm not entirely sure going on:

        note: prev_trans_time alias generated grab transaction      time of previous transaction (meaning first entry prev_trans_time = null)          create or replace function transacttimechecker(prev_trans_time) return string         begin             if prev_trans_time > transact_time                         return (i'm not sure write                                 here need fix entries order adjusted)             elsif prev_trans_time <= transact_time                         return (we good, no problem)             else                         --do nothing             end if;         end; 

i don't think need recursion. i'm assuming prev_trans_time last used order time. want wait until new time create next transaction. function can iterate until system time goes up.

declare     transact_time date := sysdate;  begin     while (prev_trans_time > transact_time) loop         transact_time := sysdate;     end loop;     return transact_time; end; 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -