在DB2 iseries中为多个sql文件创建脚本

时间:2018-04-19 13:22:17

标签: db2 ibm-midrange db2-400

我想创建一个sql文件来执行多个其他的sql文件 为了正确运行或“部署”文件。

我通常(在oracle中)做了类似的事情:

@/location/table1.sql  
@/location/table1triggers.sql  
@/location/table1index's.sql  
@/location/table2.sql  
@/location/table2triggers.sql  
@/location/table2index's.sql  
@/location/table1constraints.sql (FK for table 2)

然后只执行了整个文件,对于db2 iseries / ibm有什么类似的吗?

1 个答案:

答案 0 :(得分:3)

在IBM i上,我会通过创建一个运行每个脚本的CL程序来实现这一点:

RUNSQLSTM SRCSTMF('/location/table1.sql')
RUNSQLSTM SRCSTMF('/location/table1triggers.sql')
RUNSQLSTM SRCSTMF('/location/table1indexes.sql')
RUNSQLSTM SRCSTMF('/location/table2.sql')
RUNSQLSTM SRCSTMF('/location/table2triggers.sql')
RUNSQLSTM SRCSTMF('/location/table2indexes.sql')
RUNSQLSTM SRCSTMF('/location/table1constraints.sql') /* FK for table 2 */

然后使用CRTCLPGM命令将其编译到程序中,然后使用CALL命令执行。

虽然DB2 for i语法中有INCLUDE语句,但只能嵌入到写入RPG,COBOL或C的程序中。