I work with interactive SQL on the iSeries. Is it possible to query multi-member files, specifying which member you would like to query? I assume the query will run against the first member in the file if it is not told otherwise. Is it possible to query the second or third members, etc? If so, what is the syntax for doing so?
Yes, the easiest way to do that is with SQL Alias. You have a one-time setup step of creating an alias for each member you're interested in accessing. Once the alias is created, it can be referenced on just about any SQL statement.
CREATE ALIAS lib1/al_mbr1 FOR lib1/file1 (mbr1)
CREATE ALIAS lib1/al_mbr2 FOR lib1/file1 (mbr2)
SELECT * FROM al_mbr1 UNION ALL SELECT * FROM al_mbr2
MORE INFORMATION ON THIS TOPIC
Search400.com's targeted search engine: Get relevant information on DB2/400.
The Best Web Links: tips, tutorials and more.
Check out this Search400.com Featured Topic: Database issues resolved
Dig Deeper on DB2 UDB (universal databases)
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.