Solved

Access multi membered file from Java

Posted on 2012-03-14
8
539 Views
Last Modified: 2012-03-21
Hi,

I am working on a file modification project which involves craeting a UI for a business team such that they are able to access the latest version of a multi membered physical file on the AS400. The UI is being written in JAVA. I am not too familiar with this and my involvement in the project is to help facilitate the backend needs.

Is there a way in Java that can help use a specific version (or the last version) of a multi membered file? We have used single membered PF's as SQL tables from the java code. We are trying to figure out how to do the same when there are more than 1 version.

Thanks
Ali
0
Comment
Question by:bhagatali
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 7

Accepted Solution

by:
gudii9 earned 300 total points
ID: 37720603
Here is interesting explanation, link
You can do this by creating an SQL Alias. Suppose that you have a physical file MYLIB/SALES with twelve members (one member for each month of the year). To access JANUARY, you must first create an alias with the following SQL command:

CREATE ALIAS MYLIB/SALES_JANUARY FOR MYLIB/SALES(JANUARY)

http://as400samplecode.blogspot.com/2011/09/java-access-multiple-member-physical.html
0
 
LVL 16

Assisted Solution

by:theo kouwenhoven
theo kouwenhoven earned 200 total points
ID: 37720635
Hi ALi,

You can make an Alias for a member:

CREATE ALIAS MyLib/MyAlias FOR MyLib/MyFile (Member1)

Use that alias in the rest of your SQL;

SELECT * FROM MyLib/MyAlias

If possibel, create the alias in QTEMP, so that not remain on disk  :-)

Successs
0
 
LVL 18

Expert Comment

by:daveslash
ID: 37720704
As the previous two posts point out, creating the alias in QTEMP is the best way to go. But, in case you need an alternative, you can also issue a CL command to override to the target member before running your SQL.

e.g.
OVRDBF FILE(MyTable) TOFILE(ACALIB/MyTable) MBR(TargetMbr)

HTH,
DaveSlash
0
 

Author Comment

by:bhagatali
ID: 37720843
@Dave: I initially was thinking of the OVRDBF command too but I am not certain of will the override remain when I execute the SQL query on that file. We know how an override on AS400 remains for the duration of a job. From Java, with all the connections and AS400 object class that have to be created I was curious if the override would still be in effect.

@murphy and @gudii: thanks for the alias and QTEMP suggestions.
Regards
Ali
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:daveslash
ID: 37720877
The OVRDBF has always worked from me through ODBC and JDBC, but I still think the CREATE ALIAS in QTEMP is a better solution.
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 37721645
Sorry gudii9,

I think you posted the solution while I was still typing it.

:-)
0
 
LVL 27

Expert Comment

by:tliotta
ID: 37745651
In general, an ALIAS can be preferred when a permanent object may be shared among users or across sessions (or across jobs). An OVRDBF can be preferred when it is known to be needed strictly local to the process.

CREATE ALIAS creates a permanent object. Technically, it's implemented as a DDM file. As such, all of the overhead of object creation (and perhaps deletion if not actually permanent) gets brought in. This includes setting ownership and authority attributes. Those attributes may cascade into changes to related objects such as the owning profile.

An OVRDBF simply puts some changes into any ODP in that job. No significant overhead.

Either one can work well. There's no real way to say one is better. It always depends on the environments in which they're used.

Tom
0
 

Author Comment

by:bhagatali
ID: 37747158
Thanks Tom for the added explanation.

Regards
Ali.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now