@Benjamin We do have the "strange behaviour" documented, see the 3rd sentence of the "Important note" here
https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_result_sets_DECLARE.html ... Do not mix ? SQL parameter placeholders with program variables: This would lead to a runtime error at OPEN or at FOREACH time, because the number of SQL parameters will not match the number of variable provided in the USING clause.
To also add understanding, look at the FGLSQLDEBUG of a static SQL statement with a host variable.
For instance
LET numcli = '8905'
SELECT custname FROM fdecus WHERE custnr=$numcli AND cussupcd='C'
yields in FGLSQLDEBUG, note the host variable is a parameter and passed using using ...
SQL: SELECT custname FROM fdecus WHERE custnr = ? AND cussupcd = 'C'
| 4gl source : play.4gl line=33
| ../ODI_common.h:00829(3) : adaptStatement: stmt type = 1
| ../ODI_common.h:00834(3) : adaptStatement: ifxemul = 1
| sqt.c:00861(3) : Nat stmt1 = select custname from fdecus where custnr = ? AND cussupcd = 'C'
| sqlcode : 100
| sqlerrd3 : 0
| curr driver : ident='dbmsqt'
| curr connection : ident=':memory:' (dbspec=[:memory:])
| using: 1
| t: STRING f:01 v:"8905"
| Timestamp : 2024-10-11 09:48:44.17306
| Execution time : 0 00:00:00.00007
@Seb - perhaps we can improve the visibility of that note