gpt4 book ai didi

oracle - 创建存储过程时如何修复 'Encountered the symbol'?

转载 作者:行者123 更新时间:2023-12-02 10:45:02 26 4
gpt4 key购买 nike

我想创建一个过程来检查记录是否存在,然后更新,否则插入。但是,有一个问题我试图解决,但无法解决。请帮助。

CREATE TABLE JOB_RUN
(
DATE_KEY VARCHAR2(8),
JOB_NAME VARCHAR2(20),
START_DATE TIMESTAMP,
CTL_ROWS NUMBER,
LOAD_DATA_ROW NUMBER,
END_DATE TIMESTAMP,
FLAG_COMPLETED CHAR(1),
PRIMARY KEY (DATE_KEY,JOB_NAME)
);

这是字段的样本值:
INSERT INTO JOB_RUN(DATE_KEY,JOB_NAME,START_DATE,CTL_ROWS,LOAD_DATA_ROW,END_DATE, FLAG_COMPLETED)
VALUES('20110101','TABLE_NAME',SYSDATE,10,0, NULL, 'N');

然后,我创建了接收date_key和job_name的过程
create or replace procedure check_job(pdate IN varchar2,pname IN varchar2) as
declare
v_count int;
begin
select count(*) into v_count from MISDBA.job_run where (date_key=pdate and job_name=pname);
if v_count = 1 then
update job_run
set start_date=sysdate,ctl_rows=5;
else
insert into misdba.job_run(date_key,job_name,start_date,ctl_rows,load_data_row,end_date, flag_completed)
values(pdate,pname,sysdate,10,0, null, 'N');
end if;
commit;
end;

之后,我在下面的查询中运行此程序以调用PROCEDURE
BEGIN
EXECUTE CHECK_JOB('20200101','table2');
END;

我收到此错误:

SQL Error [6550] [65000]: ORA-06550: line 2, column 9: PLS-00103: Encountered the symbol "CHECK_JOB" when expecting one of the following:

:= . ( @ % ; immediate The symbol ":=" was substituted for "CHECK_JOB" to continue. java.sql.SQLException: ORA-06550: line 2, column 9: PLS-00103: Encountered the symbol "CHECK_JOB" when expecting one of the following::= . ( @ % ; immediate The symbol ":=" was substituted for "CHECK_JOB" to continue.

最佳答案

您必须删除EXECUTE:

BEGIN
CHECK_JOB('20200101','table2');
END;

关于oracle - 创建存储过程时如何修复 'Encountered the symbol'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56474280/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com