Q
Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Working with interactive SQL

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)

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close