Page 1 of 1

Parameter in Myscript

Posted: Wed 30 Apr 2014 13:51
I would like to have a script like that:
drop table IF EXISTS `reserve_maj` ;
create table reserve_maj select reference , cc.depot , sum(qte_vendu-qte_valide) as reste from cde_cli cc , ligne_cc lc where (cc.prep_ok < 10 ) and (cc.depot=:depot) and (cc.record=lc.record) and (qte_vendu > qte_valide) group by reference ;
alter table `reserve_maj` add index `reference` ( `reference`, `depot` );

and i want to pass depot as parameter like that :
myscript.Params.ParamByName('depot').AsString:='AZERTY';
it don't work

Thanks

Re: Parameter in Myscript

Posted: Tue 06 May 2014 09:07
by PavloP
TMyScript is not designed for work with parameters. However, if you need to use them, then the parameters should be placed before execution of each SQL statement. This must be done in the BeforeExecute event handler. For example:

Code: Select all

procedure TForm1.MyScriptBeforeExecute(Sender: TObject; var SQL: string; var Omit: Boolean);
begin
  if Pos(':depot', SQL) > 0 then
    MyScript.Params.CreateParam(ftString, 'depot', ptInput).AsString :='AZERTY';
end;