Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Tweak content

...

  1. Change the Label to the mixed case MyTableID.
  2. Note the Data Type should be LONG.
  3. On the Attributes tab, set the External Name to mytableid | READONLY.
    • The first part is the lowercase name of the column in your PostgreSQL table.
    • READONLY tells Clarion that the field will always be set in the back-end, so never attempt to assign values to it directly.  Note the space on either side of the pipe character is required!
  4. On the Options tab, add a new property IsIdentity.  It's a Boolean, with a value of TRUE.

If you are using FM3, you can add the ForceSQLDataType Option and set it to serial, so that FM3 automatically uses this type when it creates your SQL table.  I've not had a chance to experiment with this myself, and I'll report back here if I run into problems with it.

Primary Key

You may have learned that keys defined on the Clarion side are there primarily for template use, and they need not be defined as-is on the SQL side.  Clarion will use the key definition in the dictionary to build the ORDER BY clause sent to SQL.  Keys on the SQL side are for efficient queries, and need not be the same in Clarion.  In summary, the keys defined in Clarion don't have to be defined in SQL, and vice versa.

...

        /AUTOINC=SELECT currval(<39>public.mytable_mytableid_seq<39>)
  • There are several additional driver options that you can add.  They don't specifically related to auto-numbering, but you should add them nonetheless.  You can look up each of these in the Clarion help:
        /BUSYHANDLING=2 /NESTING=1 /USEDECLAREFETCH=1
  • The Owner Name contains the SQL Connection String.  In my example I hard coded it, but usually I use a global variable that's used for all tables.  The value is set once when the program begins.  I use the ANSI driver (versus Unicode, as Clarion doesn't currently support Unicode), but I've been told that the Unicode version works fine as well.  The server in this case is called closet, the default port for PostgreSQL is 5432, the database is called test, the user is usr, and the password is pwd:

...