2016-07-04 88 views
-2

我在嘗試使用INSERT INTO時多次檢查過所有3條語句時都收到了一個錯誤的逗號錯誤,謝謝。ORA-00917:缺少逗號。 INSERT INTO語句

INSERT INTO staff 
(staff_id, staff_name, address, d_o_b, email, phone_number, salary, hire_date, job_role, nationality, over_time, bonus, caravan_park_id) 
VALUES 
(1.NEXTVAL, 'Simon Gould', '17 Pearson Grove', '13/10/92', '[email protected]', 07817333245, '24000', '13/10/15', 'engineer', 'Portuguese', '10 hours', '£500', 1.nextval); 
INSERT INTO staff 
(staff_id, staff_name, address, d_o_b, email, phone_number, salary, hire_date, job_role, nationality, over_time, bonus, caravan_park_id) 
VALUES 
(2.NEXTVAL, 'Josh Dawkins', '28 Mulholland Drive', '12/09/82', '[email protected]', 07801123456, '15000', '02/05/11', 'engineer', 'English', '6 hours', '£300', 2.nextval); 
INSERT INTO staff 
(staff_id, staff_name, address, d_o_b, email, phone_number, salary, hire_date, job_role, nationality, over_time, bonus, caravan_park_id) 
VALUES 
(3.NEXTVAL, 'Michelle Arazanguiz', '75 Newport Way', '21/03/90', '[email protected]', 07323456456, '16000', '05/11/08', 'tour guide', 'Spanish', '0 hours', '£0', 3.nextval); 
+0

什麼是phone_number類型?是薪水類型字符串? –

+2

什麼是1.nextval?這是一個序列嗎? – DavidG

+1

我敢打賭,你還有其他問題,但是由於你似乎想對'staff_id'和'caravan_park_id'值進行硬編碼,所以你不需要'.nextval'部分。我很好奇,是什麼讓你想要首先構建價值。 – sstan

回答

1

the Oracle documentation,您的查詢應該是這樣的:

INSERT INTO staff 
(staff_id, staff_name, address, d_o_b, email, phone_number, salary, hire_date, job_role, nationality, over_time, bonus, caravan_park_id) 
VALUES 
(staff_id.NEXTVAL, 'Simon Gould', '17 Pearson Grove', '13/10/92', '[email protected]', 07817333245, '24000', '13/10/15', 'engineer', 'Portuguese', '10 hours', '£500', caravan_park_id.nextval); 
INSERT INTO staff 
(staff_id, staff_name, address, d_o_b, email, phone_number, salary, hire_date, job_role, nationality, over_time, bonus, caravan_park_id) 
VALUES 
(staff_id.NEXTVAL, 'Josh Dawkins', '28 Mulholland Drive', '12/09/82', '[email protected]', 07801123456, '15000', '02/05/11', 'engineer', 'English', '6 hours', '£300', caravan_park_id.nextval); 
INSERT INTO staff 
(staff_id, staff_name, address, d_o_b, email, phone_number, salary, hire_date, job_role, nationality, over_time, bonus, caravan_park_id) 
VALUES 
(staff_id.NEXTVAL, 'Michelle Arazanguiz', '75 Newport Way', '21/03/90', '[email protected]', 07323456456, '16000', '05/11/08', 'tour guide', 'Spanish', '0 hours', '£0', caravan_park_id.nextval); 

也就是說,使用staff_id.NEXTVALcaravan_park_id.nextval指示要在這兩個序列的下一個值。

+0

要明確,這個答案的前提是存在稱爲'staff_id'和'caravan_id'的序列。 – APC