MySQL Forums
Forum List  »  MySQL Query Browser

Re: Query Help Needed
Posted by: irek kordirko
Date: February 27, 2012 02:18PM

KG Muthukumar Wrote:
> Thanks Irek.. much appreciate your help and will
> keep your avice in mind the next time..
> a supplemental question to the above:
> While the SQL you provided works for a one-time
> load, I am also planning for an incremental load
> into the Target table when ever the source table
> record is updated or a new row is added to the
> source table - I would like to do this as a
> trigger on insert/update..
> any thoughts on how the trigger SQL might look..

Cannot be done using triggers.
According to docs:

B.5.9: Can triggers access tables?

A trigger can access both old and new data in its own table. A trigger can also affect other tables,
but it is not permitted to modify a table that is already being used (for reading or writing)
by the statement that invoked the function or trigger.

When a new record is inserted, a value of STATUS_CREATE_DATETIME from the next record cannot be calculated. So the only way is to update previous record basing on values from the current (just being inserted) record.
Since the trigger cannot modify its own table, it can't be done using the trigger.

Options: ReplyQuote

Written By
February 25, 2012 02:48PM
February 26, 2012 10:39AM
February 26, 2012 06:46PM
Re: Query Help Needed
February 27, 2012 02:18PM
February 27, 2012 08:14AM
February 27, 2012 05:05PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.