文字列を返すパラメーターを使用せずに Testing という名前の単純な Oracle 関数を作成しました。.NET アプリから呼び出そうとすると、エラーが発生します。
System.Data.OracleClient.OracleException:
ORA-06550: 行 1、列 7:" "PLS-00221: 'TESTING2' はプロシージャではないか、未定義です".
「Select testing() from dual」を実行するように変更し、CommandType を Text に変更すると、機能します。私は何が欠けていますか?
Dim oracleConn As OracleConnection = CreateConnection(<connection info here>)
Dim oracleCmd As New OracleCommand()
oracleCmd.Connection = oracleConn
'oracleCmd.CommandText = "SELECT TESTING2() FROM DUAL" 'this works
oracleCmd.CommandText = "TESTING2" 'this does not work
oracleCmd.CommandType = CommandType.StoredProcedure
'oracleCmd.ExecuteReader() 'also tried this
Dim tmpVar As String = oracleCmd.ExecuteScalar()
create or replace FUNCTION testing2
RETURN VARCHAR2
AS
begin
return 'hello';
end;