Parameter in Myscript

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
[email protected]
Posts: 12
Joined: Tue 11 Oct 2005 14:03

Parameter in Myscript

Post by [email protected] » 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

PavloP
Devart Team
Posts: 149
Joined: Fri 24 Jan 2014 12:33

Re: Parameter in Myscript

Post by PavloP » Tue 06 May 2014 09:07

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;

Post Reply