Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Oracle to MySQL syntax question

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.46 KB  |  views: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION)
  2. SELECT a.a1, b.ID, b.DENOMINATION FROM
  3. (SELECT rownum a1 FROM dual CONNECT BY rownum <= 10000000) a, BOOK b
  4. where a.a1 between b.START_NUMBER and b.START_NUMBER+b.UNITS-1;
  5.        
  6. for 1 to BOOK.units loop
  7.  
  8.   INSERT INTO VOUCHER (
  9.       -- VOUCHER_NUMBER handled by auto-increment
  10.       BOOK_ID
  11.     , DENOMINATION
  12.   )
  13.   SELECT
  14.       b.ID
  15.     , b.DENOMINATION
  16.   FROM BOOK b
  17.   WHERE b.ID = [book ID];
  18.  
  19. end loop