Hi everyone, I am trying to update a SQL DataTable with this query.
UPDATE EXPEDIENTE LEFT JOIN RELACION_BACK ON EXPEDIENTE.CodExpediente = RELACION_BACK.CodExpediente
SET SolicitadoABSIS=1, FechaSolicitadoABSIS = @PFechaSolicitadoABSIS
WHERE RELACION_BACK.CodConcepto=160 And RELACION_BACK.Importe>0 And EXPEDIENTE.IDExpediente=@PExpediente;
The query works propperly when I execute it on Access, but when I execute a non-query from UiPath, I get this error message:
RemoteException wrapping System.Data.SqlClient.SqlException: Sintaxis incorrecta cerca de la palabra clave 'LEFT'.
at UiPath.Database.Activities.ExecuteNonQuery.<ExecuteAsync>d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at UiPath.Database.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
UPDATE EXPEDIENTE SET SolicitadoABSIS=1, FechaSolicitadoABSIS = @PFechaSolicitadoABSIS FROM EXPEDIENTE JOIN RELACION_BACK ON EXPEDIENTE.CodExpediente = RELACION_BACK.CodExpediente
WHERE RELACION_BACK.CodConcepto=160 And RELACION_BACK.Importe>0 And EXPEDIENTE.IDExpediente=@PExpediente;
Hi Emira, thanks for your answer. To understand de query… if SolicitadoABSIS and FechaSolicitadoABSIS are fields in RELACION_BACK table, should I write “UPDATE RELACION_BACK SET …” or I have to write “UPDATE EXPEDIENTE SET …” because the left table is EXPEDIENTE?
Hi @ajgb
Can you share the two tables structures? Not sure where those fields belong.
If the two fields you are trying to update belong to the RELACION_BACK table, then the query would be:
UPDATE RELACION_BACK SET SolicitadoABSIS=1, FechaSolicitadoABSIS = @PFechaSolicitadoABSIS FROM EXPEDIENTE LEFT JOIN RELACION_BACK ON EXPEDIENTE.CodExpediente = RELACION_BACK.CodExpediente
WHERE RELACION_BACK.CodConcepto=160 And RELACION_BACK.Importe>0 And EXPEDIENTE.IDExpediente=@PExpediente;