sc_select and sc_lookup may not have constant num values in the select statement

Use this SQL to create a simple dataset for test:

create table a_tbl (id int primary key, name varchar(45) );
insert into a_tbl (id, name) values (1, ‘A’), (2, ‘B’);

Then create a control application with one field called “test”. It doesn’t really matter what it is called – at least one field is needed to get the control app to be generated.

In the validation event put the following code:

$sql = “select id, name, 1 from a_tbl”;
sc_select(ds, $sql);
if ( $ds === false ) {
$msg = “Error when accessing data: <br>” . {my_data_erro}
. "<br>sql: " . $sql
;
sc_error_message($msg);
}
else {
$items = “”;
while ( ! $ds->EOF ) {
$items .= $ds->fields[0] . ": " . $ds->fields[1] . ": " . $ds->fields[2] . “<br>”;
$ds->MoveNext();
}
$items = rtrim($items, “|”);
}
sc_error_message($items);

Now, when one runs the application, ignore the test field and press OK: one gets this message:

1: 1: 1
2: 1: 1

The numerical constant value interferes with the execution. It does not help to enclose it in single quotes. If one puts a larger number, e.g. 4, it even gives errors accessing the records.
However, if you put a non-numerical text, e.g. ‘table’, it works.