急!急!急!请问如何在Oracle通过C#创建新的存储过程(不是调用)
我要通过在C#中在Oracle中创建一个新的存储过程。存储过程如下:CREATE OR REPLACE PROCEDURE version_table
(super in VARCHAR2,
name in varchar2,
bspatial in boolean)
IS
obj_id INTEGER;
vs_id integer;
str varchar2(256);
BEGIN
str := 'select object_class_id from ' || super || '.geostar_object_classes$ where table_name=upper(''' || name || ''')';
execute immediate str into obj_id;
if ..... then
begin
end;
end if;
commit;
END;
现在通过
OracleCommand pOraComm = new OracleCommand();
pOraComm.Connection = pOracleConn;
pOraComm.CommandText = strSQL;
pOraComm.CommandType = CommandType.Text;
pOraComm.ExecuteNonQuery();
不能建立。请问如何解决啊? --------------------编程问答-------------------- pOracleConn打开了吗?
pOraComm.ExecuteNonQuery();
这句执行成功了没有? --------------------编程问答--------------------
肯定是打开了!而且执行成功了! --------------------编程问答-------------------- 现在通过
OracleCommand pOraComm = new OracleCommand();
pOraComm.Connection = pOracleConn;
pOraComm.CommandText = strSQL;
pOraComm.CommandType = CommandType.Text;
pOraComm.ExecuteNonQuery();
不能建立。请问如何解决啊?
strSQL是什么?是创建存储过程的sql语句吗? --------------------编程问答-------------------- 可以尝试一下就创建存储过程的sql语句用OracleCommand 来执行一下。 --------------------编程问答-------------------- 可以尝试一下就创建存储过程的sql语句用OracleCommand 来执行一下。 --------------------编程问答--------------------
OracleConnection cmicCn = new OracleConnection(pOracleConn);
cmicCn.Open();
string strSQL = "create proc ProcEmployees " +
" as " +
" select * from Employees ";
OracleCommand cmicCmd = new OracleCommand(strSQL, cmicCn);
cmicCmd.ExecuteNonQuery();
试试这个。。 --------------------编程问答-------------------- 创建存储过程:
GetProduct.cs:
view source
print?
01.using System;
02.using System.Data;
03.using System.Data.SqlClient;
04.using System.Data.SqlTypes;
05.using Microsoft.SqlServer.Server;
06.
07.
08.public partial class StoredProcedures
09.{
10. [Microsoft.SqlServer.Server.SqlProcedure]
11. public static void GetProduct(int id)
12. {
13. //使用调用该存储过程的客户端打开的连接
14. SqlConnection conn = new SqlConnection("Context Connection=true");
15. conn.Open();
16. SqlCommand cmd = new SqlCommand();
17. cmd.Connection = conn;
18. cmd.CommandText = "Select ProductID, ProductName, CategoryID, Quantity FROM Products Where ProductID = @ID";
19. cmd.Parameters.Add("@ID", SqlDbType.Int, 0);
20. cmd.Parameters["@ID"].Value = id;
21.
22. SqlDataReader reader = cmd.ExecuteReader();
23. SqlPipe pipe = SqlContext.Pipe;
24. //将读取器返回给客户端
25. pipe.Send(reader);
26. }
27.};
补充:.NET技术 , C#