Non-query Issue. Update a composite table

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)

Could you help me with this issue?

Hi @ajgb
Can you try this:

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?

1 Like

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;

Here’s the syntax for Updates with join

Let me know if that works for you

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.