Pass parameter to sql "in" clause

I'm using Fast Report community desktop app and I haven't been able to pass the parameter value to the following query:

The parameter is using @ because I'm connecting to mysql. The data type I'm using for @receivables query parameter is Varchar and the report parameter datatype is string. The value of the parameter I'm passing in is something similar to '1, 2, 3'.

Does anyone know how I can get this parameter working?

Query:

select * from receivables where id in(@receivables)


Thanks,

Comments

  • Hello!

    Load the sample data into a table and set a filter in the DataBand (taking account of spaces in the parameter): ( ‘,’ + [ParamIds].Replace(‘ ’, “”) + ‘,’ ).Contains(‘,’ + ToString([Orders.Id]) + ‘,’).

    On the SQL Server (2016+) / MySQL / PostgreSQL side, you can make the following changes:

    MS SQL: WHERE Id IN (SELECT TRY_CAST(TRIM(value) AS INT) FROM STRING_SPLIT(@receivables, “,”))

    MySQL: WHERE FIND_IN_SET(Id, REPLACE(@receivables, “ ”, “”)) > 0

    PostgreSQL: WHERE Id = ANY(string_to_array(replace(@receivables, “ ”, “”), “,”)::int[])

    Via SelectCommand in StartReport: generate/insert a safe list of numeric IDs into TableDataSource.SelectCommand before loading the data.

This discussion has been closed.