× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 05-Jan-2014 09:41 -0800, William Salim wrote:
Before this I also use RRN, but as Birgitta said what about if
reorganized or perhaps data deleted. So that why I asked to this
forum.

Of course /deleted/ records would have no impact, *if* the file is defined with Reuse Deleted Records attribute turned off [i.e. REUSEDLT(*NO)], at least *until* the data is reorganized.

Still thinking using the trigger combine with RRN or not...

If the RRN is acceptable [I agree with both Birgitta and Dieter that using RRN should be avoided], then a simple means to circumvent the lack of the year data is to create a file that defines the range of RRN from each year of data. Use that new file to provide data for the missing year information.

Given the assumption that the first 12000 rows are from year=2012, the next 13000 are from year=2013, and some 14 recently added rows are from year=2014:

create table yearMap
( fromRRN dec(7), toRRN dec(7), isYear dec(4) )
;
insert into yearMap values
( 1, 12000, 2012 )
, ( 12001, 25000, 2013 )
, ( 25001, 25014, 2014 )
, ( 25015, 9999999, default )

Then the reporting can use the effect of the following query [using whatever technique is required or desired to minimize changes to the reporting program; e.g. OPNQRYF]:

select D.*
from mmddDBF as D
inner join
yearMap as Y
on rrn(D) between fromRRN and toRRN
order by Y.isYear, D.monthFld, D.dayFld

Of course if the mapping of the data by RRN to year is that simple, rather than creating a table to store the year data and joining to that new table, the use of an expression for the ORDER BY is an option; e.g.:

select D.*
from mmddDBF as D
order by
case rrn(D)
when rrn(D) between 1 and 12000
then dec( 2012, 4)
when rrn(D) between 12001 and 25000
then dec( 2013, 4)
when rrn(D) between 25001 and 25014
then dec( 2014, 4)
/* otherwise the NULL value */
end
, D.monthFld
, D.dayFld


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.