String value as tableName in Select Statement

Hi have a string which stores the bufferTable name, now i want to use this string in a select statement,

Is there a way out?

thanks and appreciate any inputs

  1. Create SysDictTable instance from the table name
  2. Call makeRecord() and save return value to a variable of type Common
  3. Use the variable in query

For example:

SysDictTable dictTable = SysDictTable::newName('UserInfo');
Common common = dictTable.makeRecord();
   
while select common
{
    //This expects that the table contains "Name" field
    info(common.(dictTable.fieldName2Id('Name')));
}

Hi,

Other alternative is constructing a SQL statement using the variable which has got the table name. For instance -

str 500 sqlStat;
str tableName = ‘CustTable’;
;
sqlStat = 'select * from ’ + tableName;

You can then use Connection class to execute this statement.