下面是我的代碼給出如下。我試圖添加5個參數,該函數將這些參數放入Employee表中。但我沒有成功,做了很多事情。Oracle中的存儲函數無法將值插入所需的表
錯誤
ORA-01858: a non-numeric character was found where a numeric was expected ORA-06512: at "xxxxxxx.A1SF_ADDEMP", line 14 01858. 00000 - "a non-numeric character was found where a numeric was expected" *Cause: The input data to be converted using a date format model was incorrect. The input data did not contain a number where a number was required by the format model. *Action: Fix the input data or the date format model to make sure the elements match in number and type. Then retry the operation.
加上我怎麼測試存儲功能具有插入/更新或刪除它的聲明?
執行語句
Select A1SF_ADDEMP('Adesh', '33', 'M', 8000, '26/03/1990')
From dual;
代碼
CREATE OR REPLACE Function A1SF_ADDEMP
(pEmpName In Varchar2,
pTaxFileNo In Varchar2,
pGender In Varchar2,
pSalary In Number,
pBirthdate In Varchar2
) Return Varchar2
Is
tEmpId Number(38,0);
tBirthDate Date;
BEGIN
tEmpId := A1Seq_Emp.nextval;
tBirthdate := to_date('pBirthdate','dd/mm/yyyy');
Insert Into Employee(EmpId, EmpName, TaxFileNo, Gender, Salary, Birthdate)
Values (tEmpId, pEmpName, pTaxFileNo, pGender, pSalary, tBirthdate);
Commit;
Return null;
END;
我將如何執行上述功能牢記DML語句是否必須使用遊標或其他? – 2012-03-24 13:26:29
@ extinguisher33,正如我在我的回答中解釋的那樣,你必須將它包裝在PL/SQL塊中;但我會將它轉化爲一個程序。 – Ben 2012-03-24 13:27:40
程序事情我知道的原因我已經學習了SQL Server,但我非常感興趣知道如何調用,在Sql開發人員上測試此函數,以及如何從Visual Studio調用它) – 2012-03-24 13:29:30