2B
Generating DDL from a DDS
2E Model with No Changes
Crispin Bates – CPU Inc
About Me
— I work for CPU, Inc.
— CPU, Inc. (http://www.cpulink.net)
Ohio focusing on IBM i, Microsoft
development. Our expertise is in
deploying CA 2E/Plex and RPG app
user interfaces using Zend Server.
— I started my programming career
— I have been a 2E user since 1989.
— I have been a Plex user since 1998
2
) is a CA Partner based in Cincinnati,
Windows and Internet application
designing, constructing and
plications, as well as Sencha 's Ext JS
in 1988 using RPGII in the UK.
.
8.
Session Abstract
— This presentation will look at ge
generating DDS and RPG4 Code
definitions without changing th
— We wanted minimal impact to
generate DDL files for our DB2 W
— We will look at the generator ex
parsing the generated DDL.
3
etting a 2E Model that had been
e to generate DDL for the database
he model generation options.
existing code, but wanted to
Web Query implementation.
xit points, calling API’s and
Agenda
— 1. What are we doing and why?
— 2. How are we going to do this?
— 3. Putting it all together.
— 4. Questions & Answers.
4
?
?
What are we doing and why?
— We are a fairly traditional 2E RP
applications using DDS for the
— We also use Web Option
— We looked at DB2 Web Query a
implement it for our users.
— DB2 Web Query promised to be
our users to access the wealth o
application.
5
PG shop developing 5250
Database
and decided we wanted to
e a new Business Analytics tool for
of data that they have in our
What are we doing and why?
— One of the first requests that ca
that the field names in the DB2
business name, and not the DD
— We also noticed that for some o
creating we were getting poor p
suggesting that we create SQL I
— At this point I started looking a
2E, and quickly determined tha
change to SQL Generation.
6
ame from our business group was
2 Web Query tool match the fields
DS Name.
of the reports that we were
performance. The system was
Index’s to improve performance.
at the SQL Generation options in
at it would be a huge impact to
What are we doing and why?
— The next thing I started looking
and Index’s that would provide
Access plans that the system w
— My first pass at these produced
people were really happy with t
— But…this was all manual work,
doing it this way.
7
g at was manually creating Views
e the Long Field names and the
was suggesting.
d good results, and our Business
the results.
and I did not want to continue
What are we doing and why?
— It was around this time that I was bro
came across a really interesting threa
DDL within the same 2E Model
— The question that was asked was whe
in the same Model.
— Several references were posted.
− Dan Cruickshank of IBM had produced
that talked about replacing DDS with D
and this was what was being used for r
− There was also a good article on the Pl
• http://wiki.2einfo.net/index.php?title=Us
8
owsing the CA Community Forums and I
ad that was discussing mixing DDS and
ether is was possible to mix DDS and DDL
a document about Database Modernization
DDL without having to recompile any programs
reference
lex/2E Wiki
sing_SQL_with_2E
How are we going to do this?
— So, I read Dan’s document on d
the first time) and then started
newer DDL options that were in
clause on the CREATE TABLE sp
— After an hour or two I had recre
and that TABLE had the same R
the original DDS PF. I could use
programs in my 2E Model. Now
9
database modernization (not for
d playing around with some of the
n V5R4, in particular the RCDFMT
pecification
eated a DDS PF as a DDL TABLE,
Record Format Level Identifier as
e this TABLE without affecting any
w I was getting somewhere.
Data Validation DDS vs. DDL
— One thing to note is the difference be
TABLE vs. a DDS PF.
— Data is validated when written to a D
— Data is validated when read from a D
— We ran some analysis over our PF’s lo
returned via DSPFD.
— We found that about 98% or more of
were Read Access.
— This suggested that DDL would provid
is not done on Read Access.
10
etween the way data is validated in a DDL
DDL TABLE
DDS PF
ooking at the Read vs. Write statistics
f the data access for almost all of our PF’s
de better performance because validation
How are we going to do this?
— I then came across the QSQGND
really interesting
— Additionally I read that at IBM
the specification of the RCDFMT
the puzzle, as I could now repla
— So, now for the interesting stuff
11
DDL API. This is where things got
i 6.1 the INDEX DDL would allow
T clause. This was the last piece in
ace the DDS LF’s with DDL INDEX’s
f…
QSQGNDDL API
— From the infocenter
− The Generate Data Definition Langu
data definition language statemen
The results are returned in the spec
12
uage (QSQGNDDL) API generates the SQL
ts required to recreate a database object.
cified database source file member.
Prerequesites
— Some things that I need to say
− DDL TABLE’s force REUSEDLT(*YES)
− Multi Member PF’s not supported i
− Joins (virtuals) not supported in Ind
− QSQGNDDL does not correctly gene
when an INDEX is the target object
• Note: DCREQ Opened with IBM Roch
− So, I need to cater for this later on…
13
here
in SQL
dex
erate DDL for Select/Omit specifications
t
hester and was accepted
…
QSQGNDDL
— There are several good resource
downloadable code that implem
— Carsten Flensburg provided a re
downloadable code. Requires P
SystemiNetwork
− http://systeminetwork.com/article/
database-files-and-objects-sql-ddl-
14
es where you can find
ments the QSQGNDDL API.
eally good article here, with
Pro Membership to
/apis-example-reverse-engineering-
-statements
QSQGNDDL
— Tom Holden has a simplified ve
− http://www.tommyholden.com/dow
— You can also roll your own in 2E
15
ersion that works well here
wnloads/Save%20Files/index.html
E…
QSQGNDDL Implementation
16
QSQGNDDL Prototype
17
QSQGNDDL Datastructure
18
QSQGNDDL Datastructure 2
19
QUSEC Definition
20
QSQGNDDL Implementation
21
QSQGNDDL Implementation
22
Parameters
23
Parameters
24
QSQGNDDL - Notes
— The QSQGNDDL API does not au
Member in the Source file that
will fail if the member is not fo
that the member exists, and is
25
utomatically create the Source
is specified on the API. The API
ound. So, you have to make sure
empty before calling the API.