Subject How reliable is GEN_UUID()?
Author Luis Madaleno | magnisoftR
Hi,

How reliable is GEN_UUID()?

I am asking this question because for a table with only 272 records I get
values for the GEN_UUID() that are weird.
And many of those records got an empty value. Not NULL just empty.
And empty fields in my code would give-me an empty string (I guess).

How can I convert this value to a readable GUID value?

I have GUID field created as CHAR(16) CHARACTER SET OCTETS COLLATE OCTETS.
This field is filled in a trigger:

CREATE OR ALTER TRIGGER STOCK_MOVIMENTOS_BI FOR STOCK_MOVIMENTOS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
NEW.GUID = GEN_UUID();
END
^
CREATE OR ALTER TRIGGER STOCK_MOVIMENTOS_BU0 FOR STOCK_MOVIMENTOS
ACTIVE BEFORE UPDATE POSITION 0
AS
begin
if (NEW.GUID IS NULL) then
NEW.GUID = GEN_UUID();
end
^

I then used update stock_movimentos set guid=null;
To force values into the field.

Is anyone having problems using this kind of field as primary keys?

I was able to set the primary to this field in a table with almost 1 million
records, so I guess everything is ok.
And since the charset is OCTETS, was we see is not what is stored, and the
empty fields are not real empty.
Just need to clarify this.



Regards,

Luis Madaleno