The simple answer is "You don't - there is not an 'iBATIS way' to do this."

You can however do a couple of things.

In your database, you can define cascading deletes, so that when you
delete a parent, you delete the children, too.

You can also (on some databases) execute multiple statements in one
mapped statement. For example using Oracle, you could do this:

<delete id="delete">
BEGIN
 DELETE FROM Child WHERE parentId=#parentId#;
 DELETE FROM Parent WHERE parentId=#parentId#;
END;
</delete>

Larry

PS: I just noticed that this is the CS list, not the java list - that
mapped statement is from an example I had using the Java syntax, which
iirc, is the same, but if not...sorry. ;-)


On 8/24/06, Vani <[EMAIL PROTECTED]> wrote:

Hi all,

I have a parent table eg Department(DeptID,DeptName) and a childtable eg
Employee(EmpId, EmpName,DeptID). Now my problem is, I want to delete a row
in the child table if its corresponding foreign key(Dept ID) is deleted in
the parent table. How do i implement it using Ibatis?

Please help me.

Thank you.
--
View this message in context: 
http://www.nabble.com/Deleting-a-row-in-the-childtable-tf2158879.html#a5964724
Sent from the iBATIS - User - Cs forum at Nabble.com.


Reply via email to