Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

create trigger that checks if field on different table exist

user10683509May 30 2011 — edited Jun 1 2011
Hi i am trying to create a trigger that when the user tries to insert data on table A column 1 check first on table B column 1 if id exist if not decline entry, this what i got so far but i get the error

ORA-04071: missing BEFORE, AFTER or INSTEAD OF keyword

create trigger check_artists
on RECORDINGS
for insert, update as
if not exists (select * from ARTISTS, RECORDINGS
where ARTISTS.artist_id = RECORDINGS.artist_id)
begin
print "Illegal Artist_ID!"
rollback transaction
end
go

i have also tried with the before keyword but then says something like invalid trigger sintax help please
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 29 2011
Added on May 30 2011
25 comments
6,053 views