如何创建包含编译时错误的 SQL 过程?

how to create SQL procedure which contains compile time errors?

我正在编写一次性 SQL 过程,它将向 table 添加一个标识列,然后将 table 的主键设置为该新标识列。但是我无法编译 SQL 过程,因为 CREATE PROCEDURE 语句 returns 编译错误。

如何告诉 SQL 在编译错误的情况下创建过程?

CREATE or replace PROCEDURE TESTSQL(                                
 )                                                                  
LANGUAGE    SQL                                                     
SPECIFIC        ORDHEADP5T                                          
SET OPTION   DATFMT    = *ISO, DLYPRP = *YES, DBGVIEW = *SOURCE,    
             USRPRF    = *OWNER, DYNUSRPRF = *OWNER, COMMIT = *CHG  
BEGIN                                                               
                                                                    
alter table   ordheader                                             
add column   ordidnum int generated always as identity ;            
                                                                    
alter table     ordheader                                           
add constraint  pk_ordheader primary key ( ordidnum ) ;             
                                                                    
end                                                                 
SQL0205  30      14  Position 44 Column ORDIDNUM not in table ORDHEADER   

如果你把它减少到一个改变 table 你可以做这个,比如:

CREATE or replace PROCEDURE TESTSQL()                                                                  
LANGUAGE    SQL                                                     
SPECIFIC        ORDHEADP5T                                          
SET OPTION   DATFMT    = *ISO, DLYPRP = *YES, DBGVIEW = *SOURCE,    
             USRPRF    = *OWNER, DYNUSRPRF = *OWNER, COMMIT = *CHG  
BEGIN                                                               
alter table   ordheader                                             
    add column   ordidnum int generated always as identity          
    add constraint  pk_ordheader primary key ( ordidnum ) ;             
end