no primary key value for foreign key value error in Master-Detail Dataset

Hi,

We are using master detail relationship dataset but getting primary key violation error during posting the data.

-------------------------------
*Project GBlWare.exe raised exception class EASANativeException with message* 
*[FireDAC][Phys][ODBC][Sybase][SQLAnywhere]no primary key value for foreign key*
-------------------------------

Our current master detail scenario is that ,we are using parameter in details dataset that reference to master dataset primary key field value. But when I add a new record at that time master dataset key value is null. So when I press tab or down arrow in detail dataset grid it automatically posts detail data in database. As at that time master dataset is not posted to database, so it causes the foreign key violence exception. 

In ADO we use *Batchoptimistic* property for detail dataset. So that user can add multiple detail data in details dataset. Then user can save batch of data to database at a time. On that period we first post master data and then we set detail foreign key value with master primary key value. So same thing I want to do in FIreDAC

Currently I am doing following setting
1. I have put a master query on form with sql
Select * from Order 

2. On Detail query on form with SQL
Select * from OrderDetail where OrderID = :OrderID

3. I set Query detail master source as Tdatasource linked to Master query.

4. Then In detail query I set masterfild as Master dataset primary key. and indexfield name as detail query foreign key.

So am I missing any step ? Please suggest.

*How can I implement same master-detail dataset functionality in FireDAC such that user can add multiple detail record at a time to database.?* 
So please suggest the proper way to implement it.

It would be better if any body please provide one demo.


Thanks,
0
Jitendra
9/12/2014 3:54:59 AM
embarcadero.delphi.firedac 822 articles. 2 followers. Follow

1 Replies
1356 Views

Similar Articles

[PageSpeed] 11

http://docwiki.embarcadero.com/RADStudio/XE7/en/Caching_Updates_(FireDAC)
http://docwiki.embarcadero.com/RADStudio/XE7/en/Caching_Updates_(FireDAC)#Centralized_Cached_Updates

-- 
With best regards,
Dmitry Arefiev / FireDAC Architect
0
Dmitry
9/15/2014 4:05:42 AM
Reply:

Similar Artilces:

No primary key value for foreign key
Hi, I tried to: alter table sa.shipitems add foreign key FK_SHIPITEM_REFERENCE_OITEMS (oitemsid) references sa.oitems (oitemsid) on update cascade on delete restrict but got this error: No primary key value for foreign key 'FK_SHIPITEM_REFERENCE_OITEMS' in table 'shipitems' What does it mean and how to round this problem? fyi, here is the definition of both table /*==============================================================*/ /* Table: shipitems */ /*===============================...

no primary key value for foerign key--error
What is the meaning of this error? How is it resolved? Jlicht wrote: > > What is the meaning of this error? How is it resolved? The error above means that you have referential integrity (RI) set up in you database and you try to insert a invalid foreign key. For RI, you always have two (or more!) tables: a master table (e.g. invoice) and a detail table (e.g. invoice item). A row in detail table is only valid, if the reference to the master table is null (as long as allowed by the field in detail table) or if the value exists in the master table. Example: CREATE TABLE Ma...

SQL statement failed: (-194) No primary key value for foreign key
I'm getting this error message sporadically when my remote sites are replicating to my central server. The odd thing is the record that is the primary key value does exist! I'm at a lost...Does any have any idea, why this may be happening? Thanks Tasha Did the record exist at the time the error was reported? I have seen cases before where the Parent record is physically sent to the remote *after* the Child record. This would explain why the error was legitimately reported but when you look at the database later the Parent record now exists. -- -------------...

SQL statement failed, no primary key value for foreign key ... in table ...
Problem: SQL statement failed, no primary key value for foreign key ... in table ... After deleting or changing primary key values in either consolidated or remote database. Question: Are there any triggers that can resolve inserting a record that has a foreign key value with no existing primary key value in primary table? Description: We have a serious problem with the dbremote program. I think it's a general problem that could appear in every database with related tables. Everytime the problem turns up we must create new remote databases from the consolidated datab...

Filling foreign key values in a master-detail form
I want to design a one-to-many master-detail form with the following two tables, having "Rotation" as the master and "Rotation Position" as the detail: CREATE TABLE "DBA"."Rotation" ( "RotationId" integer NOT NULL DEFAULT autoincrement, "Rotation Date" datetime NOT NULL DEFAULT 'TIMESTAMP', PRIMARY KEY ("RotationId") ) CREATE TABLE "DBA"."Rotation Position" ( "RotationId" integer NOT NULL, "Position" char(2) NOT NULL, PRIMARY KEY (&...

No primary key value for foreign key 'ISYSTABCOL' in table 'ISYSCOLPERM'
Hi all, running SA 10.0.1.3686 and .3712 on Win 2003 Server SP1. The above message appears when I try to add a column to a table. It's just a simple one: alter table dbo.T_MaZuGavAktion add fkz_BeilageNrLautVersand int check (@Wert > 0) null; There is a view based on this table, and several users have been granted update column rights on this view. It is only possible to execute the "ALTER TABLE ADD column null" statement when I revoke the update column rights from the view before (and re-grant them afterwards). That happened once in the past week...

1) Null value in Foreign key 2) extra value to indicate all the values in PK table apply
I have two tables  1) tblCustomer (ID, Name, City)  2) tblemp (ID, NAME, Dept.ID, tblcustomer.ID) Both the tables have ID as PKA emp can be either assigned a) All customers b)single customer c) NO customer Pls note:- there will never be 2 or 3 customer linked to emp (my actuall requirement tables are different but to explain i am using the above tables) I know how to assign single customer......but had problem how to link all customers and "no customer" Please tell me if the following solution is right?1) I will manually insert a record in tblCustomer with id 0 as " all custom...

Primary Key/Foreign Key relationship errors
Hey All,  So I am having trouble getting Dynamic Data to set up my SQL Data properly. For some reason, it is not reading the primary key/foreign key relationships correctly. Here is an example of the warning message I am getting:  Warning 1 DBML1062: The Type attribute 'UpdatedInfo' of the Association element 'Location_UpdatedInfo' of the Type element 'Location' does not have a primary key.  No code will be generated for the association.  0 0 Warning 2 DBML1062: The Type attribute 'UpdatedInfo' of the As...

integer primary/foreign key vs. varchar(255) primary/foreign key
Hello. Is there any principal performance (or some other) difference between using the integer primary/foreign key and using the string (varchar(255)) keys in queries that use tables joins? Server is Sybase SQL Anywhere 5.5.04 Yes! The primary key will only be made up of 12 bytes. By using an integer you ensure that your entire column is in the key. -- Jim Egan [TeamPS] Dynamic Data Solutions, Inc. http://www.dyn-data.com Houston, TX *********************************************************** Enterprise Applications in Your F...

Keys, keys,keys...
Just installed PGP 6.5.8 and all is running fine, so far :-) Question: When I opened the PGP Keys window for the first time, apart from the *Create Key* wizard, there are about 50 odd keys belonging to various and sundry at NAI. Were these supplied for a purpose or only for illustration? Is there any reason they could not or should no be deleted? Question 2: I sent someone an encrypted test message using that person's public key. It went off fine except, I am left with only the encrypted eMail. What setting should I change in order for my eMail client (Outlook 2000) ...

Ways to get a mapping of values versus keys in a hash where there is one-to-one mapping between the keys and the values !
------=_Part_6250_27861417.1227632496175 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all, I recently had one requirement where I needed to get the key in a hash on the basis of supplied value. There is one additional information that there is one to one mapping between the keys and the values. I was able to do that by defining a extra array and hash variables as shown in the program below but I feel this approach will not work for all scenarios like :- 1. When the value of a particular key is undef in the ori...

foreign key as a primary key
hi, I am using a foreign key (which is a primary key in a secondary table) as a primary key in a primary table. There is also another primary key in the primary table. Do You have to declare the foregin key as a primary key ? regards Jan Eikeland email:jaeikela@c2i.net url :http://home.c2i.net/jaeikela In article <368b0234.5056065@forums.powersoft.com>, jaeikela@c2i.net says... > hi, > > I am using a foreign key (which is a primary key in a secondary table) > as a primary key in a primary table. > There is also another primary key in the primary table...

primary key and foreign Key????
 Hi i have 2 table.. Table1UID         Username1               AB2               CD3               DD Table 2ITEM       Price          UIDPOO1      20.00          1POO2      10.00          2POO3       15.00         1 Now i am letting the Admin to delete the user in table1But since UID 1 and 2 are ...

Primary key
Hello, I've got a modeling problem betwin a conceptual model and a physical model and espacially about the foreign key. See below the illustrated exemple of the problem : -Whether the entity � ARTICLE � with two informations : CODE & WORDING -Whether the entity � UNITE � with two informations : CODE & WORDING An article has necesseraly three unity, the unity of command, of storage and of sails. These three unity can be differents. Conceptual model phycical model The generated physical model doesn't suitable me. How ...

Web resources about - no primary key value for foreign key value error in Master-Detail Dataset - embarcadero.delphi.firedac

Skylanders Trap Team - Hands On Interview, Full Details & Trap Masters - YouTube
Skylanders Trap Team is announced and we sit down with Jeff Poffenbarger, Executive Producer at the Skylanders Trap Team launch event to get ...

Apple Reveals Master Details of Wireless Charging System
On September 19, 2013, the US Patent & Trademark Office published a patent application from Apple that reveals master details of their proposed ...

BBC Sport - The Masters: BBC coverage details from Augusta
How to follow BBC Sport's coverage of The Masters on BBC TV, radio and online.

Showtime Prez Reveals All Renewal Plans, ‘Masters of Sex’ and ‘Ray Donovan’ Details
Showtime’s David Nevins updates renewal prospects for all his series and new details on upcoming projects including Ron Howard's 'Conquest.' ...

TCA: HBO Reveals Details Of Mike Nichols/Meryl Streep ‘Master Class’, Queen Latifah ‘Bessie’ Project ...
HBO parsed out some details on Mike Nichols directing of Meryl Streep in the network's adaptation of Master Class, Terrence McNally's Tony Award-winning ...

‘The Flash’ Season 2 SPOILERS: Mirror Master Attacks? Grant Gustin Reveals Premiere Details
"The Flash" star Grant Gustin recently revealed that fans will meet the centrai villain for season two during the premiere and also discussed ...

Full Soundtrack Details For 'The Master' Featuring Jonny Greenwood's Score & Songs By Ella Fitzgerald ...
Yes, Paul Thomas Anderson's "The Master" is on the way, and where once secrecy and mystery reigned, now it seems we can't get enough info about ...

‘Halo 3: ODST’ Out For ‘Master Chief Collection’ On Xbox One, Full Details
... outro loading screen after a match [Images via Halo Waypoint ] ‘Halo 3: ODST’ Out For ‘Master Chief Collection’ On Xbox One, Full Details ...

Latest Benchmarking Tests Give More Details on OnePlus Two! - Master Herald
While there have been significant amount of information regarding the features and specifications on the upcoming flagship smartphone OnePlus ...

‘The Master:’ See 18 New Photos, Plus Detail About the Film’s 65mm Component and Planned Presentation ...
Anticipation for Paul Thomas Anderson ‘s new film The Master kicked into high gear recently thanks to a wonderful full trailer and the sooner-than-expected ...

Resources last updated: 12/6/2015 11:34:03 PM