Thank you. I knew there had to be something I was missing. This option, and keeping the record format statement, will produce a perfect copy of the parent file. Just what was needed. Case closed. Mike.
Original Message:
Sent: Wed January 24, 2024 10:10 AM
From: Daniel Gross
Subject: Database modernization
Hi Mike,
there are 2 variants of the LIKE clause:
The variant without (..) does "copy" more column attributes.
HTH
Daniel
------------------------------
Daniel Gross
Original Message:
Sent: Wed January 24, 2024 09:52 AM
From: Mike Overlander
Subject: Database modernization
Hello, I was trying not to describe all the complications of our system when I asked about the LIKE feature of creating a table. All of your points are well taken and many have already been considered, but since I posed a simple version of my problem, the lack of information may have influenced them. I will expand the information, but try for simplicity.
This is a 2-stage problem. The file in the DDS Format(name) function can easily be converted to source for a table. RunSqlScripts gives us the record format keyword and name, so that is why it's used in the source code. This 'parent' file data is replaced more than 3,000 times a day and is keyed as the example for it's duplicate. 99% of our DDS files are not keyed unique, but programming code usually has maintained the data as unique per the key on the physical file. The data almost always copies to a DDL Table which has the unique key set like the example, without a problem. And one of the biggest points of modernization is to move this enforcement code out of programs.
In stage 1, the application that builds this 'parent' data also needs to compare it to yesterdays version of the data, so stage 2 is the duplicate file created with the DDS Format(name) function, and the data copied to it after every successful load of the parent. In order to successfully convert both of these files to DDL tables, we want them to be exactly the same with the least amount of complexity, work, or opportunity for error. That is why I'm searching for the answers to the LIKE function. And there are 14 files involved in this one job stream that need duplicates containing the history of yesterday.
Daniel, I'm no whiz with the command diagrams in the SQL manual, but I thought LIKE showed that it had to be in parenthesis, so I will look at it again and try it without.
Robert, yes I ran the extract tool over the cloned file, and it doesn't interpret it as a LIKE scenario, it extracts all the fields and labels just like it does for the parent. I'd prefer not to use this to be sure they never get out of sync, which is why the DDS versions use the Format(name) keyword.
And to the points about an identity column, with thousands of DDS files, we are not in a position to make use of this concept and recompile the system.
This isn't the only challenge, we are just trying to incrementally upgrade the system we have. And may programs use the physical files directly, and in some cases we already have hundreds of LF objects over files and we need the record formats to be the same if we hope to avoid level-check issues. We cannot change all access to SQL to avoid it, and I don't believe complicating the system with logical files that are not the complete record layout to achieve a certain level id is a good idea either.
I appreciate all the feedback. It's quite involved to update a 35-40 year old system, and this may just be one part that remains DDS defined.
Thank you all.
------------------------------
Mike Overlander
Original Message:
Sent: Tue January 23, 2024 08:34 AM
From: Mike Overlander
Subject: Database modernization
In traditional DDS coding for a database, you can use the following to create an exact duplicate of a file by another name:
A R EDR832BH1 FORMAT(EDP832BH1)
*
A K H1CMPY
A K H1CST1
A K H1ID#
And using DDL to define the same file duplication, you can do the following:
CREATE OR REPLACE TABLE EDP832BPH1(
LIKE EDP832BH1
)
RCDFMT EDR832BH1;
LABEL ON TABLE EDP832BPH1 IS 'EDI B2B 832 HEADER FILE, PURGED DATA' ;
ALTER TABLE EDP832BPH1
PRIMARY KEY (H1CMPY, H1CST1, H1ID#);
Can anyone explain why the SQL table version does not end up with the same level Id as the parent, and also has no column headings or field text for each field? It is difficult to understand why these two coding techniques do not produce the same result, and if trying to convert to using the tables instead of the file with native I/O you have to recompile all of the programs that depend on the level Id.
Thank you.
------------------------------
Mike Overlander
------------------------------