简体   繁体   中英

AS400 files - convert PF and LF to SQL

I'm working in a IBM environment, specifically with AS400 machines and DB2 databases.
My next task is converting every possible file from PF and LF, to SQL (for instance, CREATE TABLE... and CREATE VIEW...).

Are there cases when I can't do that?
I know that for multiple record format file you can't, is it true?

With System i Navigator on a PC, connect to your server and drill down into Databases and a schema. Click on either Tables or Views to list (possibly all) PFs or LFs in that library. Then, right-click the selections and select 'Generate SQL'. I suggest choosing to generate into 'Run SQL scripts'.

The result will be a SQL script with CREATE TABLE or CREATE VIEW statements for all selected objects. Most relevant LABEL statements will also be included for column attributes. You can either save the script into a .SQL file on the PC or a network share. I usually copy/paste the script rather than save it, but you'll want to experiment in order to understand how line endings (CR and LF) might be generated in your case.

Be sure to review (and possibly test) various options. Some might be better fits for your final objective.

As for multi-format LFs, I don't think I've seen them used on any system I've worked with since SQL became fully available. Since there is no good SQL equivalent, it's unlikely there is any automated method. Maybe someone knows an obscure possibility.

If your question involves a System/36 environment, edit your question to indicate so. Numerous additional comments might be needed.

Yes, there are cases where a file cannot be 'converted to SQL.'
Multiformat logicals are one such case. Program described physicals are another. There may be others where the API cannot generate DDL. This sounds as if you are replacing IBM i with something else. Be advised that DB2 for i is a somewhat different dialect to DB2 LUW, and is quite different to MS SQL Server or MySQL. Significant testing will be required to make sure the data comes across as desired.

Yes one case is when the file has more than one member. Any pf that has max members greater than 1 will cause problems. You can create a list of all PF with multiple members with the dspfd command.

dspfd file(*all/*allusr) type(*mbr) output(*outfile) outfile(mylib/myfile)

Search the outfile for max members > 1.

Looky here for more info, we call this Cruikshanking where I work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM