Hi
I want to update country region Id's in TaxVatNumTable.
If the record doesnt already exists, it must be insterted.
I import the new values from a .csv file.
Here is my code. When I run the code, I get an error, that "The record already exists". But its just the VatNum that exists in the table is for another company.
ttsBegin;
while (file.status() == IO_Status::Ok && conLen(conRecord) > 0)
{
contactView.clear();
counter++;
Progress.incCount() ;
nowHandling++;
accountNum = strLwr(conPeek(conRecord, 2));
select forUpdate firstOnly RecId from tmpcustTable
where tmpcustTable.AccountNum == accountNum;
name = conPeek(conRecord, 1); // Navn
name = strLRTrim(name);
land = conPeek(conRecord, 7); // Land
tmpcustTable.VATNum = conPeek(conRecord, 6);
if (!land)
{
// Skal sættes (CountryRegionId) ellers fejl ved insert af adresser
land = 'DNK';
}
else
{
logisticsAddressCountryRegion = LogisticsAddressCountryRegion::findByISOCode(land);
land = logisticsAddressCountryRegion.CountryRegionId;
}
if(tmpcustTable && tmpcustTable.VATNum != '')
{
select forUpdate taxVATNumTable where
taxVATNumTable.VATNum == tmpcustTable.VATNum &&
taxVATNumTable.Name == name;
if(taxVATNumTable)
{
taxVATNumTable.CountryRegionId = land;
taxVATNumTable.doupdate();
tmpcustTable.update();
}
else
{
taxVATNumTable.CountryRegionId = land;
taxVATNumTable.doInsert();
}
}
conRecord = file.read();
}
}
ttsCommit;
*This post is locked for comments
I have the same question (0)