0

First I want to say I've never tried using triggers before, and I read a lot of information to do this. What I want to do is delete all records from gallery_assets_meta where its parent_id is equal to gallery_assets.id.

This was what I tried on sequel pro:

screenshot

My Sql code:

BEGIN
DELETE FROM gallery_assets_meta
    WHERE gallery_assets_meta.parent_id = old.id;
END

When I try to delete a record from gallery_assets I get this error:

screenshot2

rafaelmorais
  • 1,323
  • 2
  • 24
  • 49
  • 1
    Hello. So, what is the problem? what is the question? – Adrian Nasui Dec 12 '14 at 11:48
  • Hello, I edited my question. You can check the error that occurs. – rafaelmorais Dec 12 '14 at 11:50
  • Hi, seems that sequel pro checks for the total number of records affected and throws this error for some reason. – Adrian Nasui Dec 12 '14 at 11:59
  • Would you consider not using the trigger and calling the command "DELETE FROM gallery_assets_meta WHERE gallery_assets_meta.parent_id = old.id;" before the deletion of the row in "gallery_assets"? – Adrian Nasui Dec 12 '14 at 12:00
  • Yes, and the result is the same. Except when I do it AFTER it deletes the field from gallery_assets but not the correspondent childs of gallery_assets_meta – rafaelmorais Dec 12 '14 at 12:05

0 Answers0