[英]How to use PL/SQL with pure C#?
我詳細說明了這小段代碼,以開始我的小步驟。 連接很好。 簡單的OdbcDataReader
選擇工作正常。 但是我無法測試任何PL / SQL函數。 它是如何工作的 ? 我需要額外安裝一些東西還是做錯了什么?
using System;
using System.Data.Odbc;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string connectionString = "dsn=TEST;uid=read;pwd=___";
OdbcConnection con = new OdbcConnection(connectionString);
con.Open();
try
{
OdbcCommand cmd = new OdbcCommand("begin end;", con);
int result = cmd.ExecuteNonQuery();
cmd.Dispose();
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
con.Close();
con.Dispose();
Console.ReadKey();
}
}
}
PL / SQL程序顯然是:
begin
end;
錯誤消息如下:
System.Data.Odbc.OdbcException (0x80131937): ERROR [HY000] [Oracle][ODBC][Ora]OR
A-06550: line 1, column 7:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
begin declare exit for goto if loop mod null pragma raise
return select update while <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall
<a single-quoted SQL string>
我認為您的錯誤是在PL / SQL方面而不是c#代碼方面。
這是無效的,因為在begin
和end
之間需要一個語句:
begin end;
這是無效的,因為它包含一個語句,盡管它為null;
:
begin null; end;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.