在我的 pl/sql 过程中出现 pl/sql 语句被忽略的错误,其中
SELECT
在编译时在 sql Developer 中启动
PROCEDURE sort_emp_records (
p_instance_id IN VARCHAR2,
p_filename IN VARCHAR2,
p_max_batch_rec IN NUMBER,
x_status_code OUT VARCHAR2,
x_error_message OUT VARCHAR2
) IS
BEGIN
insert into LCK_EMPLY_TARG_TBL
select VAL_STATUS trunc((rowno + p_max_batch_rec - 1) / p_max_batch_rec) LOOP_SET_ID
from (
select VAL_STATUS, emp_id, row_number() over (order by status) rowno
from LCK_EMPLY_SRC_TBL
where VAL_STATUS = 'VALID'
) dst
EXCEPTION
WHEN OTHERS THEN
x_status_code := sqlcode;
x_error_message := sqlerrm;
END sort_emp_records;
首先,您缺少列名称。在评论部分,您说您的表格有 26 列,您需要通过执行以下操作来指出它们:
insert into LCK_EMPLY_TARG_TBL (column_name_1,column_name_2)
另一种情况是您在选择中的列之间缺少分隔符:
select VAL_STATUS
,trunc((rowno + p_max_batch_rec - 1) / p_max_batch_rec) LOOP_SET_ID
您的查询的最后一个问题是您在末尾缺少一个分号,正如@KoenLostrie之前在评论部分中提到的那样。
最后,您的代码应该或多或少看起来像这样(您只需将
column_name_1
,column_name_2
替换为 LCK_EMPLY_TARG_TBL
表中的真实列名称):
PROCEDURE sort_emp_records (
p_instance_id IN VARCHAR2,
p_filename IN VARCHAR2,
p_max_batch_rec IN NUMBER,
x_status_code OUT VARCHAR2,
x_error_message OUT VARCHAR2
) IS
BEGIN
insert into LCK_EMPLY_TARG_TBL (column_name_1,column_name_2)
select VAL_STATUS, trunc((rowno + p_max_batch_rec - 1) / p_max_batch_rec) LOOP_SET_ID
from (
select VAL_STATUS, emp_id, row_number() over (order by status) rowno
from LCK_EMPLY_SRC_TBL
where VAL_STATUS = 'VALID'
) dst;
EXCEPTION
WHEN OTHERS THEN
x_status_code := sqlcode;
x_error_message := sqlerrm;
END sort_emp_records;