Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PL/SQL Trigger (PLS-00201: identifier '...' must be declared)

509 views
Skip to first unread message

Pete

unread,
Jun 6, 2005, 4:27:13 PM6/6/05
to
Hi!

I´m new to Oracle and have a problem when i try to create a trigger.
Is it possible to reference the values that should be inserted?
If yes, how is it possible?

Here is my code:

--

CREATE OR REPLACE TRIGGER test_trigger_fik
BEFORE INSERT
ON flight_intervals
REFERENCING new inserted
FOR EACH ROW

DECLARE
la_time flight_intervals.arrival_time%TYPE;
d_time flight_intervals.arrival_time%TYPE;
la_airport flight_intervals.from_airport%TYPE;
d_airport flight_intervals.from_airport%TYPE;
f_id flight_intervals.flight_id%TYPE;

BEGIN
f_id := inserted.flight_id;
SELECT MIN(arrival_time) INTO la_time
FROM flight_intervals
WHERE flight_id = f_id
ORDER BY arrival_time;
IF SQL%NOTFOUND
THEN la_time := inserted.arrival_time;
END IF;

...

END;
/
show error;

exit;

--

I always reveive the following errors:
9/2 PL/SQL: Statement ignored
9/10 PLS-00201: identifier 'INSERTED.FLIGHT_ID' must be declared
15/8 PL/SQL: Statement ignored
15/19 PLS-00201: identifier 'INSERTED.ARRIVAL_TIME' must be declared

Can anyone help me?

Thanks!
Pete


Maxim Demenko

unread,
Jun 6, 2005, 5:34:28 PM6/6/05
to
Pete schrieb:
> Hi!
>
> IŽm new to Oracle and have a problem when i try to create a trigger.

> Is it possible to reference the values that should be inserted?
> If yes, how is it possible?
>
> Here is my code:
>
> --
>
> CREATE OR REPLACE TRIGGER test_trigger_fik
> BEFORE INSERT
> ON flight_intervals
> REFERENCING new inserted
> FOR EACH ROW
>
> DECLARE
> la_time flight_intervals.arrival_time%TYPE;
> d_time flight_intervals.arrival_time%TYPE;
> la_airport flight_intervals.from_airport%TYPE;
> d_airport flight_intervals.from_airport%TYPE;
> f_id flight_intervals.flight_id%TYPE;
>
> BEGIN
> f_id := inserted.flight_id;
> SELECT MIN(arrival_time) INTO la_time
> FROM flight_intervals
> WHERE flight_id = f_id
> ORDER BY arrival_time;
> IF SQL%NOTFOUND
> THEN la_time := inserted.arrival_time;
> END IF;
>
> ....

>
> END;
> /
> show error;
>
> exit;
>
> --
>
> I always reveive the following errors:
> 9/2 PL/SQL: Statement ignored
> 9/10 PLS-00201: identifier 'INSERTED.FLIGHT_ID' must be declared
> 15/8 PL/SQL: Statement ignored
> 15/19 PLS-00201: identifier 'INSERTED.ARRIVAL_TIME' must be declared
>
> Can anyone help me?
>
> Thanks!
> Pete
>
>
>
>

Try to replace in trigger body "inserted" through ":inserted"

Best regards

Maxim

0 new messages