Hello.
I'm writing a code for the following purposes:
1) You select records for ProdTable in the ProdTableListForm.
2) You push a button, and got a new form with the selected records from ProdTableListForm.
3) You assign new PoolID number on the records by changing the ProdPoolId field in the ProdPool table when you click on a button on the new form.
4) The new PoolId is validated in the records.
5) If the new PoolId doesn't exist in the ProdPool table it's necessary to create a record with that values, if it does exist nothing will happens.
-But when I do that I always got a error message: "The record already exist" and no records are created.
---
Here is the code for behind the OK button who assign the new pool ID's
public void clicked()
{
ttsBegin;
while select ptlTable
{
select forupdate prodTable
where prodTable.prodPoolId == ptlTable.ProdPoolId;
{
prodTable.ProdPoolId = getYear+""+getWkOfYr+""+ptlTable.ProdPoolId;
prodTable.DlvDate = ptlTable.NewDlvDate;
pool.Name = jdpPtlPoolDescr;
prodTable.update();
}
}
ttsCommit;
}
The code above work fine. It assign values to PoolId just like I want.
But after this code block another block is as follows.
ttsBegin;
while select ptlTable
{
select forupdate pool
where pool.ProdPoolId == ptlTable.ProdPoolId;
{
pool.ProdPoolId = ptlTable.ProdPoolId;
pool.Name = jdpPtlPoolDescr;
pool.insert();
}
}
ttsCommit;
After this code is run, the error appear: "Cannot create a record in Production pools (ProdPool). The record already exists."
But no records are created in the pool table though.