Subject Re: [firebird-support] Re: Key violation on Primary/Unique key constraint INTEG_55/30 on table(s)
Author Gaurav Sood
Except one thing:

I created the database using IBPump, and probably Disabled the Triggers when
I pumped the data, perhaps that could be a problem ? how do I check or
enable all the triggers ?





On 3/14/06, Gaurav Sood <sood.gaurav@...> wrote:
>
> The INTEG_55 error is from a totally different part of the interface,
> unrelated to the Add New Person function which is causing the INTEG_30
> violation. So I feel like I am at square one with the PeopleID key violation
> as the trigger is implemented and working,....what do I do now? i will try
> altering the Trigger to match your recommendation, but otherwise, I don't
> know what else to do.
>
> The weird thing with the INTEG_55 error is that if I delete all the
> phonetic transcripts before creating multiple 'new' phonetic transcripts,
> then i don't get the INTEG_55 violation (ie. the keys for that particular
> transcript are clean). That's something.....so I am not quite sure what the
> error is but, it occurs after the SQLExec and Close transaction occur on the
> UtteranceQueryID (see above code).
>
>
> Thanks again for your help, if you have a chance to look at that code and
> let me know what you think, it would be great.
>
> Regards,
> Gaurav
>
>
> On 3/14/06, Adam <s3057043@...> wrote:
>
> > --- In firebird-support@yahoogroups.com, "Gaurav Sood"
> > <sood.gaurav@...> wrote:
> > >
> > > I found there is a separate trigger for PeopleID as follows;
> > >
> > >
> > > CREATE TRIGGER CREATEPEOPLEID FOR PEOPLE
> > > ACTIVE BEFORE INSERT POSITION 0
> > > AS BEGIN
> > > NEW.ID = GEN_ID(PEOPLEIDGEN, 1);
> > > END ^
> >
> > This will always assign a new generated value to ID. This is a valid
> > way of doing what was done in Delphi, however be aware that in FB 1.5
> > you have no way of seeing the value of NEW.ID if you do it this way.
> >
> > A better approach is
> >
> > CREATE TRIGGER CREATEPEOPLEID FOR PEOPLE
> > ACTIVE BEFORE INSERT POSITION 0
> > AS
> > BEGIN
> > IF (NEW.ID IS NULL) THEN
> > BEGIN
> > NEW.ID = GEN_ID(PEOPLEIDGEN, 1);
> > END
> > END
> > ^
> >
> > This will only generate an ID if you do not explicitly define one.
> > Think of a generator as a bucket full of usable IDs. If you leave ID
> > as NULL in the insert, then this trigger will reach into the bucket
> > and grab the next available ID.
> >
> > If you want to get a new peopleid value, then you as the developer
> > make a rule that the value you use must come from the bucket. You can
> > use the select query I demonstrated before (useful if you are
> > maintaining a master-detail list). Of course it only takes one person
> > to break the rules and you will get PK violations.
> >
> >
> > >
> > > however, the code apparently referencing this trigger is the SQL
> > Insert
> > > statement which I had previously written: SQL.Add('Insert into
> > People (ID)
> > > values (0)');
> > >
> > > So, is this still causing the error in the same way thought
> > previously? (I
> > > presume it works in a multi -transactional envirnoment ?)
> > >
> >
> > If that trigger was active then no, each ID would have been
> > different. Remember that check constraints are also implemented as
> > triggers. Your best bet is to find out what constraint INTEG_55
> > refers to by looking in the RDB$ system tables, then working out
> > which constraint exactly is being violated.
> >
> > When defining constraints you should name them, then the error will
> > be meaningful.
> >
> > Adam
> >
> >
> >
> >
> >
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Visit http://firebird.sourceforge.net and click the Resources item
> > on the main (top) menu. Try Knowledgebase and FAQ links !
> >
> > Also search the knowledgebases at http://www.ibphoenix.com
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
> --
>
>
>
> Analyst
> B. Engineering, B. IT
> A.N.U (2004)
>
> M: +61 401 409 620
> H: +61 3 9376 8580
>
>
> "In life, always do right. This will gratify some people and astonish the
> rest."
>
> � Mark Twain
>



--



Analyst
B. Engineering, B. IT
A.N.U (2004)

M: +61 401 409 620
H: +61 3 9376 8580


"In life, always do right. This will gratify some people and astonish the
rest."

� Mark Twain


[Non-text portions of this message have been removed]