【发布时间】:2013-11-21 10:58:41
【问题描述】:
我有以下3张表,
Data_Excel 包含人的姓名、地址、城市和来源;
Person表有名字和ID;
我需要在 person_location 中插入地址来源、地址、城市和 ID...
我正在使用以下查询:
CREATE SEQUENCE seq
START WITH 6571
MINVALUE 6571
INCREMENT BY 1
CACHE 100
INSERT INTO Person (id,Name,source)
Select (seq.nextval),p_name,source
FROM Data_Excel
WHERE P_Name NOT IN
(SELECT name FROM Person)
GROUP BY P_Name,P_Address,P_city,Source
HAVING count(*) < 2;
但我收到以下错误。 我使用 seq 因为 ID 是 people 的主键,但它不是自动递增的。我也试过了,但有一个错误:
02287. 00000 - "sequence number not allowed here"
*Cause: The specified sequence umber (CURRVAL or NEXTVAL) is inappropriate
here in the statement.
*Action: emove the sequence number.
【问题讨论】:
标签: sql oracle11g oracle-sqldeveloper sql-insert