Page 1 of 1

About TMystrdPrc

Posted: Tue 31 Aug 2010 06:56
by vga
I have a mystrdprc with 7 params

CREATE DEFINER=`root`@`%` PROCEDURE `getnext`(
inout `picid` int(11) ,
out `filename` varchar(100),
`process` int(11),
`Step` int(11),
`Taskid` int(11),
`typer` int(11),
`toid` int(11)
)
BEGIN
if `process` = 3 then /* 3 码流程 */

case step
when 0 then
begin
update `state` set `k0`=`typer`, `s0`=1, `st0`=now()
where `data_id` between `picid` and `toid` and `Task_ID`=`taskid` and `s0`=0 and k1 `typer` limit 1;

select `data_id`, `PicName` into `picid`, `filename`
from `state`
where `data_ID` between `picid` and `toid` and `s0`=1 and `k0`=`typer` limit 1;
end;

when 1 then
begin
update `state` set `k1`=typer, `s1`=1, st1=now()
where `data_id` between `picid` and `toid` and `Task_ID`=`taskid` and `s1`=0 and k0 `typer` limit 1;

select `pic_id`, `PicName` into `picid` , `filename`
from `state`
where `data_ID` between `picid` and `toid` and `s1`=1 and `k1`=`typer` limit 1;
end;

when 2 then
begin
update `state` set `k2`=typer, `s2`=1, st2=now()
where `pic_id` between `picid` and `toid` and `Task_ID`=taskid and s0=2 and s1=2 and `s2`=0 and k0 `typer` and k1 `typer`limit 1;

select `data_id`, `PicName` into `picid` , `filename`
from `state`
where `data_ID` between `picid` and `toid` and `s2`=1 and `k2`=`typer` limit 1;
end;

end case;

else /* 2 码流程 */
case step
when 1 then
begin
update `state` set `k1`=typer, `s1`=1, st1=now()
where `Task_ID`=taskid and `s1`=0 and `pic_id` between `picid` and `toid` limit 1;

select `data_id`, `PicName` into `picid` , `filename`
from `state`
where `data_ID` between `picid` and `to_id` and `s1`=1 and `k1`=`typer` limit 1;
end;

when 2 then
begin
update `state` set `k2`=typer, `s2`=1, st2=now()
where `pic_id` between `picid` and `toid` and `Task_ID`=taskid and `s2`=0 and k1 `typer` limit 1;

select `data_id`, `PicName` into `picid` , `filename`
from `state`
where `data_ID` between `picid` and `toid` and `s2`=1 and `k2`=`typer` limit 1;
end;

end case;
end if;


/*

set @picid = 99990;
SET @file1='';

call `getnext`( @picid, @file1, 3, 0, 0, 1234, 100000);
select @picid, @file1;

*/

END;


when I use TMystrdPrc, I cannot uses
"mystrdprc1.ParamBynane('picid').AsInteger := 0;"
to set param values, why?


delphi 2010 & mydac 5.9.055

Posted: Tue 31 Aug 2010 07:48
by Dimon
Please specify the error message and the exact moment the error is raised.

Posted: Tue 31 Aug 2010 08:44
by vga
with message "Parameter 'picid' not found'.

but I show Parameter with:

mmo1.Lines.Text :=
mystrdprc1.Params[0].Name + #13 +
mystrdprc1.Params[1].Name + #13 +
mystrdprc1.Params[2].Name + #13 +
mystrdprc1.Params[3].Name + #13 +
mystrdprc1.Params[4].Name + #13 +
mystrdprc1.Params[5].Name + #13 +
mystrdprc1.Params[6].Name;

result is:

`picid`
`filename`
`process`
`Step`
`Taskid`
`typer`
`toid`

Posted: Tue 31 Aug 2010 12:51
by Dimon
Because you've created a stored procedure with quoted parameters names you should use quoted names in the ParamByName method as well.

mystrdprc1.ParamByName('`picid`').AsInteger := 0;

Posted: Wed 01 Sep 2010 02:40
by vga
thank you!