Subject RE: [IBO] Key Links and Deleting Records - Request Help
Author Russ Newcomer
Based on your and Helen's advice, I changed my code to the following :

With cdm.Shipdelete do
begin
If not Prepared then Prepare;
Params[0].AsString := ContractNum.Text + '.';
Execute;
end;
cdm.ShipQuery.Refresh;

Now, when this code executes a second time (it's an on-exit event for a text
box, second time is the second time you leave the box), an error message
comes back to me :

ISC ERROR CODE : 335544665

ISC ERROR MESSAGE :
VIOLATION OF PRIMARY OR UNIQUE KEY constraint "INTEG_4" on table "Shipments"


There's some more to it, and I can post that also if needed.

I'm using a generator to create my primary key, and I wonder if that's part
of the problem?



Thanks,
Russ Newcomer


-----Original Message-----
From: Jason Wharton [mailto:jwharton@...]
Sent: Wednesday, February 27, 2002 4:10 PM
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] Key Links and Deleting Records - Request Help


It should work and I am interested in why it isn't. What appears to be the
exact problem? What do you mean that it dies on the first delete of the 2nd
pass?

But, I must also say there are much better ways to do this with a
client/server database. How about doing a single DELETE statement with the
WHERE clause specifying what all records should be deleted. Then, just
refresh the dataset after this statement is executed.

HTH,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com <http://www.ibobjects.com>


----- Original Message -----
From: "cbmrussn" <russn@...>
To: <IBObjects@yahoogroups.com>
Sent: Wednesday, February 27, 2002 11:16 AM
Subject: [IBO] Key Links and Deleting Records - Request Help


> Delphi 6.02, IBO4, FB RC2, Win2k.
>
> I have a piece of code that preforms a .locate on my dataset to find
> a specific record, delete it, then check to see if there is another
> record that meets to requirements of the .locate, delete, ad
> infinitum.
>
> The problem is that this code executes through fully the first time
> correctly, deleting all the records it needs to. The second time
> through this procedure, it dies on the first .delete.
>
> Here's the code that's giving me problems.
>
> var
> Index : Integer;
> Found : Boolean;
> RecordID : String;
> begin
> Index := 1;
> Found := True;
> cdm.ShipQuery.Edit;
> repeat {until not(found)}
> begin
> RecordID := ContractNum.Text + '.' + IntToStr(Index);
> Found := cdm.ShipQuery.Locate('Ship_ID', RecordID,
> [loCaseInsensitive]);
> if Found then
> cdm.ShipQuery.Delete;
> Index := Index + 1;
> end;
> until not(Found);
> end;
>
>
> Thanks,
> Russ Newcomer
>
>
>
>
___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or
InterBase
> without the need for BDE, ODBC or any other layer.
>
___________________________________________________________________________
> http://www.ibobjects.com <http://www.ibobjects.com> - your IBO community
resource for Tech Info
papers,
> keyword-searchable FAQ, community code contributions and more !
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
<http://docs.yahoo.com/info/terms/>
>
>
>



Yahoo! Groups Sponsor

ADVERTISEMENT

<http://rd.yahoo.com/M=217097.1902236.3397169.1261774/D=egroupweb/S=17050071
83:HM/A=960173/R=0/*http://service.bfast.com/bfast/click?bfmid=29150849&site
id=39249818&bfpage=moneyyahoo4>

<http://us.adserver.yahoo.com/l?M=217097.1902236.3397169.1261774/D=egroupmai
l/S=1705007183:HM/A=960173/rand=521829415>

___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com <http://www.ibobjects.com> - your IBO community
resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .



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