KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method that returns the primary key's field id
PRODUCT: 4D | VERSION: 12.5 | PLATFORM: Mac & Win
Published On: March 5, 2013

Here is a utility method that returns the field id that is set as the primary key field in a table.

  //Method: GET_PRIMARY_KEY_FIELD_ID
  // $1 - Table ID

C_LONGINT($0;$1;$table_id_l;$primary_key_field_id_l)

If (Count parameters>=1)
  $table_id_l:=$1
  Begin SQL
    SELECT COLUMN_ID
    FROM _USER_CONS_COLUMNS
    WHERE TABLE_ID = :$table_id_l
    INTO :$primary_key_field_id_l;
  End SQL
End if

$0:=$primary_key_field_id_l