简体   繁体   中英

DB2 - Iseries (AS/400) DDS to DDL (FIFO, LIFO)

In our IBM iSeries v7r4 - DB2, we need to convert a DDS file to a DDL-SQL .

It doesn't matter if it's a view or an index or anything if we can convert the clause "FIFO" to DDL.

The Logical file (LF) that we need to convert has this DDS description:

A                FIFO
A R AHMVTF       PFILE(AHMVTP)
A                FORMAT(AHMVTP)
A K HM$092
A K HMA098

So, does anyone know if there are any option or alternative to create an Index/view using the clause FIFO, LIFO, etc. onto SQL?

Best regards,

There is not an SQL keyword or clause that guarantees FIFO retrieval. You might be able to use RRN() in the order by clause, but this will depend on the reuse deleted records keyword REUSEDLT(*NO) .

Be aware that DDS defaults REUSEDLT(*NO), but DDL defaults REUSEDLT(*YES) which will reassign deleted relative record numbers to new records, and you won't end up with FIFO , LIFO or FCFO on a reliable basis.

There is no SQL keyword to set REUSEDLT , so you would have to do a CHGPF after the table is created to set that option.

Another way to deal with this is to add a sequence field to the table that you can use to sequence the records using SQL. You don't have to surface that field during the querying of the table, but you would have to include it in the writes.

And now that I think of it, another way to deal with this is to make the new field an identity field which auto increments. You don't ever have to surface such a field, even on inserts. Of course, you still won't be able to get away with just a file change. There will still need to be some code changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM