PL/SQL procedure exception compile error

时间:2015-12-10 02:01:43

标签: oracle plsql plsqldeveloper

I want write procedure which create in temporary table in temp_line and LOOP in temp_line to check and get exception.

create or replace package body cux_bpm_hr_030_040_2 is 
FUNCTION save_hr_030_040(p_event_record_id       number,
                       p_share_log_id          number,
                       p_oa_flow_doc_header_id number,
                       p_created_by            number) return number is
v_data_line_id        number;
v_total_amount        number;
v_annual_vct_hour     number;
v_ot_vct_hour         number;
v_annual_vct_req_hour number;
v_ot_vct_req_hour     number;
v_string_date         varchar(100);
e_req_hour_error exception;
e_req_hour_error1 exception;
v_num                 number;

begin
select count(*) 
into v_num 
from user_tables 
where table_name = 'temp_line';

if v_num < 1 then   execute immediate ('CREATE GLOBAL TEMPORARY TABLE temp_line (   holiday_id VARCHAR2(6), holiday_begin_date DATE, holiday_begin_hour (6), holiday_begin_min (6), holiday_end_date DATE, holiday_end_hour (6), holiday_end_min (6)   ) ON COMMIT PRESERVE ROWS');   end if;

execute immediate ('FOR recitem IN(select * from oa_tplt019_line_01_v l where l.oa_flow_doc_header_id = p_oa_flow_doc_header_id)


LOOP 
insert into temp_line(holiday_id,holiday_begin_date,holiday_begin_hour,holiday_begin_min,holiday_end_date, holiday_end_hour,holiday_end_min)
values
(recitem.C_025,recitem.C_027,recitem.C_028,recitem.C_029,recitem.C_030,recitem.D_001,reitem.D_002)  ENDLOOP;');`

LOOP
Declare
        begin_diff varchar2(8);
        diff       varchar2(8);
        holiday_begin_date   number;
        holiday_end_date     number;
select nvl(l.holiday_begin_date, 0),nvl(l.holiday_end_date, 0)
into holiday_begin_date,holiday_end_date
from temp_line l

begin_diff = holiday_begin_date - sys_date
diff =  holiday_end_date - holiday_begin_date
IF begin_diff > 3 then
  raise e_req_hour_error;
  ENDIF;
IF diff < 0 then
  raise e_req_hour_error1;
  ENDIF; ENDLOOP;

I'm getting compile error:

Compilation errors for PACKAGE BODY KL_BPMDEV.CUX_BPM_HR_030_040_2

Error: PLS-00103:  Encountered the symbol ""when expecting one of the following:
        ( begin case declare end
          exception exit for goto if loop mod null pragma raise return
          select update while with <an identifier>
          <a double-quoted delimited-identifier> <a bind variable> <<
          continue close current delete fetch lock insert open rollback
          savepoint set sql execute commit forall merge pipe purge
Line: 25
Text: ﹛ --create temporary table

1 个答案:

答案 0 :(得分:0)

代码中的主要错误是您在BEGIN ... END中声明了一些其他变量。您只能在功能BEGIN之前声明。您需要学习编写函数/过程的基础知识。见here

除此之外,您还需要修复几个调试错误。以下函数已成功编译。请查看我做出更正的评论

join

无论您是复制此代码的一部分,还是自己完全编写,都需要使用编辑器来修复这些错误。我看到你标记了plsqldeveloper。该工具可以准确地告诉您有哪些错误,您可以逐个修复它们,直到您编译它们为止。