Subject | Re: [firebird-support] Key violation on Primary/Unique key constraint INTEG_55/30 on table(s) |
---|---|
Author | Gaurav Sood |
Post date | 2006-03-14T00:11:12Z |
Hi Helen
I've run through the program with the debugger and found that once we
try to make a new person with the GUI, it calls the Person.pas file
OnShow routine
procedure TPersonDlg.FormShow(Sender: TObject);
var
personType: TPersonTypeEnum;
begin
{ Check for new Person. }
if Person < 1 then
begin
*** Person := NewPerson;
Status := pdNew;
end
else
Status := pdEdit;
The *** Person := NewPerson; is an internal private function that does
the below:
function TPersonDlg.NewPerson: TPersonID;
begin
with ApplicationForm.ScratchQuery do
begin
{ Create a new record in People. }
Close;
SQL.Clear;
*** SQL.Add('Insert into People (ID) values (0)');
ExecSQL;
{ Get ID for new Person. }
Close;
SQL.Clear;
SQL.Add('Select max(ID) from People');
Open;
Result := Fields[0].AsInteger;
end;
end;
where it seems like *** SQL.Add is causing the problem. how do I make
a unique ID value which is the next highest ID value up (ie. if the
last person was 10 the next would be 11).
I ran the SQL routine on RDB$RELATION_CONSTRAINTS and found the
INTEG_30 violation is specific to table People and column ID.
The INTEG_55 violation is specific to the SampleWords table, and I
presume there will be a similar line of SQL code which is causing the
problem with creating a New NON UNIQUE key.
Thanks for your help again,
Gaurav
I've run through the program with the debugger and found that once we
try to make a new person with the GUI, it calls the Person.pas file
OnShow routine
procedure TPersonDlg.FormShow(Sender: TObject);
var
personType: TPersonTypeEnum;
begin
{ Check for new Person. }
if Person < 1 then
begin
*** Person := NewPerson;
Status := pdNew;
end
else
Status := pdEdit;
The *** Person := NewPerson; is an internal private function that does
the below:
function TPersonDlg.NewPerson: TPersonID;
begin
with ApplicationForm.ScratchQuery do
begin
{ Create a new record in People. }
Close;
SQL.Clear;
*** SQL.Add('Insert into People (ID) values (0)');
ExecSQL;
{ Get ID for new Person. }
Close;
SQL.Clear;
SQL.Add('Select max(ID) from People');
Open;
Result := Fields[0].AsInteger;
end;
end;
where it seems like *** SQL.Add is causing the problem. how do I make
a unique ID value which is the next highest ID value up (ie. if the
last person was 10 the next would be 11).
I ran the SQL routine on RDB$RELATION_CONSTRAINTS and found the
INTEG_30 violation is specific to table People and column ID.
The INTEG_55 violation is specific to the SampleWords table, and I
presume there will be a similar line of SQL code which is causing the
problem with creating a New NON UNIQUE key.
Thanks for your help again,
Gaurav
On 3/13/06, Si Carter <mail.lists@...> wrote:
>
>
> > -----Original Message-----
> > I don't know what the errors are referring to exactly, but I
> > guess the software may not be selecting the correct radio
> > button option for Person, and so creating an error with an
> > ambiguous type that does not fit the table definition.
>
> To find out what table and column INTEG_?? Is refering to you could use the
> query found here (http://www.fbtalk.net/viewtopic.php?id=214)
>
> This should help narrow the search down.
>
> Rgds
>
> Si Carter
> http://www.fbtalk.net/ - Web Based Firebird Forum
> http://sourceforge.net/projects/fbutils - FBUtils
> http://sourceforge.net/projects/dnfbb - Web based, Firebird Powered Forum
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> 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