I am trying to insert the data from other table using INSERT/SELECT combo. I also need to insert increment with specific calculation. However, I can't figure out why it is not working.
I have the table (temp_business_area) like this:
----------
| bname |
----------
| London |
| Sydney |
| Kiev |
----------
I would like to have this in enum table:
-----------------------------------------------------------------
| identifier | language_id | code | data | company_limit |
----------------------------------------------------------------|
| BUSINESS_UNIT | 0 | 100 | London | 126 |
| BUSINESS_UNIT | 0 | 200 | Sydney | 126 |
| BUSINESS_UNIT | 0 | 300 | Kiev | 126 |
-----------------------------------------------------------------
But what I get is this:
-----------------------------------------------------------------
| identifier | language_id | code | data | company_limit |
----------------------------------------------------------------|
| BUSINESS_UNIT | 0 | 100 | London | 126 |
| BUSINESS_UNIT | 0 | 100 | Sydney | 126 |
| BUSINESS_UNIT | 0 | 100 | Kiev | 126 |
| BUSINESS_UNIT | 0 | 200 | London | 126 |
| BUSINESS_UNIT | 0 | 200 | Sydney | 126 |
| BUSINESS_UNIT | 0 | 200 | Kiev | 126 |
| BUSINESS_UNIT | 0 | 300 | London | 126 |
| BUSINESS_UNIT | 0 | 300 | Sydney | 126 |
| BUSINESS_UNIT | 0 | 300 | Kiev | 126 |
-----------------------------------------------------------------
And here is my loop.
BEGIN
FOR x IN 1 .. 3 LOOP
INSERT INTO enum (identifier, language_id, code, data, company_limit)
SELECT 'BUSINESS_UNIT', 0, x*100, bname, 126 FROM temp_business_area;
END LOOP;
END;
I can't figure out where am I making mistake. Help?
limit 20,10to get the specific row not sure about oracle so looking how to implementlimitin oracle might be a hintSELECT 'BUSINESS_UNIT', 0, x*100, bname, 126 FROM temp_business_area limit x, 1