HI
I found sp out param has no value .
Mysql stored proc is
delimiter //
DROP PROCEDURE if exists SP_ECP_TestOutParam;
//
create procedure SP_ECP_TestOutParam(
out RecordCount int
)
begin
select 1 as Id;
set RecordCount=10;
END
//
delphi Code :
var
I:Integer;
ParamName,ParamValue:string;
begin
uniStoredProc1.StoredProcName:='SP_ECP_TestOutParam';
uniStoredProc1.PrepareSQL();
uniStoredProc1.ExecProc;
for I := 0 to UniStoredProc1.ParamCount-1 do
begin
ParamName:=uniStoredProc1.Params.Items.Name;
ParamValue:=uniStoredProc1.ParamByName(ParamName).AsString;
end;
end;
but Paramvalue No Value ! Why ? can you tell me ,how to Setting?
mysql out param no Value
-
DemetrionQ
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: mysql out param no Value
Hello.
The problem is due to the fact that a SELECT query is executed within your procedure. As a result of execution, the procedure will return 2 datasets. UniStoredProc1 reads the first dataset and tries to find information about the returning parameter in it. Since the first dataset is a result of the SELECT query execution within the procedure, the parameter in the UniStoredProc1 is not filled in.
You have 2 ways to solve the problem:
- remove the SELECT query from the stored procedure;
- run the stored procedure in the following way:
The problem is due to the fact that a SELECT query is executed within your procedure. As a result of execution, the procedure will return 2 datasets. UniStoredProc1 reads the first dataset and tries to find information about the returning parameter in it. Since the first dataset is a result of the SELECT query execution within the procedure, the parameter in the UniStoredProc1 is not filled in.
You have 2 ways to solve the problem:
- remove the SELECT query from the stored procedure;
- run the stored procedure in the following way:
Code: Select all
UniQuery1.SQL.Text := 'CALL SP_ECP_TestOutParam(@out_value)';
UniQuery1.ExecSQL;
UniQuery1.SQL.Text := 'SELECT @out_value;';
UniQuery1.Open;
ParamValue := UniQuery1.FieldByName('@out_value').AsString;