如果您尚未修改默認的 HR 安裝
Rows affected:
訪問返回值
RETURN 語句立即將控制從存儲過程返回到調用程序
Oracle 函數是計算並返回單個值的子程序
下面是一個返回指定員工的電子郵件的函數
CREATE OR new FUNCTION GET_EMPLOYEE_EMAIL (
p_employee_id NUMBER
)
RETURN VARCHAR
IS p_email VARCHAR
BEGIN
SELECT EMAIL INTO p_email FROM EMPLOYEES
WHERE EMPLOYEE_ID = p_employee_id;
RETURN p_email;
END GET_EMPLOYEE_EMAIL;
執行函數的方式與執行存儲過程的方式相同
// create the connection
OracleConnection conn = new OracleConnection(
User Id=UserID;Password=Password;
// create the command for the function
OracleCommand cmd = new OracleCommand();
cmd
cmd
cmd
// add the parameters
// the return value
cmd
cmd
ParameterDirection
// execute the function
conn
cmd
conn
// output the result
Console
[
From:http://tw.wingwit.com/Article/program/net/201311/15009.html