Use the ADD5 template [message #1572] |
Tue, 26 August 2008 13:46 |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
I am trying to add multiple records into a table using the ADD5 function. However, I am getting error "Primary key (key name) is not complete - check selection".
I am calling the task from a parent screen (multi2) and expecting to see a number of blank rows in which to enter data. If I call the ADD2 function from this screen in exactly the same way everything works fine, but the ADD5 function gives the primary key error.
The primary key will be different for each inserted row anyway so I don't understand why the function expects it to be set in advance. The primary key is an auto increment and so is not set until database insert.
I'm clearly missing something obvious here so any pointers would be much appreciated.
|
|
|
Re: Use the ADD5 template [message #1573 is a reply to message #1572] |
Tue, 26 August 2008 14:33 |
AJM
Messages: 2369 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
The ADD5 pattern requires the identity of two tables, known as OUTER (parent) and INNER (child). It will add entries to the INNER table having a foreign key which is the primary key of the OUTER table. You must therefore supply the primary key of the OUTER table, which means that it must be called from a task which displays the OUTER entity so that a qualifying value can be passed in the $where string to the ADD5 task.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
Re: Use the ADD5 template [message #1581 is a reply to message #1580] |
Thu, 28 August 2008 10:47 |
AJM
Messages: 2369 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you want to take an existing row and put it back into the database with a different primary key then the ADD5 pattern is not what you want as this will always start with a blank screen and take all input from the user, not from an existing row which you selected previously.
As I said in an earlier post the ADD5 pattern works with an OUTER (parent) and INNER (child) entity - it will add new rows to the INNER entity with a foreign key which links back to the OUTER entity, and the only value which is passed to the ADD5 pattern in the $where string is the primary key of the OUTER entity.
If you want to take an existing record and put it back with a different primary key have you tried using the COPY and PASTE buttons? That is what they were designed for.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
Re: Use the ADD5 template [message #1584 is a reply to message #1572] |
Thu, 28 August 2008 11:43 |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
Thanks Tony. I haven't tried the non screen based transactions yet, so I'll have a closer look and see if I can achieve what I want.
|
|
|