BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TClientDataset - Key violation error

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Antonio Budano
Guest





PostPosted: Tue Feb 08, 2005 10:14 pm    Post subject: TClientDataset - Key violation error Reply with quote



Hi,
I have the following situation:
DB Interbase 6.0, TSQLConnectction, TSQLQuery, TDatasetProvider,
TClientDataset on Delphi 6.
I know I am outdated but...
I have a table in IB that has 19 fields, 9 of them are defined not null and
they are part of a unique index.
I have coded the SQL in the TSQLQuery, then I added TFields components, I
set the pfInKey flag to the fields being part of the unique index and I set
the UpdateMode of the provider to UpdateWhereKeyOnly.
When I insert records on the ClientDataset, I got the Key Violation
exception when I insert a records that has the first 8 fields with the same
values (they are String fields and Smallint fields) except the 9th that has
a different content.
Calling the post method, I get the key violation exception.
I can solve the problem removing the pfInKey flag on the key fields, the
post method works, then I can call the ApplyUpdates method.
It seams that the TClientDataset doesn't consider the content of the 9th
Tfield.
Is there any limitation (8?) on the number of TField that can be part of the
key?

Thanks

Antonio


Back to top
Bill Todd
Guest





PostPosted: Tue Feb 08, 2005 10:48 pm    Post subject: Re: TClientDataset - Key violation error Reply with quote



No, although I have never heard of a nine field key.

What is the data type of the ninth field?

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email

Antonio Budano wrote:

Quote:
Is there any limitation (8?) on the number of TField that can be part of
the
key?

Back to top
Antonio Budano
Guest





PostPosted: Wed Feb 09, 2005 6:24 am    Post subject: Re: TClientDataset - Key violation error Reply with quote



"Bill Todd" <no (AT) no (DOT) com> ha scritto nel messaggio
news:420941d2$1 (AT) newsgroups (DOT) borland.com...
Quote:
No, although I have never heard of a nine field key.

What is the data type of the ninth field?


The ninth field is a TStringField, named cdsT08021PART.
As I said before, I can resolve the problem if I remove the pfInKey on key
fieds and let the provider to apply udates, relaying on the dbms to check
duprec.
I don't understand why with a similar table that has the same fields
definition except the PART field that is missing it works, the update
process is the same.


Below is the Metadata definition for the Interbase table

/* Domain definitions */
CREATE DOMAIN "CLIE" AS VARCHAR(1Cool
DEFAULT '';
CREATE DOMAIN "CLSF" AS VARCHAR(3Cool
DEFAULT '';
CREATE DOMAIN "DATA_CREA" AS DATE
DEFAULT CURRENT_DATE;
CREATE DOMAIN "DATA_MODI" AS DATE
DEFAULT CURRENT_DATE;
CREATE DOMAIN "ESER" AS SMALLINT
DEFAULT 0
CHECK ((VALUE >= 0) AND (VALUE <= 9999));
CREATE DOMAIN "MAGA" AS VARCHAR(4)
DEFAULT '';
CREATE DOMAIN "MATE" AS VARCHAR(1Cool
DEFAULT '';
CREATE DOMAIN "PART" AS VARCHAR(1Cool
DEFAULT '';
CREATE DOMAIN "PERI" AS SMALLINT
DEFAULT 0
CHECK ((VALUE >= 0) AND (VALUE <= 99));
CREATE DOMAIN "QNTA_BLOC" AS NUMERIC(15, 3)
DEFAULT 0;
CREATE DOMAIN "QNTA_CQLT" AS NUMERIC(15, 3)
DEFAULT 0;
CREATE DOMAIN "QNTA_DISP" AS NUMERIC(15, 3)
DEFAULT 0;
CREATE DOMAIN "QNTA_RESI" AS NUMERIC(15, 3)
DEFAULT 0;
CREATE DOMAIN "QNTA_TRAS" AS NUMERIC(15, 3)
DEFAULT 0;
CREATE DOMAIN "SOCI" AS VARCHAR(4)
DEFAULT '';
CREATE DOMAIN "STAB" AS VARCHAR(4)
DEFAULT '';
CREATE DOMAIN "UNIT_MISU" AS VARCHAR(4)
DEFAULT '';
CREATE DOMAIN "UTEN_CREA" AS VARCHAR(10)
DEFAULT USER;
CREATE DOMAIN "UTEN_MODI" AS VARCHAR(10)
DEFAULT USER;

/* Table: T08021, Owner: SYSDBA */

CREATE TABLE "T08021"
(
"SOCI" "SOCI" NOT NULL,
"ESER" "ESER" NOT NULL,
"PERI" "PERI" NOT NULL,
"CLIE" "CLIE" NOT NULL,
"MATE" "MATE" NOT NULL,
"CLSF" "CLSF" NOT NULL,
"STAB" "STAB" NOT NULL,
"MAGA" "MAGA" NOT NULL,
"PART" "PART" NOT NULL,
"DATA_CREA" "DATA_CREA",
"DATA_MODI" "DATA_MODI",
"UTEN_CREA" "UTEN_CREA",
"UTEN_MODI" "UTEN_MODI",
"QNTA_DISP" "QNTA_DISP",
"QNTA_CQLT" "QNTA_CQLT",
"QNTA_TRAS" "QNTA_TRAS",
"QNTA_BLOC" "QNTA_BLOC",
"QNTA_RESI" "QNTA_RESI",
"UNIT_MISU" "UNIT_MISU"
);

CREATE UNIQUE INDEX T08021_PX ON T08021(SOCI, ESER, PERI, CLIE, MATE, CLSF,
STAB, MAGA, PART);


And this is the components definition on the datamodule


object qryT08021: TSQLQuery
NoMetadata = True
SQLConnection = BISDB.DB01
Params = <
item
DataType = ftString
Name = 'SOCI'
ParamType = ptInput
end
item
DataType = ftSmallint
Name = 'ESER'
ParamType = ptInput
end
item
DataType = ftSmallint
Name = 'PERI'
ParamType = ptInput
end>
SQL.Strings = (
'SELECT *'
''
'FROM T08021'
''
'WHERE SOCI = :SOCI AND'
' ESER = :ESER AND'
' PERI = :PERI'
''
'ORDER BY SOCI,'
' ESER,'
' PERI,'
' CLIE,'
' MATE,'
' CLSF,'
' STAB,'
' MAGA,'
' PART;')
Left = 640
Top = 220
object qryT08021SOCI: TStringField
FieldName = 'SOCI'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 4
end
object qryT08021ESER: TSmallintField
FieldName = 'ESER'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
end
object qryT08021PERI: TSmallintField
FieldName = 'PERI'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
end
object qryT08021CLIE: TStringField
FieldName = 'CLIE'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 18
end
object qryT08021MATE: TStringField
FieldName = 'MATE'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 18
end
object qryT08021CLSF: TStringField
FieldName = 'CLSF'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 38
end
object qryT08021STAB: TStringField
FieldName = 'STAB'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 4
end
object qryT08021MAGA: TStringField
FieldName = 'MAGA'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 4
end
object qryT08021PART: TStringField
FieldName = 'PART'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 18
end
object qryT08021DATA_CREA: TDateField
FieldName = 'DATA_CREA'
end
object qryT08021DATA_MODI: TDateField
FieldName = 'DATA_MODI'
end
object qryT08021UTEN_CREA: TStringField
FieldName = 'UTEN_CREA'
Size = 10
end
object qryT08021UTEN_MODI: TStringField
FieldName = 'UTEN_MODI'
Size = 10
end
object qryT08021QNTA_DISP: TFMTBCDField
FieldName = 'QNTA_DISP'
Precision = 15
Size = 3
end
object qryT08021QNTA_CQLT: TFMTBCDField
FieldName = 'QNTA_CQLT'
Precision = 15
Size = 3
end
object qryT08021QNTA_TRAS: TFMTBCDField
FieldName = 'QNTA_TRAS'
Precision = 15
Size = 3
end
object qryT08021QNTA_BLOC: TFMTBCDField
FieldName = 'QNTA_BLOC'
Precision = 15
Size = 3
end
object qryT08021QNTA_RESI: TFMTBCDField
FieldName = 'QNTA_RESI'
Precision = 15
Size = 3
end
object qryT08021UNIT_MISU: TStringField
FieldName = 'UNIT_MISU'
Size = 4
end
end
object dspT08021: TDataSetProvider
DataSet = qryT08021
Constraints = True
UpdateMode = upWhereKeyOnly
OnUpdateError = dspT08021UpdateError
BeforeUpdateRecord = dspT08021BeforeUpdateRecord
Left = 644
Top = 280
end
object cdsT08021: TClientDataSet
Aggregates = <>
Params = <
item
DataType = ftString
Name = 'SOCI'
ParamType = ptInput
end
item
DataType = ftSmallint
Name = 'ESER'
ParamType = ptInput
end
item
DataType = ftSmallint
Name = 'PERI'
ParamType = ptInput
end>
ProviderName = 'dspT08021'
OnNewRecord = cdsT08021NewRecord
Left = 648
Top = 344
object cdsT08021SOCI: TStringField
FieldName = 'SOCI'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 4
end
object cdsT08021ESER: TSmallintField
FieldName = 'ESER'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
end
object cdsT08021PERI: TSmallintField
FieldName = 'PERI'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
end
object cdsT08021CLIE: TStringField
FieldName = 'CLIE'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 18
end
object cdsT08021MATE: TStringField
FieldName = 'MATE'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 18
end
object cdsT08021CLSF: TStringField
FieldName = 'CLSF'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 38
end
object cdsT08021STAB: TStringField
FieldName = 'STAB'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 4
end
object cdsT08021MAGA: TStringField
FieldName = 'MAGA'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 4
end
object cdsT08021PART: TStringField
FieldName = 'PART'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
Size = 18
end
object cdsT08021DATA_CREA: TDateField
FieldName = 'DATA_CREA'
end
object cdsT08021DATA_MODI: TDateField
FieldName = 'DATA_MODI'
end
object cdsT08021UTEN_CREA: TStringField
FieldName = 'UTEN_CREA'
Size = 10
end
object cdsT08021UTEN_MODI: TStringField
FieldName = 'UTEN_MODI'
Size = 10
end
object cdsT08021QNTA_DISP: TFMTBCDField
FieldName = 'QNTA_DISP'
Precision = 15
Size = 3
end
object cdsT08021QNTA_CQLT: TFMTBCDField
FieldName = 'QNTA_CQLT'
Precision = 15
Size = 3
end
object cdsT08021QNTA_TRAS: TFMTBCDField
FieldName = 'QNTA_TRAS'
Precision = 15
Size = 3
end
object cdsT08021QNTA_BLOC: TFMTBCDField
FieldName = 'QNTA_BLOC'
Precision = 15
Size = 3
end
object cdsT08021QNTA_RESI: TFMTBCDField
FieldName = 'QNTA_RESI'
Precision = 15
Size = 3
end
object cdsT08021UNIT_MISU: TStringField
FieldName = 'UNIT_MISU'
Size = 4
end
end



Back to top
Bill Todd
Guest





PostPosted: Wed Feb 09, 2005 4:08 pm    Post subject: Re: TClientDataset - Key violation error Reply with quote

Sorry. I am not sure what is causing the problem. Perhaps someone else
will.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.