How to work with GUID field in Firebird database?

How to work with GUID field in Firebird database?

Postby VadimMescheryakov » Wed 09 Dec 2015 10:33

Hello

How to work with GUID field in Firebird database?

I created next table:

create table test (id Integer, GUID char(16) octets);

How assign values to GUID fields from my applicaton?
VadimMescheryakov
 
Posts: 9
Joined: Tue 30 Nov 2010 04:17

Re: How to work with GUID field in Firebird database?

Postby ViktorV » Thu 10 Dec 2015 18:19

To set the GUID field value, you can use the following code:
Code: Select all
procedure TForm.Button1Click(Sender: TObject);
var
  GUID: TGUID;
  Arr: TBytes;
begin
  ClientDataSet.Edit;
  Arr := GUID.Create('{F0C5A5FC-8E64-48FB-80B0-A62FFED81E48}').ToByteArray;
  ClientDataSet.FieldByName('guid').AsBytes := Arr;
  ClientDataSet.Post;
  ClientDataSet.ApplyUpdates(0);
end;
ViktorV
Devart Team
 
Posts: 1831
Joined: Wed 30 Jul 2014 07:16


Return to dbExpress driver for InterBase & Firebird