× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On 08/02/2008, at 2:57 AM, DenisP@xxxxxxxxx wrote:

But nevertheless the information is there on the file.

Whether or not it exists on the file is immaterial. The AS400FileRecordDescription.retrieveRecordFormat() method does not retrieve that information. This is just another example of stupid design in the Java Toolbox (and therefore JTOpen). It's not quite as stupid as having the commit(), rollback(), startCommitmentControl(), endCommitmentControl(), and isCommitmentControlStarted() methods as members of the AS400File object but is very close.

The various getATTRIBUTE methods (e.g., getCOLHDG(), getTEXT(), etc.) only return what is already contained in the RecordFormat object. It appears the only way to set these attributes is by the various setATRIBUTE methods (e.g., setCOLHDG(), setTEXT(), etc.). Because this information is not set by the retrieveRecordFormat() method it is not available to return hence the empty string.

What you have done is what any REASONABLE person would presume. Namely that retrieveRecordFormat() would give back ALL format level information and not just the minimum necessary to describe a record layout (i.e., name, type, length). Because the fieldDescription object supports getTEXT() and getCOLHDG() etc. and the only way to get a list of fieldDescription objects is via the RecordFormat object it seems reasonable that RecordFormat should provide a method to populate all field information from existing host data.

I can accept that it may work this way for performance reasons but there should be another method that does allow the caller to extract ALL the descriptive information. I wondered if the KeyedFile.setRecordFormat() method might behave differently but no such luck:

KeyedFile keyedFile = new KeyedFile(system, PATH);
keyedFile.setRecordFormat();
RecordFormat format = keyedFile.getRecordFormat();
FieldDescription[] fieldDescriptions = format.getFieldDescriptions();
for (int i = 0; i < fieldDescriptions.length; i++ )
{
FieldDescription fieldDescription = fieldDescriptions[i];
System.out.println("Field '" + fieldDescription.getFieldName() + "' = Text '" +
fieldDescription.getTEXT() + "'");
}

results in the same output as your original example. Note the hidden side effect of setRecordFormat--it retrieves the format information from the host.

It seems the setATTRIBUTE methods are intended to be used only when creating a file from Java. The getATTRIBUTE methods exist purely to test what was set previously. I consider this an incomplete implementation. If there is a way to retrieve this information without resorting to JDBC or direct API calls then I'd like to know it.

When you use the command line sql client to select rows from a table it shows the correct
column headings from the file description.

Because it is using the SQL meta-data to extract the column headings.

So ... I guess the question is
how do you get at that information via JTOpen if
AS400FileRecordDescription doesn't retrieve it. Is there a way to
retrieve the "entire record format" including column headings?

You could use JDBC and interrogate the meta-data made available through that interface.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.