UUID – a practical joke?


UUIDs sind nichts Neues. Ich habe sie in 4D lange vermißt. Bis zur V13 einschließlich sind UUIDs in 4D mehr ein practical joke.

Sehen Sie sich die V13 an. Ein Feld angelegt, 20 Datensätze von „A“..“T“ erzeugt, Datensätze angesehen. Anschließend ein Feld vom Typ UUID mit der Eigenschaft Auto UUID hinzugefügt und als Primärschlüssel der Tabelle definiert. Z.B. via SQL

$statement_t:=“ALTER TABLE [Tabelle_1] ADD tab1_uuid UUID AUTO_GENERATE PRIMARY KEY;“
Begin SQL
EXECUTE IMMEDIATE :$statement_t;
End SQL

Das UUID-Feld in das Ausgabe-Formular aufgenommen, um sich das Feld anzusehen. Alle Felder sind mit einer UUID gefüllt. Super, so möchte ich das haben. Doch halt. Fenster anfassen und alle UUIDs haben sich verändert. Erneut anfassen, erneut ändern sich alle angezeigten UUIDs.

V13

Das macht keinen Spaß! Was mache ich jetzt. Dem Feld in allen Datensätzen einen Wert mit Generate UUID zuweisen? Ich brauche das UUID-Feld nur, um in V14 das Logbuch führen lassen zu können.

Also in V14 testen. Die in V13 angelegte Datenbank mit V14 öffnen, konvertieren lassen, und …? Die UUIDs stehen. Egal wie häufig ich wechsele, die UUIDs verändern sich nicht. Noch mal Glück gehabt. Dann ist mir den Inhalt der UUID-Felder in V13 egal.

UUIDs stay, as soon as in V14
UUIDs ändern sich nicht mehr in V14

Dazu auch Avoid Primary Key-Assistant



UUIDs are no new concept at all. I missed them for quite some time in 4D. These days, up to and inclusive V13, I treat UUIDs as a practical joke.

Do as follows in V13. New database, one table, one field. Create 20 records from „A“..“T“. Check the records content. Then add a field of type UUID, Auto UUID checked and defined as primary key for this table. Or use this SQL-snippet

$statement_t:=“ALTER TABLE [Tabelle_1] ADD tab1_uuid UUID AUTO_GENERATE PRIMARY KEY;“
Begin SQL
EXECUTE IMMEDIATE :$statement_t;
End SQL

To see the field-content add the UUID-field to the listform. Perfect, every UUID-field contains a UUID. Stop, what’s this! Every time a touch the window I get a new list of UUIDs. Every touch rebuilds all UUIDs visible, indeed.

V13

Hard to believe! What to do now? Generate content for every field procedurally, using Generate UUID? No way. The only reason I touched UUID at all is to run a log file in V14, which requires a 4D-known primary key-field.

Lets test how V14 behaves. Load the V13-created database with V14. Puh, UUIDs are permanent now. No update when touching the window. V13 runs a practical joke on us.

UUIDs stay, as soon as in V14
UUIDs stay, as soon as in V14

Further reading Avoid Primary Key-Assistant