oracle pl / sql存储过程错误
ORA-06550:第1行,第7列:
PLS-00306:调用“ STAT_STND_TERR_PRCDRE”时参数的数量或类型错误
ORA-06550:第1行,第7列:
PL / SQL:语句被忽略
06550. 00000-“%s行,%s列:\ n%s”
CREATE OR REPLACE PROCEDURE STAT_STND_TERR_PRCDRE
(
SPATIAL_QUERY_DATE_COND IN VARCHAR2,
ITEM_LONGITUDE_NUM IN VARCHAR2,
ITEM_LATITUDE_NUM IN VARCHAR2,
STATE_ABBR OUT VARCHAR2,
TERR_CD OUT VARCHAR2,
TERR_NM OUT VARCHAR2
)
AS
v_state_abbr STAT_STND_TERR.STATE_ABBR%type;
v_terr_cd STAT_STND_TERR.TERR_CD%type;
v_terr_nm STAT_STND_TERR.TERR_NM%type;
BEGIN
SELECT T.STATE_ABBR AS STATE_ABBR, T.TERR_CD AS TERR_CD, T.TERR_NM AS TERR_NM
into v_state_abbr,v_terr_cd,v_terr_nm
FROM STAT_STND_TERR T
WHERE
T.STATE_ABBR='NY' AND
T.ORG_ABBR = 'iso' AND
T.TERR_LINE_CD = 'pveh' AND
TRUNC(T.TERR_EFF_DT) <= TO_DATE(SPATIAL_QUERY_DATE_COND,'YYYY-MM-DD') AND
TRUNC(T.TERR_EXP_DT) > TO_DATE(SPATIAL_QUERY_DATE_COND,'YYYY-MM-DD') AND
(SDO_RELATE(T.GEOM,
MDSYS.SDO_GEOMETRY(2001, 8307,
MDSYS.SDO_POINT_TYPE(ITEM_LONGITUDE_NUM,ITEM_LATITUDE_NUM,NULL),NULL,NULL),
'MASK=ANYINTERACT QUERYTYPE=WINDOW')='TRUE')
AND ROWNUM = 1;
DBMS_OUTPUT.put_line ('STATE_ABBR:'||v_state_abbr);
DBMS_OUTPUT.put_line ('TERR_CD:'||v_terr_cd);
DBMS_OUTPUT.put_line ('TERR_NM:'||v_terr_nm);
END;
/`
答案 0 :(得分:0)
您的过程的签名具有三个OUT参数。这些用于将值返回到调用程序。但是,过程的主体不会填充这些参数,而是使用DBMS_OUTPUT来显示它们。尽管如此,您仍然需要在调用代码中为这些参数分配目标变量。
让我们稍微更改一下代码:
CREATE OR REPLACE PROCEDURE STAT_STND_TERR_PRCDRE
(
SPATIAL_QUERY_DATE_COND IN VARCHAR2,
ITEM_LONGITUDE_NUM IN VARCHAR2,
ITEM_LATITUDE_NUM IN VARCHAR2,
STATE_ABBR OUT VARCHAR2,
TERR_CD OUT VARCHAR2,
TERR_NM OUT VARCHAR2
)
AS
v_state_abbr STAT_STND_TERR.STATE_ABBR%type;
v_terr_cd STAT_STND_TERR.TERR_CD%type;
v_terr_nm STAT_STND_TERR.TERR_NM%type;
BEGIN
SELECT T.STATE_ABBR AS STATE_ABBR, T.TERR_CD AS TERR_CD, T.TERR_NM AS TERR_NM
into v_state_abbr,v_terr_cd,v_terr_nm
FROM STAT_STND_TERR T
WHERE
T.STATE_ABBR='NY' AND
T.ORG_ABBR = 'iso' AND
T.TERR_LINE_CD = 'pveh' AND
TRUNC(T.TERR_EFF_DT) <= TO_DATE(SPATIAL_QUERY_DATE_COND,'YYYY-MM-DD') AND
TRUNC(T.TERR_EXP_DT) > TO_DATE(SPATIAL_QUERY_DATE_COND,'YYYY-MM-DD') AND
(SDO_RELATE(T.GEOM,
MDSYS.SDO_GEOMETRY(2001, 8307,
MDSYS.SDO_POINT_TYPE(ITEM_LONGITUDE_NUM,ITEM_LATITUDE_NUM,NULL),NULL,NULL),
'MASK=ANYINTERACT QUERYTYPE=WINDOW')='TRUE')
AND ROWNUM = 1;
-- populate the out parameters
STATE_ABBR := v_state_abbr;
TERR_CD := v_terr_cd;
TERR_NM := v_terr_nm;
END;
现在我们用匿名块来称呼它:
declare
l_state_abbr STAT_STND_TERR.STATE_ABBR%type;
l_terr_cd STAT_STND_TERR.TERR_CD%type;
l_terr_nm STAT_STND_TERR.TERR_NM%type;
begin
STAT_STND_TERR_PRCDRE
(
SPATIAL_QUERY_DATE_COND => '2019-06-01'
ITEM_LONGITUDE_NUM => '12000',
ITEM_LATITUDE_NUM => '38000',
STATE_ABBR => l_state_abbr,
TERR_CD => l_terr_cd,
TERR_NM => l_terr_nm
);
DBMS_OUTPUT.put_line ('STATE_ABBR:'|| l_state_abbr);
DBMS_OUTPUT.put_line ('TERR_CD:'|| l_terr_cd);
DBMS_OUTPUT.put_line ('TERR_NM:'|| l_terr_nm);
end;
/
因此,这里使用OUT参数的局部变量调用了该过程,并且调用程序显示了返回的值。