如何在Delphi中使用FireDAC使用SQL Server Table-Data类型?

时间:2022-06-30 16:32:02

For example:

例如:

I have a data-table type in SQL:

我在SQL中有一个数据表类型:

CREATE TYPE dbo.typTable1 AS TABLE
(
    Field1 INT NOT NULL,
    Field2 NVARCHAR(20) NULL
)

And a stored procedure in SQL, like this:

和SQL中的存储过程,如下所示:

CREATE PROCEDRE dbo.prcTest
    @XDataTable dbo.typTable1 READONLY
AS
BEGIN
    .
    .
    .

And now problem!!! : When i send a table as parameter in delphi like this:

现在问题!!! :当我在delphi中发送一个表作为参数时,如下所示:

FireDACStoredProcedure.Params.ParamByName('@XDataTable').AsDataset := 
    FireDACMemTable;

And when i run this, an error accour that say not supported.

当我运行这个时,会出现一个不支持的错误。

Please guide me...thanks to you so much...

请指导我......非常感谢你...

1 个解决方案

#1


1  

I am thinking something like that:

我在想这样的事情:

Set the DataType = ftObject;

Set datatypename = <your_procedureName>.<your_parameter>

With FireDACStoredProcedure.Params.ParamByName('@XDataTable') do
begin
DataType := ftObject;
DataTypeName := 'prcTest.@XDataTable';
end;

Inspired in https://delphiaball.co.uk/2016/04/29/interbase-array-fields-firedac/

灵感来自https://delphiaball.co.uk/2016/04/29/interbase-array-fields-firedac/

#1


1  

I am thinking something like that:

我在想这样的事情:

Set the DataType = ftObject;

Set datatypename = <your_procedureName>.<your_parameter>

With FireDACStoredProcedure.Params.ParamByName('@XDataTable') do
begin
DataType := ftObject;
DataTypeName := 'prcTest.@XDataTable';
end;

Inspired in https://delphiaball.co.uk/2016/04/29/interbase-array-fields-firedac/

灵感来自https://delphiaball.co.uk/2016/04/29/interbase-array-fields-firedac/