Results 1 to 5 of 5

Thread: Data Conversion from Char to Numeric in WRKQRY

  1. #1
    Code400 Newbie
    Join Date
    Jul 2007
    Location
    USA
    Posts
    33
    Rep Power
    554

    Data Conversion from Char to Numeric in WRKQRY

    hello,

    In AS/400 query how do you change an alpha field into a numeric to do math on it?



    Example: VARIABLE is defined as an alpha field 4 characters long and has the value “1234” in it.

    I want to add VARIABLE and the field SCORE together to get a sum, what command do I use in query to redefine VARIABLE

    as a numeric field?


    regards,
    Anil.

  2. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

  3. #2
    Analyst MdnghtPgmr's Avatar
    Join Date
    Oct 2005
    Location
    Topeka, KS
    Age
    55
    Posts
    517
    Rep Power
    2212

    Re: Data Conversion from Char to Numeric in WRKQRY

    medam.anil,

    I believe DIGITS(NumericField) will do the trick.

    HTH,
    MdnghtPgmr

  4. #3
    Code400 Newbie
    Join Date
    Jul 2007
    Location
    USA
    Posts
    33
    Rep Power
    554

    Re: Data Conversion from Char to Numeric in WRKQRY

    I believe this will convert Numeric to Character, but not Vice-versa.

    Anil.

  5. #4
    Analyst GLS400's Avatar
    Join Date
    May 2006
    Location
    connecticut
    Posts
    1,891
    Rep Power
    5780

    Re: Data Conversion from Char to Numeric in WRKQRY

    Hi medam.anil:

    There is only a limited way of converting alpha to numeric within query/400. This involves convrting the alpha field to the microsecond portion of a time stamp.

    http://www.itjungle.com/mgo/mgo020503-story02.html

    Because it is so convoluted and down outright bizzar I avoid it as much as is humanly possible.

    Use another high level language or create some dds in qtemp and copy the file with nocheck is what I would recomend.

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

  6. #5
    Code400 Newbie
    Join Date
    Jul 2007
    Location
    USA
    Posts
    33
    Rep Power
    554

    Re: Data Conversion from Char to Numeric in WRKQRY

    Thanks for this info.

  7. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

Facebook Comments


Similar Threads

  1. Add-in for Excel to pull data from AS400
    By jamief in forum Tips for the Iseries/AS400
    Replies: 2
    Last Post: February 3rd, 2012, 09:59 AM
  2. Replies: 0
    Last Post: May 24th, 2006, 03:39 PM
  3. Replies: 8
    Last Post: June 17th, 2005, 02:44 PM
  4. rpgle
    By mohans in forum RPG/RPGLE
    Replies: 4
    Last Post: May 21st, 2005, 11:50 PM
  5. Replies: 6
    Last Post: October 1st, 2004, 08:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •