I'm using DELPHI XE6 with FireDAC components and has a SQL Server database server.
In the database, I have a stored procedure that takes two parameters, one integer and then a table variable that takes just one columns of type integer.
The table variable can contain from zero to multiple integers.
The head of the procedure:
/*
Declare @Temp dbo.LIP
insert into @Temp
Values(10901), (10902), (10903), (10904), (10905), (10912)
exec [dbo].[sp_lager_PkgList] 19, @Temp
*/
ALTER PROCEDURE [dbo].[sp_lager_PkgList]
@OwnerNo INT,
@LIPVariable dbo.LIP READONLY
AS
BEGIN
The outcommented part contains code that I used to check that the procedure is working ok - and it does.
In Delphi I did like this:
procedure TForm1.setUpParams;
var
sLIPNo: string;
ii: Integer;
begin
try
spMain.Prepare;
spMain.Params.ParamByName('@OwnerNo').AsInteger := StrToInt(edtPOwner.Text);
with spMain.Params.ParamByName('@LIPVariable') do
begin
DataType := ftDataSet;
DataTypeName := 'dbo.LIP';//'LGlager_PkgList.@LIPVariable';
end;
fdmtblLIPNo.Active := false;
fdmtblLIPNo.Active := True;
fdmtblLIPNo.BeginBatch();
try
for sLIPNo in mmoPLIPs.Lines do
begin
fdmtblLIPNo.Append;
try
fdmtblLIPNo.FieldByName('LIPNo').AsInteger := StrToInt(sLIPNo);
fdmtblLIPNo.Post;
finally
end;
end;
finally
fdmtblLIPNo.EndBatch;
ii := spMain.Params.ParamByName('@OwnerNo').AsInteger;
mmoDebug.Lines.Add(IntToStr(ii));
end;
spMain.ParamByName('@LipVariable').AsDataSet := fdmtblLIPNo;
finally
end;
end;
When I later execute this procedure in the delphi program none of the parameters is transfered. I have checked that the procedure is executed so that part works.
What am I doing wrong? What should I do?
This is the script for dbo.LIP, it's not directly rocket science..
CREATE TYPE [dbo].[LIP] AS TABLE(
[LIPNo] [int] NULL
)