%Table
Replaces with the actual table name of the given record.
Generally, this just means adding a “PS_” to the front of the record name. But, PeopleTools actually checks the alternate table name from the Record Type tab to see if a value is there first.
Two Uses:
- Access a table with a reference or record object rather than embedding a table name in the SQL; PeopleTools will not index the table/record in a string literal.
- Reference the Temporary table in an App Engine; %Table is the only way to reference the table because the table name is assign dynamically at run time.
Examples:
SELECT * FROM %Table(JOB) WHERE EMPLID = :1
SqlExec(“SELECT NAME FROM %Table(:1) WHERE EMPLID = :2”, Record.NAMES, &emplid, &name);
&sql = CreateSql(“SELECT * FROM %Table(:1) WHERE EMPLID = :2”, &MyRecord, &emplid);
INSERT INTO %Table(MYTEMP_TAO)
SELECT * FROM PS_MYDATATABLE
%Table also has a very important use in Application Engines, when temporary tables are used. It resolves to the temporary table created.
Example:
If %Table(MY_TEMP_TABLE) is used on a AE which can be run parallely, on the first instance of the AE, %Table(MY_TEMP_TABLE) would become PS_MY_TEMP_TABLE01.
For the 2nd instance, it would be PS_MY_TEMP_TABLE02 and so on.
It should be mandatory to use %Table, I used TEMP table name instead and faced problem coz table name was assigned at run time.