1

Irrespective of whether the table has duplicate records, primary key whatever I wanted to uniquely identify each row in As400. In Oracle there is rowid concept , there irrespective of whether the table has duplicate records or whatever there is unique rowid to each rows ,so I can fetch only that particular record using rowid. is there such kind of thing present in AS400?

I did some search related to row number in db2 AS400, but thats not meet the above requirement.

Pavan G
  • 99
  • 6
  • 2
    Why do you think, that the RRN function doesn't meet your requirement? – Mark Barinstein Nov 29 '22 at 06:22
  • I tried in this db2 editor https://dbfiddle.uk/Q9pQuWw5 , but I am getting error while using rrn function. Can you help me out in this.. - @MarkBarinstein – Pavan G Nov 30 '22 at 06:58
  • You must know, that Db2 for IBM i (iSeries, OS/400) is different product from Db2 for Linux, Unix and Windows which is used at the link you provided. There is really no [RRN](https://www.ibm.com/docs/en/i/7.5?topic=functions-rrn) function in Db2 for LUW, but it does exist in Db2 for IBM i. – Mark Barinstein Nov 30 '22 at 08:17
  • @PavanRaga Please don't just say "there's an error", this doesn't help in diagnosing. Give us an example of what exactly you do and the exact error message you're getting. – PoC Nov 30 '22 at 11:09
  • tnx for the info . RRN value can be change ryt? when reorg operation or deletion operation has done? - @MarkBarinstein – Pavan G Dec 01 '22 at 07:31
  • After reorg - yes in all cases. After delete the same value returned by RRN may be "occupied" by another row inserted after such a delete depending on the table property mentioned in the answer below. – Mark Barinstein Dec 01 '22 at 13:44
  • Does this answer your question? [Unique identifier for AS400 Database if there is no primary key / unique key / composite key defined?](https://stackoverflow.com/questions/74599271/unique-identifier-for-as400-database-if-there-is-no-primary-key-unique-key-c) – John Y Jan 12 '23 at 01:40

1 Answers1

1

No. DB2 on OS/400 allows unique identification of a given record at a given point in time only by RRN. (Unless your database definition used unique primary key, that is.)

As pointed out in answers to your former request, the RRN is to be considered temporary! An RRN is always referring to an unique record, but a record's RRN can change:

  • when you reorganize a PF (table) through rgzpfm,
  • when you delete records,
  • when you add records, and REUSEDLT(*YES) is in effect — which is the default.

Thus it's important to realize the temporary nature of RRN to record association.

PoC
  • 521
  • 3
  • 13
  • @PavanRaga Also, why do you start yet another question when your original question is still not marked as solved? Please don't spam Stackoverflow. – PoC Nov 30 '22 at 11:13