2015-06-22 109 views
-2

我正在嘗試爲Oracle的第一個存儲過程,因爲我之前的插入語句不工作。我收到了幾個小時在Google上搜索的這些奇怪的錯誤,似乎沒有人糾正我的具體問題。Oracle存儲過程運行錯誤

我只是希望能夠添加記錄:/

我的代碼如下:

CREATE OR REPLACE Insert_classifieds 
(val_date IN  TABLENAME.Addate%type, 
    val_category IN  TABLENAME.Category%type, 
    val_user IN  TABLENAME.Username%type, 
    val_ phone IN  TABLENAME.Phonenbr%type, 
    val_email IN  TABLENAME.Email%type, 
    val_shortDes IN  TABLENAME.Description%type, 
    val_longDes IN  TABLENAME.Fulldescription%type , 
    val_newstandardid out TABLENAME.Classid%type 
) 
as num_standardid number; 
begin 
    select t_class_seq.nextval into num_standardid from dual; 

    INSERT INTO TABLENAME (Classid, Addate, Category, Username, Phonenbr, Email, Description, Fulldescription) 
    VALUES (num_standardid, val_date, val_category, val_user, val_phone, val_email, val_shortDes, val_longDes); 

    commit; 
    val_newstandardid := num_standardid; 
end; 
+0

谷歌搜索是值得欽佩的,但是當涉及到語法錯誤您的第一個停靠港應始終[Oracle文檔(http://docs.oracle.com/database/121/ LNPLS/create_procedure.htm#LNPLS01373) – APC

回答

0

所以我的問題是val_phone有一個空間和一些修正。

決賽:

CREATE OR REPLACE PROCEDURE Insert_classifieds 
(val_date  TABLENAME.Addate%type, 
    val_category   TABLENAME.Category%type, 
    val_user  TABLENAME.Username%type, 
    val_phone  TABLENAME.phonenbr%type, 
    val_email   TABLENAME.Email%type, 
    val_shortDes  TABLENAME.Description%type, 
    val_longDes  TABLENAME.Fulldescription%type) 

as num_classid number; 

begin 

select t_class_seq.nextval into num_classid from dual; 

INSERT INTO TABLENAME (Classid, Addate, Category, Username, Phonenbr, Email, Description, Fulldescription) 
    values (num_classid, val_date, val_category, val_user, val_phone, val_email, val_shortDes, val_longDes); 

commit; 

end; 
4

如果你想創建一個過程,語法是(你失蹤了「 PROCEDURE「關鍵字): CREATE OR REPLACE PROCEDURE Insert_classifieds

+0

在我對代碼進行的所有編輯中,我必須刪除它們。它現在改變我的錯誤,說明我的行使用'.nextval'具有'編譯成功',我'價值'行有錯誤'列不允許在這裏'和我最後2代碼行是'無效的SQL語句'哈哈。沒完沒了!大聲笑 – narue1992