Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL query of multi-member file on AS400

On AS400 in interactive SQL in a 5250 session,

select * from myfile

returns rows from one member only when myfile has more than one member.

How can I get rows from a specific member?

Important: in the end I'd like to do this over JDBC with jt400 so really I want a solution that'll work there.

Thanks.

like image 907
tmtest Avatar asked Dec 06 '08 17:12

tmtest


People also ask

What is multi member file in as400?

A multimember physical file is having more than one member associated with it. Normally when we create the Physical file using CRTPF command a default member with the same name as PF gets added to the physical file so that's called the single-member physical file.


2 Answers

You can create an alias using the create alias command:

CREATE ALIAS myLibrary/myAlias FOR memberLibrary/memberFile(memberName)

This will allow you to run sql against that member using the alias like you would any other file:

SELECT * FROM myLibrary/myAlias

Just remember that the alias will stick around after your session, they are not temporary. So if you wont need the alias when you are done, either create the alias in QTEMP or explicitly drop the alias once you are done with it:

DROP ALIAS myLibrary/myAlias

HTH

like image 125
Ryan Guill Avatar answered Oct 02 '22 08:10

Ryan Guill


Create an SQL alias for the member and query the alias, see this page for an example.

like image 20
Kwebble Avatar answered Oct 02 '22 10:10

Kwebble