ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Fetch RRN(file)Field with all other fields

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

  • Fetch RRN(file)Field with all other fields

    Hey All !

    Can i fetch the RRN(file)-information from the record with all other fields of the database-record ?

    F.ex.
    select *, rrn(file) from file where a = :fielda


    I've test it on command-line-sql, but i't didn't work !

    Thanks !

    Peet
    Once there was a river, now there's a Stone !

  • #2
    Re: Fetch RRN(file)Field with all other fields

    The rrn(file) is OK. Its the * that doesn't like other fields on the same line.

    Comment


    • #3
      Re: Fetch RRN(file)Field with all other fields

      so just select the fields by name

      PHP Code:
      SELECT rrn(a) as recordNumber AASL#, AASLNM FROM aracust A ORDER  
      BY recordnumber 
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: Fetch RRN(file)Field with all other fields

        Hi,

        How about this:

        PHP Code:
        Select MyFile.*, rrn(MyFile
            
        from MyFile 
        or

        PHP Code:
        Select rrn(a), a.*
           
        from MyFile a 
        Birgitta

        Comment


        • #5
          Re: Fetch RRN(file)Field with all other fields

          Birgitta - Thanks once again!
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: Fetch RRN(file)Field with all other fields

            Thats nice!!
            Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

            Comment


            • #7
              Re: Fetch RRN(file)Field with all other fields

              Birgitta,
              I may be wrong but I believe that your examples in your last post don't work on a FETCH stm, i.e. you can't retrieve all together the RRN and all the fields using * on the same SELECT stm.
              Last edited by Mercury; September 25, 2007, 09:18 AM.
              Philippe

              Comment


              • #8
                Re: Fetch RRN(file)Field with all other fields

                Hi,

                it will work on a Fetch or Select ... into Statement, but you need two fields or a field (for the relative record no) and a data structure to receive the whole record.

                PHP Code:
                D EDSMyFile     E DS                  ExtName(MyFile)  
                D RRNMyFile       S             10I 0

                C
                /EXEC SQL
                C
                +   Select RRN(a), a.*
                C+      into :RRNMyFile, :EDSMyFile 
                C
                +      From MyFile a ....
                C/End-Exec

                C
                /EXEC SQL
                C
                Fetch Next From MyCursor into :RRNMyFile, :EDSMyFile
                C
                /End-Exec 
                Birgitta
                Last edited by B.Hauser; September 25, 2007, 09:28 AM.

                Comment


                • #9
                  Re: Fetch RRN(file)Field with all other fields

                  Yes it does work... My bad. I can't remember why I had the feeling it was not working. Thanks Brigitte.
                  Last edited by Mercury; September 26, 2007, 03:49 AM.
                  Philippe

                  Comment


                  • #10
                    Re: Fetch RRN(file)Field with all other fields

                    Perfekt, Birgitta, Danke schön !!
                    (perfect, birgitta, thank you !)



                    Originally posted by B.Hauser View Post
                    Hi,

                    it will work on a Fetch or Select ... into Statement, but you need two fields or a field (for the relative record no) and a data structure to receive the whole record.

                    PHP Code:
                    D EDSMyFile     E DS                  ExtName(MyFile)  
                    D RRNMyFile       S             10I 0

                    C
                    /EXEC SQL
                    C
                    +   Select RRN(a), a.*
                    C+      into :RRNMyFile, :EDSMyFile 
                    C
                    +      From MyFile a ....
                    C/End-Exec

                    C
                    /EXEC SQL
                    C
                    Fetch Next From MyCursor into :RRNMyFile, :EDSMyFile
                    C
                    /End-Exec 
                    Birgitta
                    Once there was a river, now there's a Stone !

                    Comment


                    • #11
                      Re: Fetch RRN(file)Field with all other fields

                      Thanks Birgitta - another great example bookmarked ....
                      Greg Craill: "Life's hard - Get a helmet !!"

                      Comment

                      Working...
                      X