Packed numeric data (contained inside an alpha-numeric field) retrieval problem from an externally described table on the AS/400
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kevin_Boutin
Posted On:   Wednesday, March 28, 2001 05:58 PM

I know to use BigDecimal to retrieve packed numeric data from a ResultSet; however, this is a bit more complex. I have a table on the AS/400 that is externally described but contains a large alpha-numeric field that consists of several sub-fields of varying data types (i.e. alpha, packed numeric, etc.). When retrieving data from the ResultSet, after executing a query on the table mentioned above, I am forced to use the getString method to retrieve the large alpha-numeric field. After retrieving the data into a String, I need to parse the sub-field data into the correct data types (including packed numeric). This is where my problem lies. I cannot retrieve a BigDecimal (or even a BigInteger) from the String ret   More>>

I know to use BigDecimal to retrieve packed numeric data from a ResultSet; however, this is a bit more complex.


I have a table on the AS/400 that is externally described but contains a large alpha-numeric field that consists of several sub-fields of varying data types (i.e. alpha, packed numeric, etc.).


When retrieving data from the ResultSet, after executing a query on the table mentioned above, I am forced to use the getString method to retrieve the large alpha-numeric field.


After retrieving the data into a String, I need to parse the sub-field data into the correct data types (including packed numeric). This is where my problem lies. I cannot retrieve a BigDecimal (or even a BigInteger) from the String retrieved using the getString method mentioned above.


What do I need to do? I am stumped and I need an answer as quickly as possible. Any and all help is greatly appreciated.

   <<Less

Re: Packed numeric data (contained inside an alpha-numeric field) retrieval problem from an externally described table on the AS/400

Posted By:   Iulian_State  
Posted On:   Monday, June 25, 2001 10:27 AM

Ex:


String field = rs.getString("MYFIELD");
AS400Text conv = new AS400Text(3);
AS400PackedDecimal number = new AS400PackedDecimal(4, 0);
String subfield = field.substring(0,3);
BigDecimal value = new BigDecimal(number.toObject(conv.toBytes(subfield)).toString());


Attn:

If you are using the Toolbox driver your string will end prematurely if by chance you have 0x6F byte (EBCDIC) (" in ASCII) in your field. I recommend to use getBytes() method instead.


Iulian

About | Sitemap | Contact