rowversion as column datatype

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dupe
Posts: 21
Joined: Wed 15 Jun 2016 13:37

rowversion as column datatype

Post by dupe » Thu 17 Nov 2016 14:18

Hello,

we are using the rowversion datatype in our SQL Server tables.
Now we want to copy a record in our application.
But this record is made up with different JOIN's.
In the past we determined the rowversion column with its name "TS".
Now SDAC creates multiple columns for each joined table. So we have columns called "TS_1", "TS_2" and so on.
If we check those columns we get the field information as ftBytes.
We think this is because SQL Server treats rowversion as a binary(8) column.

So our question is how we can check if its a rowversion column or not?

Best regards

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: rowversion as column datatype

Post by azyk » Wed 23 Nov 2016 08:33

To solve the described issue, you can check a value of the TMSFieldDesc.IsTimestamp property for the field - a True value means that the field data type is timestamp (rowversion). The code example can look like this:

Code: Select all

var
  i: integer;
  FieldDesc: TMSFieldDesc;
  Field: TField;
begin
...
  MSQuery.Open;
  for i := 0 to MSQuery.Fields.Count - 1 do begin
    Field := MSQuery.Fields[i];
    FieldDesc := TMSFieldDesc(MSQuery.GetFieldDesc(Field));

    if FieldDesc.IsTimestamp then ...
To use TMSFieldDesc, add the MSClasses unit into the uses clause.

Post Reply