Input Argument received correctly from Orchestrator, but Run Query returns empty DataTable

Hi everyone,

Iโ€™m facing an issue with a Run Query activity in UiPath using ODBC (SQL Anywhere).

:pushpin: Scenario

  • The process is started via Orchestrator API Trigger
  • An input argument CodEmpresa (Int32) is sent in the request body
  • In the Orchestrator Job Info, the argument value is correct:
InputArguments: { "CodEmpresa": 3 }
  • The project has only one XAML, set as Main / Entry Point

:pushpin: Implementation

  • Workflow argument:
    • Name: CodEmpresa
    • Type: Int32
    • Direction: In
  • Database connection via ODBC SQL Anywhere (System DSN)
  • SQL used in Run Query:
"select 
 i_empregados,
 CPF
 from bethadba.fofilhos
 where codi_emp = " & CodEmpresa.ToString & "
 and cpf is null"
  • The Run Query executes without errors
  • The output DataTable contains only the column headers, no rows

Result

Hi @robot.gestus

You can use parametrized query

select
i_empregados,
CPF
from bethadba.fofilhos
where codi_emp = ?
and cpf is null

Cheers

@robot.gestus

instead of trigger first did you check with assigning value to variable and run it and check..is it returning the correct data?

cheers

Hi @robot.gestus

Fix the where clause to handle both NULL and empty values:

WHERE codi_emp =3
AND (CPF IS NULL OR TRIM(cpf)=โ€™ ')
Also ensure codi_emp is an INT column, matching the Int32 argument
this is data condition issue not a UiPath issue or Orchestrator issue.

First check if your query works, try to give value for codEmpresa in variable from code and check if it returns you data..

Hi @robot.gestus

If solution works for you please mark as solved so thread will be closed

Thanks

If you need any further help related to this feel free to ask and if this solution works, please mark it as the Accepted Solution so that the topic can be closed.

Hi @robot.gestus

The argument is coming correctly from Orchestrator.
The issue is the string-concatenated SQL with ODBC.

SQL Anywhere is strict and the filter doesnโ€™t match, so you get only headers.

Fix: use a parameterized query (?) in Run Query and pass CodEmpresa as a parameter.

Example:
select
i_empregados,
CPF
from bethadba.fofilhos
where codi_emp = ?
and cpf is null