存储过程+调用不起作用

时间:2018-02-20 21:57:09

标签: oracle plsql

然而,

我的存储过程编译;当我尝试调用它时,我收到以下错误:

Encountered the symbol "IS" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table long double ref
char time timestamp interval date binary national character
nchar
The symbol "IS" was ignored.
ORA-06550: line 2, column 48:
PLS-00103: Encountered the symbol "," when expecting one of the following:

:= ( ; not null range default character
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

我的存储过程如下:

create or replace procedure p_xml
(v_utc_offset in XML_HOURS_LOAD.UTCOFFSET%type
, v_data_date in XML_HOURS_LOAD.DATA_DATE%type
, v_data_type in XML_HOURS_LOAD.DATA_TYPE%type
, v_posted_value in XML_HOURS_LOAD.POSTEDVALUE%type
, v_utc_value in XML_HOURS_LOAD.UTCVALUE%type
, v_hour in XML_HOURS_LOAD.HOUR%type
, v_data_code in XML_HOURS_LOAD.DATA_CODE%type
)
AS
BEGIN
  if v_utc_offset >= 4 THEN
  INSERT INTO xml_hours_Load (UTCOffset, Data_date, Data_Type, PostedValue, UTCValue, Hour, Data_Code)
  VALUES(v_utc_offset, v_data_date, v_data_type, v_posted_value, v_utc_value, v_hour, v_data_code);  
  COMMIT;
 END IF;
END;

我如何调用它(以及返回上面列出的错误的内容)如下:

DECLARE
  v_utc_offset is XML_HOURS_LOAD.UTCOFFSET%type,
  v_data_date is XML_HOURS_LOAD.DATA_DATE%type,
  v_data_type is  XML_HOURS_LOAD.DATA_TYPE%type,
  v_posted_value is  XML_HOURS_LOAD.POSTEDVALUE%type,
  v_utc_value is  XML_HOURS_LOAD.UTCVALUE%type,
  v_hour is  XML_HOURS_LOAD.HOUR%type,
  v_data_code is XML_HOURS_LOAD.DATA_CODE%type;
CURSOR cXmlHoursLoadCursor is (SELECT utcoffset, data_date, data_type, postedvalue, utcvalue, hour, data_code
                             from xml_hours_load);
BEGIN
  FOR v in cXmlHoursLoadCursor LOOP
p_xml(v.utcoffset, v.data_date, v.data_type, v.postedvalue, v.utcvalue, v.hour, v.data_code);
COMMIT;
  END LOOP;
END;

提前致谢!

1 个答案:

答案 0 :(得分:3)

在您的匿名块中,CURSOR是您应该使用IS关键字声明的唯一变量。将其从其他人中移除。

DECLARE
  v_utc_offset XML_HOURS_LOAD.UTCOFFSET%type;
  v_data_date XML_HOURS_LOAD.DATA_DATE%type;
  v_data_type XML_HOURS_LOAD.DATA_TYPE%type;
  v_posted_value XML_HOURS_LOAD.POSTEDVALUE%type;
  v_utc_value XML_HOURS_LOAD.UTCVALUE%type;
  v_hour XML_HOURS_LOAD.HOUR%type;
  v_data_code XML_HOURS_LOAD.DATA_CODE%type;
CURSOR cXmlHoursLoadCursor is (SELECT utcoffset, data_date, data_type, postedvalue, utcvalue, hour, data_code
                         from xml_hours_load);
BEGIN
  FOR v in cXmlHoursLoadCursor LOOP
p_xml(v.utcoffset, v.data_date, v.data_type, v.postedvalue, v.utcvalue, v.hour, v.data_code);
COMMIT;
  END LOOP;
END;