I am executing Pl/Sql block using OLEDB in C#. The code is:
string a1;
a1 = discom1.Text.ToString();
my_querry10 = "BEGIN"+
"SELECT * from MasterCompliant WHERE Discom ='" + a1 + "';"+
"" + var1 + " = SQL%ROWCOUNT;"+
"END;";
OleDbCommand cmd12 = new OleDbCommand(my_querry10, conn);
conn.Open();
cmd12.ExecuteNonQuery();
The exception is coming to statement:
"cmd12.ExecuteNonQuery" as "Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'."
MasterCompliant is table name; Discom is column name and var1 is integer.
BEGINSTART- not a great starting point. You're also putting your parameters directly into your SQL string, which is a really bad idea. Use parameterized SQL instead. Do you really need to execute a block instead of just one command? It's not clear what you're trying to achieve here.SELECTstatement where you should open a cursor. Furthermore, you're attempting to assignSQL%ROWCOUNTto C# variablevar1from inside a PL/SQL block - this won't work as PL/SQL has no knowledge of your C# (or VB or whatever) variables. (And - use the assignment operator:=). Please - have a look at this question which shows HOW to get values back from an anonymous block. Best of luck.