DroidDB Tip of the Month

DroidDB® Tip for May 2020

Creating Unique Record ID's

When creating a new record, you may want to create a unique id value for it (like a PERSON_ID or a COMPANY_ID). This is very simple to do.

First, in your table, create a column to hold the unique value. We'll call the column RECORD_ID for the sake of this tip, but it can be anything you want. Since you would never add, subtract, multiply, etc. these values, make the column of type Text.

Then, create a macro that will create a record and assign a unique id to it:

    Step 1: RECORD | INSERT
    Step 2: ASSIGN   col: RECORD_ID   value: @oid

This will work well if you only have one handheld creating records, but if you have multiple handhelds creating records in the same table, there is a good chance that two different handhelds will generate the same RECORD_ID.

To avoid this problem, have your macro do this insted:

    Step 1: RECORD | INSERT
    Step 2: ASSIGN   col: RECORD_ID   value: @devicename & '_' & @oid

Just be sure that every device has a unique name. You can set the name of a handheld by using FILE | HANDHELD NAME in the DroidDB development environment.

 

Back to List »

Visit our store

Top rated! I needed a solid database application development tool for mobile devices. I chose DroidDB for Android OS because it provided a way to get a strong product to market quickly. DroidDB is relational, gives me control over form layout, handles macros, and supports events. It works on all Android versions I have tried and is a great companion product to SYWARE’s VisualCE.

Mark Read, President
SyntegraTech, Inc.

signup for our newsletter