Now Available in Community - New TechTalk Videos for 2020
Read More about New TechTalks for 2020
2020 release wave 1Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I am uploading information to a temporary table, but I need to delete a record in that table if it already exists, that is, if there are two AssetId records that delete one and leave the other.
This thread has been moved to the Finance forum.
Do you need to delete anything? Can't you skip the duplicate record? If not, isn't an update better then delete + insert?
You can create a unique index on the field, try to do insert and catch DuplicateKeyException. Or you can try to find an existing record before writing.
Where do you get data from? You can make things easier and more efficient if you sort data by AssetId before writing into the table. Then you can simply check if the asset ID isn't the same as the previous one.
Was your question answered? If so, would you mind to verify the answer from Martin? The status of the trhead will then be set to Answered.
Hello, before the answer I solved it using a While Select with a Select firstOnly ... thanks
If you want to select just the first record, then there is no point in using a while select. Use a select statement without a loop.
It's also not clear how the solution is related to your question. Did you use it for checking data before writing? Or did you actually asked a wrong question and the problem was how you obtained the data?
Through a View the information is loaded into a temporary table, but if in the index I enable the Non-Duplicate does not load, this was the statement used:
while select corpConsultaAF_AbiertoNOPP06626_View
where corpConsultaAF_AbiertoNOPP06626_View.FechaAdquisicion >= dateInicial && corpConsultaAF_AbiertoNOPP06626_View.FechaAdquisicion <= dateFinal
&& corpConsultaAF_AbiertoNOPP06626_View.Estado == corpEstado
&& corpConsultaAF_AbiertoNOPP06626_View.Ubicacion == corpSede
select firstOnly corpConsultaActivosFijosTmp
where corpConsultaActivosFijosTmp.NumeroActivoFijo == corpConsultaAF_AbiertoNOPP06626_View.NumeroActivoFijo;
corpConsultaActivosFijosTmp.CodActividad = corpConsultaAF_AbiertoNOPP06626_View.CodigoActividadActivo;
corpConsultaActivosFijosTmp.CodGrupoPpal = corpConsultaAF_AbiertoNOPP06626_View.CodGrupoPrincipal;
corpConsultaActivosFijosTmp.CodGrupoPropiedad = corpConsultaAF_AbiertoNOPP06626_View.CodGrupoPropiedades;
corpConsultaActivosFijosTmp.ModeloValor = corpConsultaAF_AbiertoNOPP06626_View.ModeloValor;
corpConsultaActivosFijosTmp.NumeroActivoFijo = corpConsultaAF_AbiertoNOPP06626_View.NumeroActivoFijo;
Business Applications communities