While I prepared some SQL to randomise selection of winners, I didn't get a chance to arrange the job to be executed at midnight on new year's eve.
I still wanted to schedule a job as not to be biased with results, so I picked another abitruary date instead, one that might excite the numerologists out there - Jan 2nd, 2014 at 3:45 - yep, there's a sequence in there.
Here is the code the scheduled the job, which created a table with entries in random order.
begin sys.dbms_scheduler.create_job( job_name => 'SW_PACKT_WINNERS' ,job_type => 'PLSQL_BLOCK' ,start_date => to_date('201301020345pm','yyyymmddhhmipm') ,enabled => TRUE ,job_action => q'{ begin execute immediate q'[ create table packt_contest_winners as with data as (select name, case when linked='Y' then 3 when tweet='Y' and post='Y' then 2 when tweet='Y' then 1 when post = 'Y' then 1 else 0 end entry_qty ,null rn2 from packt_contest) select xz.rn entry, entry_qty, d.name ,dbms_random.value() rnd ,case xz.rn when 1 then 'Posted comment' when 2 then 'Tweeted post' when 3 then 'Included backlink' end reason ,case when row_number () over (order by dbms_random.value()) <= 3 then 'winner!' end prize ,sysdate ts from (select rownum rn from dual connect by level <= 50) xz join (select rownum rn, name, entry_qty from data) d on xz.rn <= d.entry_qty order by rnd ]'; end; }'); end; /
You can see the results on this page http://apex.oracle.com/pls/apex/f?p=73000:22
The first three won - so congratulations to
I have contact information for all three winners, so I'll hunt you down when I have further information from Packt.
I've been busy building an APEX website over the holiday season so I haven't had a chance to try out the examples from the book yet - but I really look forward to it!
My first read showed it was really promising for Oracle Developers to really take advantage of PhoneGap as a tool to make our mobile applications even better.
As I mentioned, I'll write a fuller review once I've had a play - and I'll see how people's comments regarding the chapters of interest come through.
Here's to a productive 2014.
Scott
No comments:
Post a Comment