ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Retrieving the Value in a Flat file through SQL Query

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

  • Retrieving the Value in a Flat file through SQL Query

    A record was written into a flat file through a COBOL Program.
    The record consists of S9(8)V99 COMP-3 data type.
    The flat file is having the data in five positions.

    How can we retrieve the correct value stored in the flat file using SQL Query.

  • #2
    Re: Retrieving the Value in a Flat file through SQL Query

    What do you mean by "correct value" ? Pls clarify.
    Philippe

    Comment


    • #3
      Re: Retrieving the Value in a Flat file through SQL Query

      Originally posted by Mercury View Post
      What do you mean by "correct value" ? Pls clarify.
      If we have written -132.50 through the COBOL program.
      I am expecting to see the same from SQL Query.

      Comment


      • #4
        Re: Retrieving the Value in a Flat file through SQL Query

        I don't see any issue here. Just use SQL as below

        Code:
        Select * from MyFile
        and you're done.
        Last edited by Mercury; March 22, 2010, 10:07 AM.
        Philippe

        Comment


        • #5
          Re: Retrieving the Value in a Flat file through SQL Query

          Originally posted by Mercury View Post
          I don't see any issue here. Just use SQL as below

          Code:
          Select * from MyFile
          and you're done.
          Murcury I guess concern is that whether it will write -ve values at that position or not??

          he may want to write sign as well
          Young people knows how to run fast but old people knows the way..

          Comment


          • #6
            Re: Retrieving the Value in a Flat file through SQL Query

            When we write COMP-3 data into a flat file, it will not show the same data when we use the DSPPFM or RUNQRY.
            So we have to convert this to retrieve the original value from the Flat file.

            Comment


            • #7
              Re: Retrieving the Value in a Flat file through SQL Query

              IIRC COMP-3 is decimal condensed or packed field. So if you want to transfer a file to an ASCII platform, declare a new field as PIC S9(8)V99 alone without COMP-3 ( ie decimal extended ) instead of decimal condensed.
              PHP Code:
               01   FLD1 PIC S9(8)V99 COMP-3.
               01   FLD2 PIC S9
              (8)V99.
              Convert from condensed or packed value to extended value
                     MOVE FLD1 TO FLD2

              Philippe

              Comment


              • #8
                Re: Retrieving the Value in a Flat file through SQL Query

                Originally posted by Mercury View Post
                IIRC COMP-3 is decimal condensed or packed field. So if you want to transfer a file to an ASCII platform, declare a new field as PIC S9(8)V99 alone without COMP-3 ( ie decimal extended ) instead of decimal condensed.
                PHP Code:
                 01   FLD1 PIC S9(8)V99 COMP-3.
                 01   FLD2 PIC S9
                (8)V99.
                Convert from condensed or packed value to extended value
                       MOVE FLD1 TO FLD2

                Is there a way that we can see the value from SQL Query.

                Comment

                Working...
                X