这是我第一次创建一个包含IN和OUT参数的存储过程,而且我很丢失。我想要做的是将3个参数(ID_TX,FORM_NAME和DATA_DATE)中的API传递到我的存储过程中,让我的存储过程执行一个简单的插入,然后传递一个值(SUBMISSION_ID)。但是,当我尝试编译代码时,我不断收到错误。错误如下:
Error(8,1): PLS-00103: Encountered the symbol "INSERT" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior The symbol "begin" was substituted for "INSERT" to continue.
Error(10,1): PLS-00103: Encountered the symbol "RETURNING" when expecting one of the following: . ( ) , * % & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset
Error(11,1): PLS-00103: Encountered the symbol "END"
我缺少一些语法基础/知识吗?提前谢谢!
create or replace procedure API_SUBMISSION(rID_TX IN VARCHAR, rFORM_NAME IN VARCHAR, rDATA_DATE IN VARCHAR, v_submission_id OUT NUMBER)
IS BEGIN
DECLARE
v_submission_id number;
insert into submission (SUBMISSION_ID, RESPONDENT_ID, SUBMISSION_DT, SUBMISSION_TYPE_ID, SUBMISSION_NAME_TX, SUBMISSION_SEQ_NB, CREATE_DT, CREATE_USER_ID, MODIFY_DT, MODIFY_USER_ID, EFFECTIVE_DT, INACTIVE_DT)
VALUES (null, get__respondent_id(rID_TX, rFORM_NAME, trunc(sysdate), sysdate, rDATA_DATE || 'TEST ' || rFORM_NAME, 1, sysdate, 1, null, null, null, null)
returning submission_id into v_submission_id;
END API_SUBMISSION;
答案 0 :(得分:2)
您的手术有几个问题:
IS/AS
和BEGIN
关键字之间的隐式声明部分。在这种情况下不是你需要的。这意味着您可以将您的程序重写为:
CREATE OR REPLACE PROCEDURE api_submission(rid_tx IN VARCHAR2,
rform_name IN VARCHAR2,
rdata_date IN VARCHAR2,
v_submission_id OUT NUMBER) IS
BEGIN
INSERT INTO submission
(submission_id,
respondent_id,
submission_dt,
submission_type_id,
submission_name_tx,
submission_seq_nb,
create_dt,
create_user_id,
modify_dt,
modify_user_id,
effective_dt,
inactive_dt)
VALUES
(NULL,
get__respondent_id(reia_id_tx, rform_name),
trunc(SYSDATE),
SYSDATE,
rdata_date || 'TEST ' || rform_name,
1,
SYSDATE,
1,
NULL,
NULL,
NULL,
NULL)
RETURNING submission_id INTO v_submission_id;
END api_submission;
/