简体   繁体   English

AS400文件 - 将PF和LF转换为SQL

[英]AS400 files - convert PF and LF to SQL

I'm working in a IBM environment, specifically with AS400 machines and DB2 databases. 我在IBM环境中工作,特别是AS400机器和DB2数据库。
My next task is converting every possible file from PF and LF, to SQL (for instance, CREATE TABLE... and CREATE VIEW...). 我的下一个任务是将每个可能的文件从PF和LF转换为SQL(例如,CREATE TABLE ...和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. 使用PC上的System i Navigator,连接到服务器并深入查看数据库和模式。 Click on either Tables or Views to list (possibly all) PFs or LFs in that library. 单击“表”或“视图”以列出该库中的PF(可能是所有)PF或LF。 Then, right-click the selections and select 'Generate SQL'. 然后,右键单击选择并选择“生成SQL”。 I suggest choosing to generate into 'Run SQL scripts'. 我建议选择生成'运行SQL脚本'。

The result will be a SQL script with CREATE TABLE or CREATE VIEW statements for all selected objects. 结果将是一个SQL脚本,其中包含所有选定对象的CREATE TABLE或CREATE VIEW语句。 Most relevant LABEL statements will also be included for column attributes. 列属性也将包含大多数相关的LABEL语句。 You can either save the script into a .SQL file on the PC or a network share. 您可以将脚本保存到PC或网络共享上的.SQL文件中。 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. 我通常复制/粘贴脚本而不是保存它,但是你需要进行实验以了解在你的情况下如何生成行结尾(CR和LF)。

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. 至于多格式LF,我认为我已经看到它们在我使用的任何系统上使用,因为SQL完全可用。 Since there is no good SQL equivalent, it's unlikely there is any automated method. 由于没有好的SQL等价物,因此不太可能存在任何自动化方法。 Maybe someone knows an obscure possibility. 也许有人知道一种模糊的可能性。

If your question involves a System/36 environment, edit your question to indicate so. 如果您的问题涉及System / 36环境,请编辑您的问题以表明如此。 Numerous additional comments might be needed. 可能需要许多其他评论。

Yes, there are cases where a file cannot be 'converted to SQL.' 是的,有些情况下文件无法“转换为SQL”。
Multiformat logicals are one such case. 多格式逻辑就是这样一种情况。 Program described physicals are another. 程序描述的物理是另一种。 There may be others where the API cannot generate DDL. 可能还有其他API无法生成DDL。 This sounds as if you are replacing IBM i with something else. 这听起来好像是用其他东西替换IBM i。 Be advised that DB2 for i is a somewhat different dialect to DB2 LUW, and is quite different to MS SQL Server or MySQL. 请注意,DB2 for i与DB2 LUW的方言略有不同,与MS SQL Server或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. 任何max成员大于1的pf都会导致问题。 You can create a list of all PF with multiple members with the dspfd command. 您可以使用dspfd命令创建具有多个成员的所有PF的列表。

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

Search the outfile for max members > 1. 在outfile中搜索max members> 1。

Looky here for more info, we call this Cruikshanking where I work 在这里寻找更多信息,我们称之为Cruikshanking我工作的地方

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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