ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Read without setting the pointer

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

  • Read without setting the pointer

    Hi All,

    I am reading the database file without positioning the pointer. Is it correct one where I am reading the database without using SETLL. The file is having key field.I need to read all the records from database. So without using setll I can directly use Read??

    Please advise.

    Rgds,
    Sudha.
    The Secret Of Achieving Your Goals Is Revealed Before Your Eyes.
    System Engineer

    Sudha...

  • #2
    Re: Read without setting the pointer

    Originally posted by sudha
    Hi All,

    I am reading the database file without positioning the pointer. Is it correct one where I am reading the database without using SETLL. The file is having key field.I need to read all the records from database. So without using setll I can directly use Read??

    Please advise.

    Rgds,
    Sudha.
    Yes you can, and it may or may not work. I'm not sure why you want to avoide using a setll.

    If you want the program to work every time, consistently and depandably, then you need to perform a setll. Without using a setll, a read operation begins from the current file pointer. If the current file pointer is at the begining of the file, then it would work. But if the file pointer is not at the begining of the file, it would only pick up the records from where the file pointer was to the end of the file. Without using a setll, a simple modification to the program (such as returning with *Inlr off) woul keep the program from working correctly after the first call.

    Simply setll using *loval on the file, and all will be good with the world.
    Michael Catalani
    IS Director, eCommerce & Web Development
    Acceptance Insurance Corporation
    www.AcceptanceInsurance.com
    www.ProvatoSys.com

    Comment


    • #3
      Re: Read without setting the pointer

      To me using setll is like if %found()
      I just use it all the time




      PHP Code:
      ==> positions the pointer to the record Equal to or Greater than Factor 1
      ==> *LOVAL repositions at the start of a keyed file
      ==> *START repositions at the start of a non-keyed file 
      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: Read without setting the pointer

        FWIW i would use *START on the setll rather than *LOVAL...
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: Read without setting the pointer

          I'm confused. The original post says they need to read all records. I would assume this is why they can't use setll. What is it exactly that is required? Maybe you want to do a read(n) so you read through the file without locking any records?
          Ben

          Comment


          • #6
            Re: Read without setting the pointer

            Originally posted by BenThurley View Post
            I'm confused. The original post says they need to read all records. I would assume this is why they can't use setll. What is it exactly that is required? Maybe you want to do a read(n) so you read through the file without locking any records?
            Setll should have nothing to do with locking records. It sounds to me like the original poster did not understand exactly what setll was for and therefore did not want to use it. Personally, I would always use the setll with the *start option.

            Comment


            • #7
              Re: Read without setting the pointer

              Yes but you can't read all the records with setll can you? I think we need to know more about the actual problem.
              Ben

              Comment


              • #8
                Re: Read without setting the pointer

                Originally posted by tomholden View Post
                FWIW i would use *START on the setll rather than *LOVAL...
                Yea, *Start is better. Old habit, and I havent really ever had enough programs to write that needs to read a file from the start of the file in order to break it.
                Michael Catalani
                IS Director, eCommerce & Web Development
                Acceptance Insurance Corporation
                www.AcceptanceInsurance.com
                www.ProvatoSys.com

                Comment

                Working...
                X