#1 2017-07-26 15:29:05

dka1
Member
From: Greece
Registered: 2017-07-25
Posts: 28

Copy of RowsVariant

I try to get result of a query using my function

function GetValues(const sql: string; var ResData: variant): boolean
var
  IRows: ISQLDBRows;
begin
  result:= False;
  IRows:= fProps.Execute(SQL, [], @ResData);
  Result:=Assigned(IRows);
  if result then 
    IRows.Step;
end;

But when IRows goes out of scope ResData has no data to access.
Is any way to use a temp variant and then copy values to ResData or I must iterate through IRows
and copy data to ResData  as TDocVariantData(ResValues).AddValue(IRows.ColumnName(i), IRows.ColumnVariant(i))?

Offline

#2 2017-07-26 16:56:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Copy of RowsVariant

It is as expected: ResData is filled with a reference to the IRows instance...
So when IRows is finalized, ResData is not able to find the reference information.

Note that ResData is a custom variant, as defined in TSQLDBRowVariantType.
It is not a TDocVariantData kind of variant.

I've just added a new ISQLDBStatement.RowDocVariant method, to create directly a TDocVariant containing the row.
See https://synopse.info/fossil/info/113b21fbb5

Online

#3 2017-07-27 06:22:13

dka1
Member
From: Greece
Registered: 2017-07-25
Posts: 28

Re: Copy of RowsVariant

Thank you,
you are really awesome, very fast, available, approachable, high knowledge.
Delphi community must be very proud with people like you,
I am very happy to cooperate with you smile

Offline

Board footer

Powered by FluxBB