0

Let's say I have in my method this call:

fieldNum(_myTableName, HouseNumber);

How do I pass the _myTableName from another method? What type should this parameter have? I tried:

when _myTableName is int fieldNum(tableId2Name(_myTableName), HouseNumber);

But it doesn't allow this thing, then tried passing _myTableName as string, which I would logically also expect to work, but doesn't aswell, how do I pass the parameter to be able to use it in fieldNum call? Is it possible at all?

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Arturas M
  • 4,120
  • 18
  • 50
  • 80

1 Answers1

0

No, it is not possible, as the fieldNum built-in function is a compile-time function, which means you must pass a valid table and field name (not a string) as parameters.

There are other functions that operates on strings (fieldName2Id) or integers (fieldId2Name). These functions are evaluated at run-time.

Best practice is to pass table or field references as integers (TableId and FieldId extended data types respectively). If you intend to store the values in a non-temporary database table consider storing the names instead.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50