Reputation: 167
EDITED for clarity:
I've created a table in DB2 using SQL. I have now realized that I did not know the record format for the physical file created and need a Logical File to define keys to use in the RPG code. How can I accomplish this using SQL rather than DDS?
This was what I wanted to ask, really, now that I know a lot more on the subject.
Upvotes: 0
Views: 1703
Reputation: 23793
There's really no difference between a PF created with DDS and a table created with SQL DDL.
Both methods result in a *FILE object with an attribute of PF.
The resulting object from either method can be used with SQL or with RPG record level access (RLA).
You can create DDS LF's or SQL views/indexes over a DDS created PF or an SQL DDL created table.
IBM provides tools to generate SQL DDL for a DDS created object, but not the other way around. You might be able to find a 3rd party tool designed to generate DDS if you lose your DDS source.
Best practice now-a-days is to use SQL DDL; as many recent enhancements to the DB are not available when using DDS.
If you think you need to use DDS for compatibly with RPG for instance, you are incorrect. All you need to do is take advantage of IBM i specific keywords.
Instead of
create table my_long_table_name (
my_long_column_name char(10)
);
Use
create table my_long_table_name
for system name mytable (
my_long_column_name
for mycol char(10)
) rcdfmt mytabler;
Upvotes: 4