Subject | Re: What's wrong with my Aft-Del-Trigger, can't create it in FB2 |
---|---|
Author | Bhavbhuti Nathwani |
Post date | 2007-01-01T09:20:17Z |
Hi Helen
Thanks for your response. I will explain what I intend to do so that
you and other can help me with this. I am not totally a newbie but I
am still approaching the Intermediate stage with FB.
I have a parent table sPacklingList and a child Table uStock. uStock
contains entries from multiple parent tables, one of which is
sPackingList, thus, I was not able to use constraints to delete
entries in uStock. I was suggested to use triggers. To make the code
reusable (from FB as well as VFP's SPT) I moved the delete code
DELETE FROM uStock
WHERE iPID = :tiID;
into a SP which takes one parameter tiID and use it in the delete command.
Now I am trying to call this SP from the After Delete Trigger where I
would like to pass the Old.iID to this SP named DelUStock. I don't
need a return value, but if explaining to me is not a big deal I would
like to return a boolean value which would return a 1 if the delete
was successful otherwise a 0.
Please advise.
Thanks for your response. I will explain what I intend to do so that
you and other can help me with this. I am not totally a newbie but I
am still approaching the Intermediate stage with FB.
I have a parent table sPacklingList and a child Table uStock. uStock
contains entries from multiple parent tables, one of which is
sPackingList, thus, I was not able to use constraints to delete
entries in uStock. I was suggested to use triggers. To make the code
reusable (from FB as well as VFP's SPT) I moved the delete code
DELETE FROM uStock
WHERE iPID = :tiID;
into a SP which takes one parameter tiID and use it in the delete command.
Now I am trying to call this SP from the After Delete Trigger where I
would like to pass the Old.iID to this SP named DelUStock. I don't
need a return value, but if explaining to me is not a big deal I would
like to return a boolean value which would return a 1 if the delete
was successful otherwise a 0.
Please advise.
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 05:38 PM 1/01/2007, you wrote:
> >Hi all
> >
> >Wishing you all a Very Happy New Year!!!
> >
> >I am trying to create a After Delete Trigger using FlameRobin 0.7.6
> >but I cannot seem to be able to create the trigger. I keep getting
> >the following error:
> >Message: isc_dsql_prepare failed
> >
> >SQL Message : -104
> >Invalid token
> >
> >Engine Code : 335544569
> >Engine Message :
> >Dynamic SQL Error
> >SQL error code = -104
> >Token unknown - line 10, column 37
> >;
> >
> >My code is as follows:
> >SET TERMINATOR ^ ;
> >
> >CREATE TRIGGER trg_aft_del_spackinglist_ustok FOR SPACKINGLIST
> >ACTIVE AFTER DELETE POSITION 0
> >AS
> >BEGIN
> >-- DELETE FROM uStock
> >-- WHERE iPID = Old.iID;
> >
> > SELECT * FROM DelUStock(Old.iID);
> >END^
> >
> >SET TERMINATOR ; ^
> >
> >I have successfully create the stored procedure DelUStock().
>
> It is an illegal SELECT statement for PSQL. In PSQL, you have to
> select <specific fields> INTO <an appropriate set of corresponding
> variables>. What do you suppose a trigger can do with your select?
>
> Explain what you want to do and we'll either show you how to do it,
> or tell you that you can't do it in a trigger. :-)
>
> ./heLen
>