Subject | Re: Database trigger - On start transaction |
---|---|
Author | Michael Vilhelmsen |
Post date | 2008-12-18T13:28:13Z |
--- In firebird-support@yahoogroups.com, Thomas Steinmaurer <ts@...>
wrote:
approach.
wrote:
>No - just tried it from scratch on a different DB using the above
> > Im running FB on 2.1.0.17798 on Windows.
> >
> > I have a DB.
> > In this DB I created this table:
> >
> > CREATE TABLE A
> > (
> > ID INTEGER NOT NULL,
> > BRUGER VARCHAR( 30) COLLATE NONE,
> > HVAD INTEGER,
> > CONSTRAINT PK_A PRIMARY KEY (ID)
> > );
> >
> >
> > SET TERM ^^ ;
> > CREATE TRIGGER A_ID FOR A ACTIVE BEFORE INSERT POSITION 0 AS
> > begin
> > if ( (new.ID is null) or (new.ID = 0) )
> > then new.ID = gen_id(A_GEN, 1);
> > end
> > ^^
> > SET TERM ; ^^
> >
> >
> >
> > I then created this database trigger:
> >
> > SET TERM ^^ ;
> > RECREATE TRIGGER BRUGER_STARTTRANSACTION
> > INACTIVE ON TRANSACTION START POSITION 10
> > AS
> > begin
> > insert into a (bruger, Hvad) values (current_user,2);
> > end ^^
> >
> >
> > Its created as INACTIVE.
> >
> >
> >
> >
> > Here after I get this error when trying to connect to the DB using
> > IBObjects:
> >
> > ISC ERROR CODE:335544361
> >
> > ISC ERROR MESSAGE:
> > attempted update during read-only transaction
> > At trigger 'BRUGER_STARTTRANSACTION' line: 5, col: 3
> >
> > I can still connect using i.e. IBX.
> >
> > Then connecting using IBX I delete the database trigger and I can once
> > again connect via OBObjects
> >
> > But should I get this error sinse the database trigger is INACTIVE?
>
> Perhaps the trigger already existed as ACTIVE and the RECREATE TRIGGER
> statement didn't get committed?
approach.
>
>
> --
> Best Regards,
> Thomas Steinmaurer
> LogManager Series - Logging/Auditing Suites supporting
> InterBase, Firebird, Advantage Database, MS SQL Server and
> NexusDB V2
> Upscene Productions
> http://www.upscene.com
> My blog:
> http://blog.upscene.com/thomas/
>