Why is this an invalid trigger?

Hello

I have a problem with a trigger. After creating the trigger it gives me the message
invalid trigger type
, I have this table
create the USER table
(
U_ID NUMBER (6) not null,
U_NOME VARCHAR2 (60) not null,
U_SEXO VARCHAR2 (10) not null,
U_IDADE NUMBER (3) not null,
U_ALTURA NUMBER (3) not null,
U_PESO NUMBER (6) not null,
U_IMC NUMBER (2.2).
U_PRIVILEGIOS NUMBER (1) not null,
U_PASSWORD VARCHAR2 (10) not null,
primary key constraint PK_UTILIZADOR (U_ID)
);
and if I do this:
INSERT IN USER (U_ID, U_NOME, U_SEXO, U_IDADE, U_ALTURA, U_PESO, U_PRIVILEGIOS, U_PASSWORD) VALUES (1, 'my name', 'Male', 32, 174, 74000, 0, 'password');
and then
SELECT * FROM USER;
I see that everything goes as planned.

What I want to do, it's when you insert or update of U_ALTURA or U_PESO, the U_IMC field is automatically updated / inserted.

Here is if:
CREATE OR REPLACE TRIGGER CALCULA_IMC
AFTER INSERTION OR THE U_ALTURA UPDADE, U_PESO ON THE USER
FOR EACH LINE
BEGIN
UPDATE USER
SET U_IMC = (U_PESO / 1000) / (POWER(U_ALTURA / 100,2);
END;
/
Can someone please tell me what I'm doing wrong?

Kodiak

898791 wrote:
What I want to do, it's when you insert or update of U_ALTURA or U_PESO, the U_IMC field is automatically updated / inserted.

Here is if:

CREATE OR REPLACE TRIGGER CALCULA_IMC
AFTER INSERTION OR THE U_ALTURA UPDADE, U_PESO ON THE USER
FOR EACH LINE
BEGIN
UPDATE USER
SET U_IMC = (U_PESO / 1000) / (POWER(U_ALTURA / 100,2);
END;
/

Can someone please tell me what I'm doing wrong?

Kodiak

There are a few problems with your relaxation. First of all, it is UPDA * T * E not UPDA * D * E. More important still, you cannot update the table that you created the trigger on, and you can't do that in an after trigger. Finally, even if you could do it the way you are trying to do, update you every row in the table for each insertion and update.

You need something more like:

CREATE OR REPLACE TRIGGER calcula_imc
   BEFORE INSERT OR UPDADE OF u_altura, u_peso ON utilizador
   FOR EACH ROW
BEGIN
   :new.u_imc := (:new.u_peso / 1000) / (POWER(:new.u_altura / 100, 2));
END;

John

Tags: Database

Similar Questions

Maybe you are looking for

  • Satellite A100-599 - hibernation process hangs

    Hello. I have problem with hibernation in Vista.He worked initially but later something was wrong, and now hibernation freezes.I have just white screen and the computer never stops (HDD light is always on). Looks like it hangs during the hibernation

  • Is there a sleep timer hide in my new Apple TV?

    I know that I can put my Apple TV in standby mode or after inactivity it will go on its own; However, I want a timer.  I want the TV and Apple TV power off after 60 minutes so that I don't use data while he slept.  IIf there is a work around for that

  • Error in Windows Mail - "error 623 - system could not find the directory entry for this connection".

    Original title: Windows Vista, Windows Mail, error 623, unable to connect to the mail.This problem occurred after a storm. Modem was fried.  Replaced the modem with the modem "2wire" ATT. Now get "error 623: the system could not find the directory en

  • Meaning of SRI?

    I'm just curious to know what the "integrated" in the international search report is actually referring sm. Is he referring to the fact that several forms of WAN interface are integrated into a single router? Thanks for the clarification.

  • VPN Tunnel established but no LAN access

    I have an embarrassing problem where more remote site PCs are accessing resources HQ LAN very well using the VPN Client (v4.6) connecting to a Cisco PIX 515E. Any PC running Windows XP SP2 with the firewall off o/s. A PC site however establishes the