I have the following 3 tables,
Data_Excel contains the names, address, city and source of person;
Person table has the name and ID;
I need to insert into person_location the address source, address, city and ID...
I am using the following query :
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;
but I get the following error. I am using seq because ID is the primary key in persons but its not auto incrementing. I also tried that but there was an error :
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.
Try moving the sequence out of the grouping query:
INSERT INTO Person (id,Name,source)
SELECT seq.nextval, p_name,source FROM (
Select 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
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With