存储过程在oracle 11g中

时间:2017-05-08 16:59:53

标签: sql oracle stored-procedures plsql

create procedure p5(age1 IN number) as
     BEGIN
     if age1>18 then 
         insert into t values ( age1 );
     else
         dbms_output.putline('age should be high');
     end if;
end p5;
  

警告:使用编译错误创建过程。

我已尝试执行此操作,但我收到的错误列在下面

SQL> exec p5(20);
BEGIN p5(20); END;
     *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object SYSTEM.P5 is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

我仍然遇到这些错误

3 个答案:

答案 0 :(得分:1)

存在多个问题,

create or replace procedure p3(age1 IN number) as --you dont need (3) here. Also closing braces are missing.
     BEGIN
     if age1>18 then 
         insert into t values ( age1 );
     else
         dbms_output.put_line('age should be high'); --you were using putline.
     end if;
end p3;  --your proc name is p2 but you are endin p3. Not needed. Just END will also do.

我尝试在本地运行它并且工作正常。

create table t (age number(3));
  

表T已创建。

create procedure p3(age1 IN number) as 
 BEGIN
 if age1>18 then 
     insert into t values ( age1 );
 else
     dbms_output.put_line('age should be high');
 end if;
end p3;
  

程序P3编译

set serveroutput on;

exec p3(23);
  

PL / SQL程序已成功完成。

exec p3(17);
  

PL / SQL程序已成功完成。

     

年龄应该很高

select * from t;

AGE
23

答案 1 :(得分:1)

错误在于:

dbms_output.put_line

而不是

dbms_output.putline

答案 2 :(得分:0)

你错过了 p3(age1 IN number(3))后的右括号。试试以下:

private static IFormBuilder<T> CreateCustomForm<T>() where T : class
{
    var form = new FormBuilder<T>();
    var templateAttribute = form.Configuration.Template(TemplateUsage.Navigation);
    var patterns = templateAttribute.Patterns;
    patterns[0] = "My prompt";
    templateAttribute.Patterns = patterns;

    return form;
}