Page 1 of 1

How to work with GUID field in Firebird database?

Posted: Wed 09 Dec 2015 10:33
by VadimMescheryakov
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?

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

Posted: Thu 10 Dec 2015 18:19
by ViktorV
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;