Pseudo-field variables can only be returned for a table that contains data.
If multiple tables are specified in the FROM clause you must use table aliases, as shown in the following Embedded SQL example:
&sql(SELECT P.Name,P.%ID,P.%TABLENAME,E.%TABLENAME
INTO :name,:rid,:ptname,:etname
FROM Sample.Person AS P,Sample.Employee AS E)
IF SQLCODE<0 {WRITE "SQLCODE error ",SQLCODE," ",%msg QUIT}
ELSEIF SQLCODE=100 {WRITE "Query returns no results" QUIT}
WRITE ptname,"Person table Name is: ",name,!
WRITE ptname,"Person table RowId is: ",rid,!
WRITE "P alias TableName is: ",ptname,!
WRITE "E alias TableName is: ",etname,!