在pl/sql过程中声明变量时出现语法错误 [英] syntax error when declaring variables in a pl/sql procedure

查看:175
本文介绍了在pl/sql过程中声明变量时出现语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我有点生气.我正在尝试将变量添加到过程中,但是它不起作用-我刚收到以下错误消息:

This is sending me a bit mad. I'm trying to add in a variable to a procedure, but it wasn't working - I just got this error message:

[错误]语法检查(25:7):错误第25行,第7行,结束行25, Ending_col 12,找到'数字',期望:; -或-..:=默认 非空-或-%-或-(.@

[Error] Syntax check (25: 7): ERROR line 25, col 7, ending_line 25, ending_col 12, Found 'number', Expecting: ; -or- .. := DEFAULT NOT NULL -or- % -or- ( . @

我在下面敲出了一个非常基本的过程来隔离问题,现在我完全陷入了困境,因为我看过的每个基本语法指南都说了要做的事情.为什么我不能如下所示声明变量?我通常会在SQL Server中编写代码,以获取有关我的问题的任何线索.非常感谢任何人的帮助!

I knocked up a really basic procedure below to isolate the problem and now I'm completely stuck, as every basic syntax guide I've looked as says to do what I've done. Why can't i declare variables as shown below? I normally code in SQL Server if that's any clue as to my problem. Many thanks if anyone can help!

CREATE OR REPLACE PROCEDURE MRCS.pro_xxx_test1 (cats out sys_refcursor)
IS

declare

spoon number;

balls varchar2(3);

BEGIN

 open cats for select * from dual;

   end;

/

推荐答案

删除"DECLARE".函数/过程声明中不需要

Remove the "DECLARE". Not needed in a function / procedure declaration

这篇关于在pl/sql过程中声明变量时出现语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆