Sc_exec_sql macro

Hello.
i have a control application where in the onLoad event can’t manage to use the sc_exec_sql Macro.

when i use it always gives me a syntax error.

the syntax i am using is:

sc_exec_sql(“INSERT INTO indicators(calculation_date,eus1) VALUES($data_server,$eus1)”);

is there any error?
the two variables are declared before that.

is this macro supposed to work in the onLoad event of a control form application?
from the documentation can not be so sure.
Thank you

Yes, in the documentation only says this macro works in onLoadAll not in onLoad. Try to put your code in onScriptInit event.

Another tip would be that you should use a local variable to get your code and pass it to the macro, like this:

$cSql = “INSERT INTO indicators(calculation_date,eus1) VALUES($data_server,$eus1)”);
sc_exec_sql($cSql);

You can try use single quotes for string variables like : ‘$data_server’

1 Like

Try this:
$cSql = “INSERT INTO indicators(calculation_date,eus1) VALUES(’$data_server’,’$eus1’)";
sc_exec_sql($cSql);

1 Like

i opted to create a grid and tu put the code in the onrecord event. Thanks everybody.