简体   繁体   English

Oracle错误:无效的SQL语句错误

[英]Oracle ERROR : INVALID SQL STATEMENT ERROR

I have maked an stored procedure but I cannot execute the stored procedure I dont know what the problem is. 我做了一个存储过程,但是我无法执行该存储过程,我不知道问题出在哪里。

Source code: 源代码:

Create or replace procedure land_naam(klantnummer_input in VARCHAR2
, verzendland_output out VARCHAR2)

AS 

BEGIN

SELECT land into verzendland_output from klanten 

WHERE klantnummer = klantnummer_input;

END land_naam;

First I create the procedure without any error. 首先,我创建过程没有任何错误。

Then if I want to execute it I run the code 然后,如果我想执行它,则运行代码

Execute land_naam;

after that I get the error : 之后,我得到错误:

ORA-00900: invalid SQL statement ORA-00900:无效的SQL语句

What can i do to solve this problem? 我该怎么做才能解决这个问题? The procedure The error statement 程序 错误声明

Modify your code to something like this: 修改您的代码,如下所示:

Create or replace procedure land_naam(klantnummer_input in VARCHAR2)
AS 
verzendland_output VARCHAR2(2000);
BEGIN
SELECT land into verzendland_output from klanten 
WHERE klantnummer = klantnummer_input;
END land_naam;

When executing the procedure, since you have an input parameter, provide one. 执行该过程时,由于您有输入参数,请提供一个。

e.g. EXECUTE land_naam('S');

As your procedure is specifying both an input and an output parameter, you'll have to specify those when calling your procedure: 由于过程同时指定了输入和输出参数,因此在调用过程时必须指定这些参数:

To declare a variable in SQLPlus that will hold the output, simple use 在SQLPlus中声明一个将保存输出的变量,简单易用

SQL> var out varchar2(100)

Then call the stored procedure with an input and output parameter (otherwise you're not specifying the correct number of parameters) 然后使用输入和输出参数调用存储过程(否则,您没有指定正确数量的参数)

SQL> exec land_naam('yourinput', :out)

Finally, print out the contents of your output variable 最后,输出输出变量的内容

SQL> print out

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM