ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

The number of records in the view

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

  • The number of records in the view

    Hello everybody!
    Using the SQL command on the physical data file, a view was created that selects records under certain conditions. Further, through the QUSRMBRD API, information about the (single) member was retrieved. Among the extracted information is information about the number of records. By condition, view selects 1 entry, but there are 6 entries in the information about the number of entries (total number of entries in the physical file). Why it happens? How to fix it?

    Postscript: Perhaps this question should have been asked not in this forum thread ...

  • #2
    The are any number of possibilities that might cause this. The counts for this API appears to be for all members - so are you sure there is only one member? What about deleted records? Are they included in the count? If you write a simple RPG program that loops through the file what does it see (I'll lay odds it is 1 record).

    Also _why_ are you checking it via this API? Have you reason to think the SQL is not correct? It just seems a rather strange thing to be doing. Have you considered using the Systables etc?

    Comment


    • #3
      As an experiment, I created a table through SQL, added records to it, created a view, and then started using QUSRMBRD. So there is exactly one member there, there are no deleted entries, a simple program in RPG or C when working with a view gives, as expected, one entry.
      I have no reason to think that SQL is incorrect. Moreover, I am sure that SQL gives the correct result. I don’t understand why this seems like a strange thing to you. There is an API that retrieves member information. Why not use this one tool instead of a bunch of others?
      Member information I do not need in any particular case. I am creating a class library for IBM i in C ++. This library will have a DataFile class containing instances of the DataFileMember class. The latter should have a method through which it would be possible to find out the number of records.

      Comment


      • #4
        No idea then I'm afraid.

        It struck me as odd because most people these days use the various SQL views obtain this kind of information rather than the old, and often difficult to use, API approach.

        I'm actually surprised that there aren't IBM supplied classes for this kind of stuff - but then C++ is not my thing.

        Comment


        • #5
          Using the API, it seems to me, allows you to get some information that is not available when using SQL ...
          Well, for example, the number of deleted records in the file.

          Comment


          • #6
            You can get pretty much everything though the SysTables and new tools from the Db2 team. Deleted records has been available for a long time. See https://www.rpgpgm.com/2015/12/almos...know.html#more

            Comment

            Working...
            X