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



Thanks for the clarification. I swear I tried fieldScale and got zeros...
I ended up using the QYS2/SYSCOLUMNS file but that's easy enough to change
once I verify it's working ok.

Brad
www.bvstools.com

On Thu, Jul 14, 2016 at 11:01 AM, Kevin Adler <kadler@xxxxxxxxxx> wrote:

"OpenSource" <opensource-bounces@xxxxxxxxxxxx> wrote on 07/07/2016
11:06:33 AM:

From: Bradley Stone <bvstone@xxxxxxxxx>
To: IBMi Open Source Roundtable <OpenSource@xxxxxxxxxxxx>
Date: 07/07/2016 11:06 AM
Subject: [IBMiOSS] Field Length using node.js
Sent by: "OpenSource" <opensource-bounces@xxxxxxxxxxxx>

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:
<snip>
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

<snip>

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

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

The Node.js developer confirmed my suspicion that fieldWidth is returning
the length of the column name (plus a null terminator). It really returns
the *actual* length of the column name in case of truncation. I question
why this might be useful to a Node.js developer, since I would have
suspected that the node db adapter would never truncate the column name.


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?

He did give me some hints about what you're looking for, though:

"The column information APIs of the Node.js adapter includes --

fieldType
fieldWidth
fieldName
fieldPrecise
fieldScale
fieldNullable

So I believe that it provides enough information to users."

fieldPrecise will return the precision (total column width) and fieldScale
(digits after the decimal) will return the scale.

So for the table in question,
ITITEM should return scale = 15, precision = 0
ITIDESC should return scale = 30, precision = 0
ITPRICE should return scale = 9, precision = 2
ITQTY should return scale = 9, precision = 0

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

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.