Subquery nested in INSERT statement

I’m hoping I can get some help. I am trying to call on a foreign key for this INSERT. I’m new and my other resources aren’t responding to this question yet. Below is the subquery that I believe is causing me issues as well as the entire INSET statement.

(SELECT contact_lab_id
FROM contact_lab
WHERE first_name = ‘John’)

INSERT INTO address_lab
( address_lab_id
, contact_lab_id
, address_type
, city
, state_province
, postal_code
, created_by
, creation_date
, last_updated_by
, last_update_date)
VALUES
( address_lab_s1.nextval
, (SELECT contact_lab_id
FROM contact_lab
WHERE first_name = ‘John’)
, (SELECT common_lookup_lab_id
From common_lookup_lab
Where common_lookup_context = ‘MULTIPLE_LAB’
And common_lookup_type = ‘HOME’)
, ‘Draper’
, ‘Utah’
, ‘84020’
, 1001
, SYSDATE
, 1001
, SYSDATE);

[code]INSERT
INTO address_lab
( address_lab_id
, contact_lab_id
, address_type
, city
, state_province
, postal_code
, created_by
, creation_date
, last_updated_by
, last_update_date
)
SELECT address_lab_s1.nextval
, contact_lab.contact_lab_id
, common_lookup_lab.common_lookup_lab_id
, ‘Draper’
, ‘Utah’
, ‘84020’
, 1001
, SYSDATE
, 1001
, SYSDATE
FROM contact_lab
CROSS
JOIN common_lookup_lab
WHERE contact_lab.first_name = ‘John’
AND common_lookup_lab.common_lookup_context = ‘MULTIPLE_LAB’
And common_lookup_lab.common_lookup_type = ‘HOME’

[/code]

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.