Computer Corporation of America
|
Feedback
Search CCA:
   
USA CCA
CCA Products
CCA Customer Support
CCA Resources
CCA - Company
CCAPRINT: A Newsletter for Model 204® and System 1032® Users
January 25, 2008
     
Model 204: Sorted Sets and Record Locks Printer-friendly version
System 1032: Loading PC-Format Data Finishing Details Printer-friendly version

 

Model 204
USE OF AND ACCESS TO PRODUCTS AND FEATURES ARE IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF THE USER’S SOFTWARE LICENSE. THE PRESENTATION OF MATERIAL HEREIN DOES NOT, IN ANY MANNER, MODIFY SUCH TERMS AND CONDITIONS.

Sorted Sets and Record Locks
By James Damon



The User Language SORT statement provides the capability for sorting two different types of record sets: records in a found set or records on a list. The resulting sorted set of records is a temporary set of records maintained on one or more CCATEMP pages. The actual data records in Table B are not affected by the sort operation. They are not moved or rearranged as a result of the sort.


The records in the sorted set are also not locked--they have neither a shared nor exclusive enqueue. However, if the sort is operating against a:

This article focuses on these record locks or lack thereof and how it may affect the results of the application.

The SORT statements
There are two different forms of the SORT statement:

Label: SORT [k] RECORDS     {IN LABEL | ON listname } BY key [AND key]...
Label: SORT [k] RECORD KEYS {IN label | ON listname } BY key [AND key]...

Either of these SORT statements creates a temporary set of records stored on CCATEMP pages. On a record-by-record basis:

Shared Record Locks and the SORT Statements
Consider the following applications, which find a set of records and then sort them using either the SORT RECORDS statement or the SORT RECORD KEYS statement.

SORT RECORDS application


BEGIN
ALL: FD ADMIT.DATE = 20071101
END FIND
SRT1: SORT RECORDS IN ALL BY CITY
FR SRT1
PRINT PATIENT.ID AND DIAGNOSIS -
AND PHYSICIAN AND CITY AND STATE
END

SORT RECORD KEYS application


BEGIN
ALL: FD ADMIT.DATE = 20071101
END FIND
SRT1: SORT RECORD KEYS IN ALL BY CITY
FR SRT1
PRINT PATIENT.ID AND DIAGNOSIS –
AND PHYSICIAN AND CITY AND STATE
END

The outputs generated by the PRINT statement are identical because in both applications the records are locked. The records in the found set labelled ALL, against which the SORT statement operates, are locked in share mode and cannot be changed until the entire request has run to completion or until a RELEASE RECORDS IN ALL statement is evaluated. Even though each FR SRT1 loop operates against an unlocked set of temporary records in CCATEMP, the underlying base records remain locked in share mode due to the FD (FIND) statement and, thus, cannot be changed.

Unlocked Records and the SORT Statements
Now compare the following two applications, where the found set is not locked because the FDWOL (FIND WITHOUT LOCKS) statement is used to create the found set labelled ALL. Everything discussed here applies if the sort was operating against a record list, which by definition is not locked.

SORT RECORDS application


BEGIN
ALL: FDWOL ADMIT.DATE = 20071101
END FIND
SRT1: SORT RECORDS IN ALL BY CITY
FR SRT1
PRINT PATIENT.ID AND DIAGNOSIS -
AND PHYSICIAN AND CITY AND STATE
END

SORT RECORD KEYS application


BEGIN
ALL: FDWOL ADMIT.DATE = 20071101
END FIND
SRT1: SORT RECORD KEYS IN ALL BY CITY
FR SRT1
PRINT PATIENT.ID AND DIAGNOSIS -
AND PHYSICIAN AND CITY AND STATE
END

 

In both applications, the underlying records in the found set may be changed while processing the application, because there are no locks on the found set. However,

  • The SORT RECORDS application results do not reflect changes made while processing because the temporary records sorted and saved on CCATEMP pages are not updated by concurrent update applications. Of course, the underlying Table B base records are updated. However, since the data from those records has already been extracted and copied to CCATEMP pages for sort processing, subsequent updates to the underlying Table B base records are not seen by that application’s FR SRT1 loop.
  • The SORT RECORD KEYS application results might reflect changes to the underlying Table B base records. Since the data from these records is revisited during the FR SRT1 loop, updates made by other users to a record not yet processed by the FR SRT1 loop will be seen in the PRINT output. This could lead to unexpected results especially if some of the fields used in the find criteria change before your report completes.

Unexpected results
For example, you may want to produce a report including only Volkswagons, only to discover that some of those Volkswagons have turned into Mercedes! That could happen in the following example where the FDWOL found set could have MAKE changed in some of the records before they are processed by the FOR EACH RECORD loop. This is a somewhat far-fetched example to illustrate the point.

BEGIN
ALL: FDWOL MAKE = VOLKSWAGON
END FIND
SRT1: SORT RECORD KEYS IN ALL BY YEAR
FOR EACH RECORD IN SRT1
PRINT YEAR AND MAKE AND VIN AND MODEL
END

If another request runs before or during the FOR EACH RECORD IN SRT1 loop and changes some of the records in the found set ALL from MAKE=VOLKSWAGON to MAKE=MERCEDES before those records are printed, then this report may print some Mercedes records even though the found set originally included only Volkswagons. When using FDWOL, keep in mind that your found set, since it is not locked, could end up being a collection of records you don’t want or expect because the fields used as find criteria in the FDWOL may have changed by the time you process the records in a subsequent FOR loop.

In Summary
If you make frequent use of the SORT statement, there are essentially two issues to consider:

  1. For maximum flexibility and ease of use, SORT RECORD KEYS is probably the best choice. It allows for the underlying Table B records, processed in the FOR loop, to be updated in that FOR loop. That is not possible in a FOR loop that processes a SORT RECORDS set.

  2. If you want a static view of the data and want to avoid holding record locks for long periods of time, SORT RECORDS is a better choice. The found set used to produce a set of sorted records can be released immediately after the SORT RECORDS statement, avoiding a potentially lengthy share lock on the found set.

System 1032
USE OF AND ACCESS TO PRODUCTS AND FEATURES ARE IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF THE USER’S SOFTWARE LICENSE. THE PRESENTATION OF MATERIAL HEREIN DOES NOT, IN ANY MANNER, MODIFY SUCH TERMS AND CONDITIONS.

Loading PC-Format Data Finishing Details
By Tym Stegner

TymIn my previous article, Loading PC-Format Data into System 1032, we diagnosed a LOAD problem caused by a non-VMS data file, and began the process to convert this data into a form that System 1032 can read. In this article, we will continue the process, including:

Determining Record Length
The previous article concluded with my explanation of how to use the VMS CONVERT command with an FDL file to translate a STREAM format file into a VARIABLE format file. This article begins with the next step: to determine the appropriate record length.

The RD we plan to use to load this data file has a record length of 591 characters. (Note: to see the record length of an RD, use the command SHOW RD <name> FIELD COLUMN, then look at the last entry. Usually this will be the full record length.)

At my request, the customer, who originally asked how to load this large text file, modified the SIZE quality in the RECORD section of the FDL file to be this length:

  +RECORD
+ BLOCK_SPAN yes
+ CARRIAGE_CONTROL carriage_return
+ FORMAT variable
+ SIZE 591

When the file was modified, the customer used that FDL file with the CONVERT command to translate the data file, then tried to load it into the dataset from System 1032. To reduce the time necessary to test the updated file, I suggested the use of the MAXIMUM option in the LOAD command, to limit the number of records to be read in to only the first 10 records.

Unfortunately, there was still a problem. When the CONVERT command was attempted, the following error occurred:

 Convert-I-RTL, record longer than maximum record length.

Consulting HELP/MESSAGE, I found the following explanation:

 $ HELP/MESSAGE/FACILITY=CONVERT  RTL
RTL, record longer than Maximum Record Length
Facility: CONV, Convert Utility
Explanation: The record from the input file is longer than the
maximum record length specified in the output file.
This is an exception condition; the record will not
be written to the output file. If the /EXIT qualifier
is specified, processing will stop.
User Action: Specify the /TRUNCATE qualifier.

This suggested to me that the SIZE quality we specified in the FDL file was not adequate. Although 591 bytes is the amount of data to be read into the dataset, it is not necessarily the length of the record in the input file.

Back to the beginning
It seemed as though we had just come back to the beginning with no forward progress. We needed to examine the record to find out how long it actually is, but we could not do that, because we could not open the file in the editor. If we could open the data file, we could inspect a record and check for a LineFeed character, which marks the end-of-record.

So, we discussed two approaches:

Extracting Records
So, how can we get a few records out of the file for inspection, when we cannot use the editor to open the file? The DCL command language came to our rescue. The following short DCL program can extract the first 10 records from the file supplied as the first parameter:

$!  First10.COM
$!
$ rdNum = 0
$ recBuf = "" !working buffer
$ infile = p1
$ open/read ic 'infile
$ open/write oc 'f$parse(infile,,,"NAME")'.TEST
$!
$rdloop:
$ read/end=no_more ic recBuf
$ rdNum = rdNum + 1
$ if rdNum .gt. 10 then goto no_more
$ write oc recBuf
$ goto rdloop
$!
$no_more:
$ close ic
$ close oc
$ dir/date/size 'f$parse(infile,,,"NAME")'.*
$ exit

The extracted records were placed in a file with the original name, but with the file-type set to TEST. This much smaller file could now be opened using an editor to inspect the records for record length.

On to LOAD
As it turned out, the incoming file had records that are 700 characters long. The 700 value was set into the FDL file under the SIZE heading, and another CONVERT command was issued. This time the conversion process was successful and created a new file. This new file, when used for the load of the dataset, worked as expected.

Summary
This article concludes the processing of a STREAM file into a VARIABLE format file, suitable for reading into System 1032. As the original file was much too large to be converted using the editor, as was the practice at this site, the CONVERT command and an FDL file were used to reformat the STREAM file into a fixed length VARIABLE format file.

Copyright © 2008 Computer Corporation of America.
All right reserved. Published in the United States of America.


Contact CCA Webmaster
Copyright 2008