代码失败,因为找不到JIT_TIME的值

时间:2016-08-03 23:15:38

标签: shell unix plsql ksh

以下函数包含在从shell脚本调用的PLSQL包中。它失败,因为找不到JIT_TIME。我很难弄清楚这个价值来自哪里。它显然不作为参数传递,不存储在任何数据库表中,也不从任何其他数据库对象中检索。

Function ADD_START_DATE( p_process_type char, p_profet_cntl_no char, p_error_file UTL_FILE.FILE_TYPE) return boolean is                                                                                
        v_profet_control_no     char(10);                                                                                                                                                                        
        v_jit_time              date;                                                                                                                                                                                   
    BEGIN                                                                                                                                                                                                  
        BEGIN                                                                                                                                                                                                 
            SELECT      contr_numb                                                                                                                                                                                   
            INTO        v_profet_control_no                                                                                                                                                                            
            FROM        prd_contr                                                                                                                                                                                      
            WHERE       end_date_time is null                                                                                                                                                                         
            AND         start_date_time is not null                                                                                                                                                                    
            AND         rownum=1;                                                                                                                                                                                      
            PKG_WRITE_ERROR.writeError( p_error_File , 'PRD-01601','ProFET Control No.='||v_profet_control_no);                                                                                                  
            return false;                                                                                                                                                                                        
        EXCEPTION                                                                                                                                                                                             
            when NO_DATA_FOUND then                                                                                                                                                                              
                null;                                                                                                                                                                                               
        END;                                                                                                                                                                                                  
        lock table prd_contr in exclusive mode nowait;                                                                                                                                                        
        BEGIN                                                                                                                                                                                                 
--                                                                                                                                                                                                      
-- A new Begin-End block has been added for jit_time function. If the value                                                                                                                             
-- of jit_time is not found, in case of complete refresh, an error is logged                                                                                                                            
-- and the process exits. In case of routine, jit_time error is ignored.                                                                                                                                
--                                                                                                                                                                                                      
            BEGIN                                                                                                                                                                                                
                v_jit_time:=jit_time;                                                                                                                                                                               
            EXCEPTION                                                                                                                                                                                            
                when OTHERS then                                                                                                                                                                                    
                    IF p_process_type = 'C' then                                                                                                                                                                       
                        PKG_WRITE_ERROR.writeError( p_error_File , 'PRD-01604', '');                                                                                                                                      
                        return false;                                                                                                                                                                                     
                    END IF;                                                                                                                                                                                            
            END;                                                                                                                                                                                                 
            INSERT into prd_contr(start_date_time, end_date_time, idp1_xfer,                                                                                                                                     
                    proc_type, contr_numb, idp1_time)                                                                                                                                                                  
            VALUES(SYSDATE, '','', p_process_type, p_profet_cntl_no,v_jit_time);                                                                                                                                 
        EXCEPTION                                                                                                                                                                                             
            when OTHERS then                                                                                                                                                                                     
                return false;                                                                                                                                                                                       
        END;                                                                                                                                                                                                  
        commit;                                                                                                                                                                                               
        return true;                                                                                                                                                                                          
    EXCEPTION                                                                                                                                                                                              
        when TIMEOUT_ON_RESOURCE then                                                                                                                                                                         
            PKG_WRITE_ERROR.writeError( p_error_File , 'PRD-01602', '');                                                                                                                                         
            return false;                                                                                                                                                                                        
        when OTHERS then                                                                                                                                                                                      
            PKG_WRITE_ERROR.writeError( p_error_File, 'PRD-01699',substr(SQLERRM,1,100));                                                                                                                        
            return false;                                                                                                                                                                                        
    END ADD_START_DATE;   

2 个答案:

答案 0 :(得分:0)

我注意到变量日期是用v_jit_time类型定义的,但从未使用过。另一方面,有一个永远不会定义的变量jit_time。 我可以成为一个人:

Function ADD_START_DATE( p_process_type char, p_profet_cntl_no char, p_error_file UTL_FILE.FILE_TYPE) return boolean is                                                                                
        v_profet_control_no     char(10);                                                                                                                                                                        
        v_jit_time              jit_time;                                                                                                                                                                                   
    BEGIN                                                                                                                                                                                                  
        BEGIN                                                                                                                                                                                                 
            SELECT      contr_numb                                                                                                                                                                                   
            INTO        v_profet_control_no                                                                                                                                                                            
            FROM        prd_contr                                                                                                                                                                                      
            WHERE       end_date_time is null                                                                                                                                                                         
            AND         start_date_time is not null                                                                                                                                                                    
            AND         rownum=1;                                                                                                                                                                                      
            PKG_WRITE_ERROR.writeError( p_error_File , 'PRD-01601','ProFET Control No.='||v_profet_control_no);                                                                                                  
            return false;                                                                                                                                                                                        
        EXCEPTION                                                                                                                                                                                             
            when NO_DATA_FOUND then                                                                                                                                                                              
                null;                                                                                                                                                                                               
        END;                                                                                                                                                                                                  
        lock table prd_contr in exclusive mode nowait;                                                                                                                                                        
        BEGIN                                                                                                                                                                                                 
--                                                                                                                                                                                                      
-- A new Begin-End block has been added for jit_time function. If the value                                                                                                                             
-- of jit_time is not found, in case of complete refresh, an error is logged                                                                                                                            
-- and the process exits. In case of routine, jit_time error is ignored.                                                                                                                                
--                                                                                                                                                                                                      
            BEGIN                                                                                                                                                                                                
                v_jit_time:=jit_time;                                                                                                                                                                               
            EXCEPTION                                                                                                                                                                                            
                when OTHERS then                                                                                                                                                                                    
                    IF p_process_type = 'C' then                                                                                                                                                                       
                        PKG_WRITE_ERROR.writeError( p_error_File , 'PRD-01604', '');                                                                                                                                      
                        return false;                                                                                                                                                                                     
                    END IF;                                                                                                                                                                                            
            END;                                                                                                                                                                                                 
            INSERT into prd_contr(start_date_time, end_date_time, idp1_xfer,                                                                                                                                     
                    proc_type, contr_numb, idp1_time)                                                                                                                                                                  
            VALUES(SYSDATE, '','', p_process_type, p_profet_cntl_no,v_jit_time);                                                                                                                                 
        EXCEPTION                                                                                                                                                                                             
            when OTHERS then                                                                                                                                                                                     
                return false;                                                                                                                                                                                       
        END;                                                                                                                                                                                                  
        commit;                                                                                                                                                                                               
        return true;                                                                                                                                                                                          
    EXCEPTION                                                                                                                                                                                              
        when TIMEOUT_ON_RESOURCE then                                                                                                                                                                         
            PKG_WRITE_ERROR.writeError( p_error_File , 'PRD-01602', '');                                                                                                                                         
            return false;                                                                                                                                                                                        
        when OTHERS then                                                                                                                                                                                      
            PKG_WRITE_ERROR.writeError( p_error_File, 'PRD-01699',substr(SQLERRM,1,100));                                                                                                                        
            return false;                                                                                                                                                                                        
    END ADD_START_DATE;   

答案 1 :(得分:0)

据我所知 JIT_TIME 功能。 所以你应该搜索函数定义 - 而不是在参数,变量或表中。

此外,程序员还清楚地预计在某些情况下无法找到此功能,如评论

中所示
-- If the value                                                                                                                             
-- of jit_time is not found, in case of complete refresh, an error is logged                                                                                                                            
-- and the process exits. In case of routine, jit_time error is ignored.