Go Back
2 Votes

Need a native way to create an ISAM file from a Repository file and structure definition


There should be a native way to create an ISAM file with a utility or from XCALL ISAMC by passing a File and Structure Definition from the Repository.  Currently, we can write our own code to do it by using the Data Dictionary XCALL routines, but seems like this functionality should be built-in to the language since it is such a funamental concept to developing applications.

8 Comments | Posted by Bret Tenny to Synergy DBL, Repository on 5/31/2016 12:00 PM
Steve Ives
CodeGen includes a utility called CreateFile that I believe will address your requirement. It is a command line utility that accepts either -s <rpsStructureName> or -f <rpsFileName> parameters and then creates an ISAM file based on the structure, key and file definitions in your repository. You could download and install CodeGen to get access to the utility, or you could grab the source code from GitHub and build and distribute your own version. Most of the functionality that you are looking for is in the file DoCreateFile.dbl.

6/6/2016 12:47 AM   0  
Bill Hawkins
There is also a CodeExchange submission ISMKEY that will generate the data needed by ISAMC from the Repository definitions.

6/15/2016 3:40 PM   0  
Bret Tenny
Thanks for these suggestions.  I am using them both for sure.  My comment here is that not having a NATIVE way in the language to do this, I feel, is a limitation and a very fundamental one.  ISAM files and the RPS are basic to using Synergy/DE and not have a documented way to do this in the Synergy manuals just seems like "what?!".  I can define a file in the RPS and init one with XCALL ISAMC, but I have no way to link the two.

6/15/2016 4:41 PM   0  
Gordon Ireland
I agree with Bret.  I am setting up a number of new structures with multiple, multi-field keys, and it seems really bad that you have to woirk out field positions in records on your fingers.

I'll have a go with the codegen stuff, but it would be nice if ISAMC could accept a repository file name, pick up the keys and just create the file
 

11/27/2017 3:56 PM   0  
Gordon Ireland
I've tried codegen's CreateFile  It doesn't seem to work for files which have auto sequence numbers in the key.  Crashes.

FIles which have alpha and decimal key fields work fine

 

11/27/2017 4:11 PM   0  
Steve Ives
Gordon, I just tested CreateFile, using both the -s (from structure definition) and -f (from file definition) mechanisms, using definitions with both auto sequence and auto time-stamp primary keys, and it created files with appropriate keys in all cases. I don't remember when I added support for this, but it was some time ago, but please make sure you're using the latest version of ColdeGen.

If that is not the issue then please email me the schema for the repository that you are using and tell me which files / structures fail.
 

11/27/2017 5:25 PM   0  
Gordon Ireland
I have just sent you the schema file and structure name.

I installed the latest codegen last week

 

11/27/2017 5:34 PM   0  
Steve Ives
OK, here is what appears to be happening:
  1. Apparently Repository lets you define illegal keys
  2. CreateFile isn’t trapping the “Illegal key specified” that is coming out of XCALL ISAMC 
Basically you can’t do what you’re trying to do with auto keys. From the documentation:
 
“Synergy DBMS automatically fills autokeys (SEQUENCE, TIMESTAMP, and CTIMESTAMP) with the appropriate values. A sequence key starts at 1 and is incremented in sequence for every record stored until the file is cleared with ISCLR. A sequence key cannot be descending. A record with autokeys passed to a STORE or WRITE statement will be updated to reflect the autokey values that were stored or written, unless a literal was passed. This allows you to retrieve the autokey values from the record without having to reread it. An autokey must be declared the appropriate size and cannot be modified, does not allow duplicates, cannot be a null key, and cannot be segmented or be a segment in a key with multiple segments. By default, autokey values are preserved (with the exception of a timestamp key where the incoming key data amounts to an empty key; in this case, all zeros, blanks, or nulls will be generated to the current timestamp).”
 
Sorry to be the bearer of bad news, but thanks for the heads up about the error handling issue in CreateFile, that will be fixed in the next release in the next couple of days. I'll also notify development about the issues in Repository.

11/27/2017 6:36 PM   0  
Please log in to comment on this idea.