问题
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