I try to move a midas application from Delphi 5 to Delphi 7. On some of my
clientdataset I have set the property PackedRecord > 0. When i use the
GetNextPacket method on these clientdataset I get an error "Key violation"
in Delphi 7 but not in Delphi 5. Why this difference ?. Anybody knows how I
can repair ?.
I use:
Delphi 7
Connection to SQL Server 2000 using ADO connection
Ole
> I try to move a midas application from Delphi 5 to Delphi 7. On some
> of my clientdataset I have set the property PackedRecord > 0. When i
> use the GetNextPacket method on these clientdataset I get an error
> "Key violation" in Delphi 7 but not in Delphi 5.
Today I hit to the same problem. I'm also moving my Midas/Datasnap
application from D5 to D7. I have PacketRecords=100 on many
ClientDataSets and some, not all, give 'Key violation' error when
scrolling the dataset past 100th record. Clearly the fetch of next
datapacket from the server fails but what is the key in this case
and how to violate it as the database (Interbase) is quite happy
with it's keys.
Could somebody kindly shed some light?
--Mikko
--
-Dave Rowntree
Ole Juhl <o...@lr.dk> wrote in message
news:3eb7...@newsgroups.borland.com...
> Does your SQL Select statement have parameters?
>
Mine does not have any parameters. But I found a difference
between those queries with have no problems and those
which raise 'Key violation' at the fetch of next datapacket:
If the SQL select feeding the DatasetProvider joins two (or more)
tables in such a way that the "master table" rows are repeated
many times then the 'Key violation' comes up. If the primary key
of the "master" table does not have repeating values then no
problems. It seems that the presence of primary key columns
in the result set does not affect in any way.
--Mikko
Have a look at QC#3515. I have provided a fix/workaround.
> If the SQL select feeding the DatasetProvider joins two (or more)
> tables in such a way that the "master table" rows are repeated
> many times then the 'Key violation' comes up.
I would expect it to. The whole point of a PK is that each row/record must
be unique.
> If the primary key
> of the "master" table does not have repeating values then no
> problems.
Good. It sounds to be working as designed then.
--
-Dave Rowntree
Thanks Dave, I will take a look at it.
>
> > If the SQL select feeding the DatasetProvider joins two (or more)
> > tables in such a way that the "master table" rows are repeated
> > many times then the 'Key violation' comes up.
>
> I would expect it to. The whole point of a PK is that each row/record
> must be unique.
>
Of course, if the result set needs to be updated. But for read-only
reporting purposes it should be possible to create joins where
the master table rows are repeating. And I can't understand
why the 'Key violation' complaint does come up if all records
are fetched in a single lot.
Anyway my quick solution was to set PacketRecords to -1 and
accept the possible network delay when result set is large.
Regards,
--MIkko
http://qc.borland.com/
--
-Dave Rowntree
For a read-only CDS, when the SQL select does not use parameters, try
removing the pfInKey flag from the DSP.DataSet PK field(s) ProviderFlags.
You should then be able to use CDS.PacketRecords > 0. I haven't tried this
but the theory seems reasonable <g>.
--
-Dave Rowntree
Ole Juhl
"Dave Rowntree" <daver@away_spam.brookswood,co.uk> wrote in message
news:3ec2...@newsgroups.borland.com...
You are welcome. Glad it fixed the problem for you.
--
-Dave Rowntree
>
> For a read-only CDS, when the SQL select does not use parameters, try
> removing the pfInKey flag from the DSP.DataSet PK field(s)
> ProviderFlags. You should then be able to use CDS.PacketRecords > 0.
> I haven't tried this but the theory seems reasonable <g>.
> --
Resetting ProviderFlags option pfInKey to False eliminated the error,
thanks.
What I'm still wondering : If CDS considers key values important why
doesn't
it complain when I fetch the whole dataset in a single packet
(PacketRecords=-1)?
Thanks Dave!
--Mikko
When you set pfInKey against the DSP.DataSet TField(s) MIDAS creates a
unique index (called 'PRIMARY_KEY') on the pfInKey field(s), which it passes
to the CDS.
I did a test against an MSSQL DB using ADO.
It appears that validation against indices is only carried out when changes
occur to an already open CDS. I'm not really convinced that this makes
sense.
--
-Dave Rowntree
>
> When you set pfInKey against the DSP.DataSet TField(s) MIDAS creates a
> unique index (called 'PRIMARY_KEY') on the pfInKey field(s), which it
> passes to the CDS.
>
> I did a test against an MSSQL DB using ADO.
> It appears that validation against indices is only carried out when
> changes occur to an already open CDS. I'm not really convinced that
> this makes sense.
>
So the appending of the next data packet to the data already in CDS is
regarded a change comparable to an insert row operation. Smells like
a bug to me...
Thanks Dave,
--Mikko
As I said, it doesn't seem very logical to me either. Why don't you post the
problem to QC with a test case app in Attachments that demonstrates the
problem.
--