× 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.



Don’t have an answer to your question as such Brad - but wouldn’t querying sys columns make more sense?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jul 7, 2016, at 12:06 PM, Bradley Stone <bvstone@xxxxxxxxx> wrote:

I'm trying to retrieve the field length of the fields in a table that I am
working with.

The main reason I want the length is so when I create a dynamic input field
for it, I can set the maxlength property for it.

Here's the file in question:

File Name . . . . ITEMPF
Library . . . . BVSTONES
Format Descr . . ITEM MASTER
Format Name . . . RITEM
File Type . . . . PF Unique Keys - N

Field Name FMT Start Lngth Dec Key Field Description
ITITEM A 1 15 K01
ITIDESC A 16 30
ITPRICE P 46 9 02
ITQTY P 51 9 00

Here's some code I'm using and using the db.fieldWidth property (which I
assume should return the field length/size):

var sql = "select * from %s.%s limit 1";
sql = util.format(sql, 'BVSTONES', 'ITEMPF');

db.init();
db.conn(DBname);
db.exec(sql, function(rs) {
var rc = db.numFields();

for (var i=0; i < rc; i++) {
var newKey = db.fieldName(i);
var newValue = db.fieldWidth(i);
lengthRs[newKey] = newValue;
console.log(newKey + '=' + newValue);
}

Here's what it's reporting for the lengths:

ITITEM=7
ITIDESC=8
ITPRICE=8
ITQTY=6

Now, those lengths I would have thought would be the length of the fields,
or the length of the data (not sure what that would help with, though).
Here's the data:

ITITEM ITIDESC ITPRICE ITQTY
BLUECAR Light Blue Car 1,000.00 1

I get that for packed fields I'll probably need to do a little manipulation
with the numbers, but the description and item number, which are character,
don't look right at all.

Any ideas?
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/opensource.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.