ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Wrong Var value - SQLRPGLE

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

  • Wrong Var value - SQLRPGLE

    Hello all,

    This is my first post, so i hope to do it correctly.

    I have executed this command, to obtain the atributes o my PRTF's
    PHP Code:
    DSPFD      FILE(*ALL/*ALL) TYPE(*ATR) OUTPUT(*OUTFILE) +
                 FILEATR(*PRTF) OUTFILE(MDTOS/DSPFDATRF) +  
                 OUTMBR(DSPFDATRF *REPLACE) 
    And i have a SQLRPGLE that reads the file with this sentence:
    Code:
     ***                                                                  
    C/EXEC SQL                                                            
    C+          SELECT PRFSZL, PRFSZW, PRLPI, PRCPI, PROVRF, PRPGRT       
    C+          INTO :WPAGL, :WPAGA, :WLPI, :WCPI, :WOVRF :WPGRT0         
    C+          FROM DSPFDATRF                                            
    C+          WHERE PRFILE = :WPRMBRO2 AND PRLIB = :PRLIBR              
    C/END-EXEC                                                            
     ***
    The program variable WPGRT0 is deffined like this:
    PHP Code:
     D WPGRT0          S              2B 0 
    When i run the SQL statment interactive (STRSQL) , the colum contains different values (-2, 360, etc)

    But running the SQLRPGLE, the var WPGRT0 everytimes contains 0 (the rest of the vars contains correct values, only WPGRT0 is wrong)

    I have tryed with this definition:
    PHP Code:
     D WPGRT0          S              5I 0 
    But the variable alwais contains 0

    i have a iSeries V5.3

    Thanks in Advance for your help.

  • #2
    Re: Wrong Var value - SQLRPGLE

    what is the SQL state & SQLCOD after the statement runs in your program? also did you look at the job log to see if any errors (data truncation, etc.) occurred?
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Wrong Var value - SQLRPGLE

      Why do you want to define this host variable as binary or integer? It is defined as DEC(3, 0)!

      ... but anyway you missed a comma before :WPGRT0 in this way this variable is handled as being an indicator variable (to check NULL values) for host variable WOVRF.

      Didn't you get any SQLCODE <> *Zeros and <> 100 or SQLSTATE whose first 2 characters are neither '00' nor '02'?

      Birgitta

      Comment


      • #4
        Re: Wrong Var value - SQLRPGLE

        Yes, the missed comma was the problem !!!

        I also changed the definition on the var to: D WPGRT0 S 5I 0

        And now the program works, good.

        Thanks a lot for your really fast help.

        Best regards,

        Comment


        • #5
          Re: Wrong Var value - SQLRPGLE

          I also changed the definition on the var to: D WPGRT0 S 5I 0
          Why do you want to use a different data type for your output field?
          Conversion between packed (Decimal) and Small Integer (5I 0) must be performed, which (minimally) descreases performance.

          Birgitta

          Comment


          • #6
            Re: Wrong Var value - SQLRPGLE

            if i use a binary definition (2B 0) the probram fails with a error about the size of the var
            Now i have changed de definion to 3B 0, and seems to work fine.

            Thanks again for your help.

            Comment


            • #7
              Re: Wrong Var value - SQLRPGLE

              icky...use "i" data type not "B" data type...
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: Wrong Var value - SQLRPGLE

                Originally posted by krymen View Post
                if i use a binary definition (2B 0) the probram fails with a error about the size of the var
                Now i have changed de definion to 3B 0, and seems to work fine.

                Thanks again for your help.
                Why binary or integer data type?????
                If you want to define a decimal or packed field the proper RPG data type is P (= Packed!!!)

                BTW a 3I 0 integer field has a valid range between -128 and +127.
                For a 3P 0 field the valid range is -999 to +999.
                Page rotation with more than 128 degrees and 3I 0 output field will cause an error!

                Birgitta
                Last edited by B.Hauser; October 31, 2011, 09:41 AM.

                Comment


                • #9
                  Re: Wrong Var value - SQLRPGLE

                  I have changed the code an now the variable is defined as Packed, and the program works fine.

                  My confusion comes from a example from IBM:

                  They use binary and packed definitions for smallint SQL columns.

                  But seems that Packet is the correct type ;-)

                  Thanks a lot for your help

                  Comment


                  • #10
                    Re: Wrong Var value - SQLRPGLE

                    This was an RPGIII example and in RPGIII integer data types were not implemented, only binary, packed (and zoned) numeric data types.
                    Unfortunately the RPGIV example is not better. The RPGIII code was simply converted into RPGIV without profiting from the RPGIV enhancements.

                    ... in either way:
                    RPG Packed - P = Decimal or Dec in SQL
                    RPG Zoned - S = Numeric in SQL
                    RPG Integer - 5I 0 = Small Integer in SQL
                    RPG Integer - 10I 0 = Integer or Int in SQL
                    RPG Integer - 20I 0 = BigInt in SQL
                    RPG Float - 4F = Float in SQL
                    RPG Float - 8F = Double in SQL

                    Birgitta

                    Birgitta

                    Comment

                    Working...
                    X