Welcome, Guest. Please login or register.

Login with username, password and session length
Pages: [1]   Go Down
Print
Author Topic: Report tip - sitting in a control file  (Read 1847 times)
0 Members and 1 Guest are viewing this topic.
kenbrody
Administrator

Posts: 82


View Profile
« on: October 15, 2007, 04:08:01 PM »

Sometimes, the best way to run a report is to sit on a record in a control file, and loop through records via "lookup".  While a simple "-sr 1" on the command line may suffice, it does prevent more than one report from being run at a time.  (Record 1 will be locked during the output phase, blocking subsequent reports from running on record 1.)

If you are not doing any posting to any file, a simple "-ro" flag to run in read-only mode may suffice.  However, there are times when you need to post to other files, and read-only mode cannot be used.  In these cases, you need to make sure that each instance of *report is sitting on a different record.

Here is a technique that will make sure that each instance of *report that runs will sit on a different record.

Create a sort/select processing as follows:

    lookup - r=free -e
    write
    select
    end

Run the report with "-sr 1" to select only record 1, along with the appropriate "-v" flag to use this sort/select processing.

This creates a new record for you to sit on, and SELECTs it for the output phase.  Every instance of *report that runs will get a different record.

At the end of your output processing, use DELETE to delete the record you have been sitting on.  This will allow the temporary records to be reused for future report runs.

Note that after the free-record lookup, you may want to populate some fields to mark this as a temporary record.  This can be used to clean up the file in the future should a crash leave the new record intact.
Logged

Kenneth Brody
aka "Mr. filePro"  :-)
Pages: [1]   Go Up
Print
Jump to:  

Valid XHTML 1.0! Powered by SMF 1.1.15 | SMF © 2011, Simple Machines | Massive Blue Theme By Cadosoas Valid CSS!