1

Topic: The help in trigger writing.

Hello, your help is very necessary. For examination asked to make the trigger which at change in label VR_DOG in column DATA_OKON at change (adding/removal) of date automatically in table VR_RAB in column STATUS_RAB does following records: if there is a date "is dismissed" if there is no date - "works". Wrote the trigger, but it does not work. I do not catch up in what with business, therefore I ask about the help!

2

Re: The help in trigger writing.

Vlrznv wrote:

For examination asked to make the trigger

it is 5. On  the teacher asks?

Vlrznv wrote:

Wrote the trigger, but it does not work.

and it is 2.

Vlrznv wrote:

I do not catch up in what with business, therefore I ask about the help!

the help

3

Re: The help in trigger writing.

The trigger should be for each row.
UPDATE VR_DOG, and it is necessary VR_RAB.
Try to continue.

4

Re: The help in trigger writing.

dmdmdm wrote:

the Trigger should be for each row.
UPDATE VR_DOG, and it is necessary VR_RAB.
Try to continue.

wrote:

to label VR_DOG in column DATA_OKON at change (adding/removal) of date automatically in the table VR_RAB ...

Misprint?
.....
stax

5

Re: The help in trigger writing.

Stax;
No, not a misprint.

6

Re: The help in trigger writing.

Vlrznv wrote:

Stax;
No, not a misprint.

to do if in VR_RAB there is no record for the worker?
ps
If not a secret, asked, who?
....
stax

7

Re: The help in trigger writing.

Vlrznv;

SQL> CREATE OR REPLACE TRIGGER tr_vr_dog_aiu
2 AFTER INSERT OR UPDATE OF data_okon ON vr_dog
3 FOR EACH ROW
4 begin
5 update vr_rab set status_rab=decode (:new.data_okon, null, ' Works ', ' It is dismissed ') where id_rab =:new.id_rab;
6 end;
7 /
Trigger created.
SQL> select * from vr_dog;
ID_RAB FIO DATA_OKO
---------- -------------------- --------
1 Vlrznv 02.10.17
2 Stax
SQL> ed
Wrote file afiedt.buf
1* update vr_dog set data_okon=decode (data_okon, null, sysdate, null)
SQL> /
2 rows updated.
SQL> select * from vr_rab;
ID_RAB STATUS_RAB
---------- --------------------
1 Works
2 It is dismissed
SQL> select * from vr_dog;
ID_RAB FIO DATA_OKO
---------- -------------------- --------
1 Vlrznv
2 Stax 02.10.17
SQL>

ps
to do if change id_rab?
.....
stax

8

Re: The help in trigger writing.

Stax;
On what a hint? If primary key, unless it is possible to change it?

9

Re: The help in trigger writing.

trace.log wrote:

Stax;
On what a hint? If primary key, unless it is possible to change it?

Hint on if  changes id_rab as  it will be reflected in vr_rab
It is possible/is impossible another  smile))
ps
To a problem  no relation has, there it is unambiguous

At change in label VR_DOG in column DATA_OKON

once again not update it is possible/is necessary to add check on change with null for date and on the contrary
.....
stax