Oracle中的存储过程错误

时间:2016-08-15 10:41:41

标签: sql oracle stored-procedures

create or replace PROCEDURE Getstudentname(
    @firstname varchar(20),
    @lastname varchar (20),
    @e_mail varchar(20)
)
as
begin
    insert into TBL_STUDENTS(fanme, lname, email)
    values(@firstname, @lastname, @e_mail);
end;

此程序中的错误是什么?

程序GETSTUDENTNAME编译

错误:

  

检查编译器日志

这个SQL查询也没有给出:

  

错误报告 - SQL错误:ORA-00936:缺少表达式   00936. 00000 - "缺少表达"   *原因:
  *操作:

3 个答案:

答案 0 :(得分:2)

Oracle不会将@用于参数。我强烈建议您在它们前面加上一些东西,以区别于列名。像这样:

create or replace PROCEDURE Getstudentname (
    in_firstname varchar2,
    in_lastname varchar2,
    in_e_mail varchar2
)
as
begin
    insert into tbl_students(fname, lname, email)
         values(in_firstname, in_lastname, in_e_mail);
end;

此外,Oracle不需要字符串参数的长度,varchar2是标准变量字符串类型。您的代码看起来更像是SQL Server代码,而不是Oracle代码。

答案 1 :(得分:1)

试试这个

create or replace PROCEDURE Getstudentname(
firstname in varchar2,
lastname in varchar2,
e_mail in varchar2
)
as
begin
insert into TBL_STUDENTS(fanme,lname,email)values(firstname,lastname,e_mail);
end;

答案 2 :(得分:1)

更正拼写错误并使用正确的语法:

CREATE TABLE tbl_Students
( id int, Fname varchar(20), Lname varchar(20),Email varchar(20) );


create or replace PROCEDURE Getstudentname(
  firstname in tbl_students.fname%TYPE,
  lastname in tbl_students.lname%TYPE,
  e_mail in tbl_students.email%TYPE
)
as
begin
  insert into TBL_STUDENTS (fname,lname,email) values (firstname,lastname,e_mail );
end;
/