How to use SQL Server data table type in Delphi using FireDAC?

For instance:

I have a data table type in SQL:

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

And the stored procedure in SQL, for example:

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

And now the problem !!!: When I send the table as a parameter in delphi as follows:

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

And when I run this, the accour error is allegedly not supported.

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

+4
source share
1 answer

I think so:

Set the DataType = ftObject;

Set datatypename = <your_procedureName>.<your_parameter>

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

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

+1
source

Source: https://habr.com/ru/post/1677056/


All Articles