Insert, delete, update [message #80977] |
Fri, 20 December 2002 01:18 |
Solve
Messages: 38 Registered: December 2002
|
Member |
|
|
Could somebody help me with inserting, deleting and updating records? For example, if I have parent table and child table and then I delete parent table's record, I would like to chech if there is no data on child table. So, I think that I have to write a trigger (on insert) or what? I have no experiense yet and mabe someone of you could help me: to give some examples or suggestions where to find an answer to my questions.
Best regards! Solveiga
|
|
|
Re: Insert, delete, update [message #80978 is a reply to message #80977] |
Fri, 20 December 2002 06:27 |
Robert Kuhlmann
Messages: 35 Registered: March 2002
|
Member |
|
|
create table (child) with the on delete cascade option like this
SQL> create table master(id number primary key) ;
Tabelle wurde angelegt.
SQL> insert into master values(1);
1 Zeile wurde erstellt.
SQL> insert into master values(2);
1 Zeile wurde erstellt.
SQL> insert into master values(3);
1 Zeile wurde erstellt.
SQL> create table child (i number primary key, fid number references master(id) on delete cascad
Tabelle wurde angelegt.
SQL> insert into child values(1,2);
1 Zeile wurde erstellt.
SQL> insert into child values(2,2);
1 Zeile wurde erstellt.
SQL> select * from master;
ID
----------
1
2
3
SQL> select * from child;
I FID
---------- ----------
1 2
2 2
SQL> delete master where id = 2;
1 Zeile wurde gel÷scht.
SQL> select * from master;
ID
----------
1
3
SQL> select * from child;
Es wurden keine Zeilen ausgewõhlt/No Rows selected
SQL>
|
|
|
|