the stored procedure code is as follows:
The CREATE DEFINER=` root ` @ ` localhost ` PROCEDURE ` test ` ()
The begin
DECLARE GoodsID int the default 0;
DECLARE no_more_products, quantity_in_stock INT the DEFAULT 0;
DECLARE cur_product CURSOR FOR the select distinct goods_id from ecs_order_goods;
DECLARE the CONTINUE HANDLER FOR the NOT FOUND SET no_more_products=1;
Drop table if the exists tmptable;
Create TEMPORARY table tmptable
(
ID INT (11) the NOT NULL AUTO_INCREMENT,
StrInfo varchar (1000),
StrTotal varchar (500),
Primary key (ID)
);
The OPEN cur_product;
The fetch cur_product into GoodsID;
REPEAT
INSERT INTO tmptable (strInfo) VALUES (' 123 ');
The fetch cur_product into GoodsID;
UNTIL no_more_products=1
END REPEAT;
The CLOSE cur_product;
SELECT * FROM tmptable;
DROP TABLE tmptable;
end;
Delphi calling code is as follows:
With spExec do
The begin
The Close;
ProcedureName:='ecs_test';
The Parameters. The Clear;
Prepared:=false;
//Parameters. CreateParameter (' iUserID, ftInteger, pdInput, 4, iRow);
Prepared:=true;
The Open;
.
The end;
Then I add incoming parameters in the process of statement, other content,
The CREATE DEFINER=` root ` @ ` localhost ` PROCEDURE ` test ` ( in iUserID int
The begin
./* all of the code remains the same, */
The end;
Delphi calling code to the following:
IRow:=1;
With spExec do
The begin
The Close;
ProcedureName:='test';
The Parameters. The Clear;
Prepared:=false;
The Parameters. CreateParameter (' iUserID, ftInteger, pdInput, 4, iRow);
Prepared:=true;
The Open;
.
The end;
The correct result is executed, as shown in the figure:
if delete the content of the stored procedure at this time, just add a select statement to return a set of data, and there is no problem, that parameter is introduced into should be yes,
Please guide you got talent, thank you!
CodePudding user response:
With spExec do
The begin
The Close;
ProcedureName:='test';
Prepare;
ParamByName (" iUserID "). The Value:=4;//4 or iRow? Don't quite understand
//Parameters. CreateParameter (' iUserID, ftInteger, pdInput, 4, iRow);
The Open;
.
The end;
CodePudding user response:
With spExec do
The begin
The Close;
ProcedureName:='test';
Prepared:=True;
The Parameters. ParamByName (" iUserID "). The Value:=iRow;
//Parameters. CreateParameter (' iUserID, ftInteger, pdInput, 4, iRow);
The Open;
The end;
CodePudding user response:
I can't ~CodePudding user response:
With spExec do
The begin
The Close;
ProcedureName:='test';
The Parameters. The Clear;
The Parameters. CreateParameter (' iUserID, ftInteger, pdInput, 4, iRow);
The Open;
The end;
CodePudding user response:
Ado is already very old stuff, it is recommended that the UniDAC instead, I found there are many people on the BBS still use BDE, ado such antiques, really confusing,CodePudding user response:
Inertia, estimate that most developers use the Delphi 1/10 less than the ability of...CodePudding user response:
//can also wrote
With spExec do
The begin
The Close;
TestProc ProcedureName:=' ';
The Parameters. Refresh;
The Parameters. ParamByName (' @ iUserID '). The Value:=iRow;
The Open;
The end;
CodePudding user response: