ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to avod Special characters in WRKQRY

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to avod Special characters in WRKQRY

    I have to take a outfile using WRKQRY. but in the parent file there are some special characters in data.
    Which need to convert into Packed decimal format. Is there any way to convert the character to Packed decimal format using WRKQRY?
    Thanks
    Venkat

  • #2
    Re: How to avod Special characters in WRKQRY

    There are a couple possibilities. But it's very difficult to show examples without seeing representative samples of the various inputs along with descriptions of what your expected outputs should be.

    Can you give some more details?
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment


    • #3
      Re: How to avod Special characters in WRKQRY

      Looking at your question it looks like you are trying to convert packed decimal numbers in a character field TO a packed decimal field. If this is indeed the case, I do not think this is possible using WRKQRY. However we did do this for a generic trigger program which used _LBCPYNV MI.

      I would go for an embedded SQL RPG program in this case to create your output file. Perhaps create a UDF which maps to your conversion program and use it within the SQL statements to create your out file.

      Comment


      • #4
        Re: How to avod Special characters in WRKQRY

        There is a technical possibility of converting a SUBSTR() to a HEX() value and manipulating the hex digits through some messy time functions, eventually getting numeric values out. But it's ugly and hardly worth it. It'd be interesting to see enough examples of the input to get an idea why anyone would need to do this (and why they'd want to; the old query product is not the right tool for this -- not that any "tool" really should be).
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment


        • #5
          Re: How to avod Special characters in WRKQRY

          @Tom
          In our case, we wanted to audit the file changes done by users for a set of standing data files. Instead of writing specific routines to audit each file, we came up with a generic trigger program which would create the audit log entries based on the information in the trigger buffer. In this case, packed decimal data had to convert to readable form to put in the audit logs. Since the trigger program could be attached to any file it had to process the buffer based on the file structure dynamically. This is where I found this conversion useful.

          I am guessing the OP is trying something similar OR is trying to analyse data which is in this format.

          Comment


          • #6
            Re: How to avod Special characters in WRKQRY

            I've seen cases where S/36-type files have multiple program-described formats. Packed values would appear at different offsets in different formats, and Query/400 was expected to handle it.

            In RPG, it's fairly easy just to read over various based DSs that fit whatever format is needed. But a 'Query' is messy.
            Tom

            There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

            Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

            Comment


            • #7
              Re: How to avod Special characters in WRKQRY

              I agree with using RPG. Just because your spec calls for manipulating wrkqry should not mean you are tied to it. Just convey it back to them in the friendliest manner, or just do it and neglect to tell them.
              Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

              Comment


              • #8
                Re: How to avod Special characters in WRKQRY

                Oh, and i would never ever use wrkqry in a production solution. did i say never ever...
                Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                Comment

                Working...
                X