Page 1 of 1

About TUniScript TParams................

Posted: Thu 05 Jan 2012 07:13
by TinTin
Happy New year,devart!

develop environment:
delphi xe,unidac 4.1.3,firebird 2.5.1, User_ID is BigInt Field.

TUniScript SQL.Text:

delete from pwr_user_role where User_ID = :UID;
delete from pwr_user_action where User_ID = :UID;
insert into pwr_user_role(User_ID,Role_ID,IsValid)
select &User_ID,Role_ID,1 from pwr_user_role where User_ID = :UID2;
insert into pwr_user_action(User_ID,act_id)
select &User_ID,act_id from pwr_user_action where User_ID = :UID2;


Why not TUniScript can not find second param:UID2?I have already mentioned the same problem(BigInt Param),And you have fixed it with UniDAC 3.70.XXX?




delphi code:

procedure TForm1.Button1Click(Sender: TObject);
var
i:Integer;
begin

//UniScript1.Params.`

UniScript1.Params.ParseSQL(UniScript1.SQL.Text,True);
// for i := 0 to UniScript1.Params.Count - 1 do
// ShowMessage(UniScript1.Params.Name); //count of param is 4

UniScript1.MacroByName('User_ID').Value := '12000';
UniScript1.Params.ParamByName('UID').Value := 12000;
UniScript1.Params.ParamByName('UID2').AsLargeInt := 1111111;


UniScript1.Execute;
ShowMessage('OK');
end;




SqlMonitor:

tfTransact:Start:

tfQExecute:delete from pwr_user_role where User_ID = :UID
:UID(Word)=12000

tfTransact:Commit:

tfTransact:Start:

tfQExecute:delete from pwr_user_action where User_ID = :UID
:UID(Word)=12000

tfTransact:Commit:

tfTransact:Start:

tfQExecute:insert into pwr_user_role(User_ID,Role_ID,IsValid)
select 12000,Role_ID,1 from pwr_user_role where User_ID = :UID2
:UID2(Unknown)=

tfTransact:Commit:

tfTransact:Start:

tfQExecute:insert into pwr_user_action(User_ID,act_id)
select 12000,act_id from pwr_user_action where User_ID = :UID2
:UID2(Unknown)=

tfTransact:Commit:

Posted: Thu 05 Jan 2012 11:46
by TinTin
I modify delphi code,but param value is still null!

procedure TForm1.Button1Click(Sender: TObject);
var
i:Integer;
begin

//UniScript1.Params.`

UniScript1.Params.ParseSQL(UniScript1.SQL.Text,True);
// for i := 0 to UniScript1.Params.Count - 1 do
// ShowMessage(UniScript1.Params.Name);

UniScript1.MacroByName('User_ID').Value := '12000';
for i := 0 to UniScript1.Params.Count -1 do
begin
if SameText(UniScript1.Params.Name,'UID') then
UniScript1.Params.Value := 12000
else if SameText(UniScript1.Params.Name,'UID2') then
UniScript1.Params.Value := 1111111
end;

//UniScript1.Params.ParamByName('UID').Value := 12000;
//UniScript1.Params.ParamByName('UID2').AsLargeInt := 1111111;


UniScript1.Execute;
ShowMessage('OK');
end;

Posted: Mon 09 Jan 2012 13:22
by AlexP
Hello,

For correct work in TUniScript with several parameters you should create additional DataSet (for example, place the TUniQuery component into a form), name the created DataSet in the UniScript1.DataSet property ( UniScript1.DataSet := UniQuery1) and assign parameters in the BeforeExecute event of this DataSet

Code: Select all

procedure TForm1.UniQuery1BeforeExecute(Sender: TObject);
begin
  if  UniScript1.Params.FindParam('UID')nil then
    UniScript1.Params.ParamByName('UID').Value := 12000; 
  if  UniScript1.Params.FindParam('UID2')nil then
    UniScript1.Params.ParamByName('UID2').AsLargeInt := 1111111; 
end;