SHARE
TWEET

Oracle to MySQL syntax question

a guest Feb 26th, 2012 25 Never
  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
RAW Paste Data
Top