2016-08-15 88 views
-2
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; 

在此過程中可能出現什麼錯誤?Oracle中的存儲過程錯誤

程序GETSTUDENTNAME編譯

錯誤:

check compiler log

這SQL查詢也無法正常工作,並提供:

Error report - SQL Error: ORA-00936: missing expression 00936. 00000 - "missing expression" *Cause:
*Action:

+0

CREATE TABLE tbl_Students ( ID INT,fanme VARCHAR(20),L-NAME VARCHAR(20),電子郵件VARCHAR(20) ); – RAHUL

回答

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; 
+0

http://www.codeproject.com/Articles/126898/Sql-Server-How-To-Write-a-Stored-Procedure-in-SQL – RAHUL

1

更正典型os並使用正確的語法:

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; 
/
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代碼。