Hello.
I would write a script in Commands->scripts,
but I would like to pass one or two parameters to that script via a client written in Delphi.
The script is similar to the one below.
How do I pass the parameters via command.execute?
log(“begin”);
var sql = ‘select field1,field2… from table where id_pk = :pid_pk order by fieldx’;
var params = { pId_pk : ‘116’ };
var result2 = lda.selectSQL(sql, params);
for (i = 0; i < result2.count; i++)
{
var row = result2[i];
log(row[1]+": "+ row[“field2”]);
lda.insert(“table2”, { date: new Date(), field1: row[1], field2: row[2] } );
lda.applyChanges();
}
log(“end”);
beforeExecuteCommand(sql, commandName, parameterNames, parameterValues)
Called before an SQL command is executed.
sql contains the SQL to execute, commandName the name of the command.
parameterNames is an array of parameter names
parameterValues is an array of object values
so you have received arrays of parameter names and values.
try to use something like
for (var i=0,len=parameterNames.length; i<len; i++)
{
if (parameterNames[i] == "idTurma") { Log(parameterValues[i]); }
}
Updates a row in the table “table”. The “oldvalues” parameter can be the same as the “newvalues” parameter if the primary key hasn’t changed. Both values have to be javascript objects with key:value pairs.