One way to encapsulate an alias reference would to be use a user-defined table function (UDTF):
Here's an example of how to reference a UDTF on a SELECT statement. UDTF references are allowed when creating SQL views and materialized query tables (MQTs).CREATE FUNCTION aliasudtf() RETURNS TABLE(col2 char(6), col3 int) LANGUAGE SQL NO EXTERNAL ACTION DETERMINISTIC DISALLOW PARALLEL BEGIN Return ( select c2,c3 from alias1 union all select c2,c3 from alias2); END;
SELECT col2 FROM TABLE( aliasudtf() ) x;
Dig Deeper on iSeries database management
Related Q&A from Kent Milligan
To solve the SQL error -321 on IBM i6.1, use the new values statement to overcome the error. If you are using an older release, declare a cursor ... Continue Reading
When working with DB2 files with columns that have both short and long names, there is no option choose which column names are returned via ODBC ... Continue Reading
When developing tables in a parent-child relationship, use a primary key and a foreign key along with a unique ID to make your database easier to ... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.