我想从 c# 执行 oracle 函数。我使用oracle 数据访问OracleConnection 和OracleCommand。我的功能是;
create or replace
FUNCTION Fnc_Sistem(Tbl VarChar2) RETURN Number IS
Sistem Number := -1;
C Integer;
S Integer;
BEGIN
C := Dbms_sql.open_cursor;
Dbms_sql.parse(C, 'Select Sistem_Kodu From '||Tbl ||' Where Referans = 1', 0);
Dbms_sql.define_column(C, 1, Sistem);
S := dbms_sql.execute(C);
Loop
If Dbms_sql.fetch_rows(C) > 0 then
Dbms_sql.Column_value(C, 1, Sistem);
End If;
Exit;
End Loop;
Dbms_sql.close_cursor(C);
Return (Sistem);
Exception
when others then
If dbms_sql.is_open(C) then
dbms_sql.close_cursor(C);
Return (-1);
end if;
Return (-1);
Raise;
End;