Pass Datatable from C# to Oracle Stored procedure

拥有回忆 提交于 2019-12-08 13:37:33

问题


How to pass a datatable or dataset from C# to the stored procedure in Oracle


回答1:


You can not directly. However there are several approaches :

  • Transform your datatable/dataset to a single XML string or blob and use it as a parameter for a stored procedure.

  • Use temporary tables to store your datatable/dataset content, so a stored procedure can process them.




回答2:


If you have a dataset or a datatable that you want to insert into ORACLE, you can create an ORACLE data adapter. Then you create a command object for insertion, and set the CommandType to StoredProcedure. You can then use the Update command of the data adapter, and have the dataset or datatable as parameter.

Something like this:

OracleCommand cmdOra = new OracleCommand(StoredProcedureName, Connection);
cmdOra.CommandType = CommandType.StoredProcedure;
OracleDataAdapter da = new OracleDataAdapter();

da.InsertCommand = cmdOra;
da.Update(dsDataSet);



回答3:


Not sure what your trying to do entirely, though using Ref Cusors in Oracle may help with whatever you may be doing. PL/SQL REF CURSOR and OracleRefCursor

Another way to accomplish passing lots of data to Oracle is through array binding: Put Your Arrays in a Bind



来源:https://stackoverflow.com/questions/5547733/pass-datatable-from-c-sharp-to-oracle-stored-procedure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!