Board index » delphi » IB trigger makes record fly away

IB trigger makes record fly away

vvaat...@news.abo.fi (Veikko V{{t{j{ TKKK) writes:

Quote
>field values and post that, I get an error (EDBEngineError) saying
>'Record/Key deleted'. I assume this is because the key field
>is changed by the trigger and the temporary record with empty key
>doesn't exist any more.

  I noticed that it does this on just one table. Other tables
with triggers work fine. What could be wrong with this table???
What does the error message mean?

  Veikko Vaataja
  veikko.vaat...@abo.fi

 

Re:IB trigger makes record fly away


  Hi!

  How do I prevent a record from flying away when inserting a new
record in an interbase table that makes the primary key field
in a before insert trigger? When I insert a new record, enter
field values and post that, I get an error (EDBEngineError) saying
'Record/Key deleted'. I assume this is because the key field
is changed by the trigger and the temporary record with empty key
doesn't exist any more.

  Should I do this some other way? I should because this
doesn't work... :(

  Veikko Vaataja
  veikko.vaat...@abo.fi

Re:IB trigger makes record fly away


In article <433qma$...@aton.abo.fi>, vvaat...@news.abo.fi (Veikko V{{t{j{

Quote
TKKK) wrote:
>   Hi!

>   How do I prevent a record from flying away when inserting a new
> record in an interbase table that makes the primary key field
> in a before insert trigger? When I insert a new record, enter
> field values and post that, I get an error (EDBEngineError) saying
> 'Record/Key deleted'. I assume this is because the key field
> is changed by the trigger and the temporary record with empty key
> doesn't exist any more.

To make this work, you need to have no DEFAULT definitions for your
table.  It seems that a combination of the before insert trigger and
default values in your database makes Delphi {*word*88}.

Tom

Re:IB trigger makes record fly away


Quote
>    How do I prevent a record from flying away when inserting a new
>  record in an interbase table that makes the primary key field
>  in a before insert trigger? When I insert a new record, enter
>  field values and post that, I get an error (EDBEngineError) saying
>  'Record/Key deleted'. I assume this is because the key field
>  is changed by the trigger and the temporary record with empty key
>  doesn't exist any more.

Actually, Interbase accept this record, but delphi can't  found this record because of the key field change, so delphi  
give you a message "Record /Key  deleted".

Solution 1 : Don't change the key field in trigger procedure. Make all change in your OnBeforeInsert event.

Solution 2 : If you still want to change the key field in trigger, ah...... let me check, tell you later.

  :-)

Re:IB trigger makes record fly away


Quote
jetle...@hk.super.net writes:
>Actually, Interbase accept this record, but delphi can't  found this record because of the key field change, so delphi  
>give you a message "Record /Key  deleted".

  Some triggers that change key field work fine! I can't understand what is
wrong with this one. One table worked after I removed default statement in
create table. I don't know what this have to do with the problem but just
worked!

Quote
>Solution 1 : Don't change the key field in trigger procedure. Make all change in your OnBeforeInsert event.

  Not good! I would like to use triggers because they are much-much-much
better... Well, in theory atleast... ;)

Quote
>Solution 2 : If you still want to change the key field in trigger, ah...... let me check, tell you later.

  Let me hear from you.

  Veikko Vaataja
  veikko.vaat...@abo.fi

Other Threads