这是我的密码:
--this section creates/replaces the C_PND Procedure
--and passes 2variables
create or replace PROCEDURE C_PND
(
p_whse in varchar2,
p_RC OUT INT
)
--No clue what we're doing here as there is no DECLARE
as
cv SYS_REFCURSOR; -- cursor variable
v_pull_zone locn_hdr.pull_zone%TYPE;
v_active varchar2(1);
v_low_wm number(3);
v_high_wm number(3);
v_lock_code resv_locn_hdr.locn_putaway_lock%TYPE;
--initializes this variable
BEGIN
p_RC := 0;
--setting values of the the CV
OPEN cv FOR
select code_id,
nvl(trim(substr(sc.misc_flags,1,1)),'N') v_active,
nvl(trim(substr(sc.misc_flags,2,3)),'100') high_wm,
nvl(trim(substr(sc.misc_flags,5,3)),'0') low_wm,
trim(substr(sc.misc_flags,8,2)) lock_code
from sys_code sc
where sc.rec_type = 'C'
and sc.code_type = 'PND';
--inputting the CV into these variables
LOOP
FETCH cv INTO v_pull_zone, v_active, v_high_wm, v_low_wm, v_lock_code;
EXIT WHEN cv%NOTFOUND;
............
............
............我想我理解其中的大部分内容,但我的问题是在as之后的五行(代码片段的第6-11行)。我的印象是,无论何时在PL SQL中使用变量,都必须声明变量。即使您正在使用游标变量。
难道我就是错了吗?或者不需要声明与CVs一起使用的变量?我还包括了一些注释(以--开头),这些注释显示了我认为SQL正在做什么。
发布于 2015-09-29 20:03:49
你说得对。您必须使用匿名块中的声明来声明变量,如下所示:
DECLARE
...
BEGIN
...
END;您的代码是一个过程,声明在
CREATE OR REPLACE xxx as
(implicit DECLARE)
BEGIN
...
END;https://stackoverflow.com/questions/32852773
复制相似问题