in Education by
I haven't been able to find this explicitly stated anywhere yet, but a bunch of examples I've found online follow what I've been doing. I have a C# class which uses ODP.net to connect to an Oracle DB and run a procedure that's in a package. My package has stored procedures which take a ref cursor output parameter. All the procedure does is open up the cursor for a particular select statement. If I execute this procedure directly on the oracle db, then eventually I'll hit a max number of open cursors error. So I was wondering if ODP.net does indeed close this cursor that was opened in my procedure? I'm using the OracleDataApaper.Fill(DataSet) method. eg. DataSet ds = new DataSet(); OracleConnection conn = new OracleConnection(this.connStr); OracleCommand com = new OracleCommand("MYPKG.MYQUERY", conn); OracleDataAdapter adapter = new OracleDataAdapter(com); conn.Open(); com.Parameters.Add("searchParam", OracleDbType.Varchar2).Value = "myName"; com.Parameters.Add("outCursor", OracleDbType.RefCursor, ParameterDirection.Output); com.CommandType = CommandType.StoredProcedure; adapter.Fill(ds); conn.Close(); PROCEDURE GETALLEMAILS(searchParamIN VARCHAR2, outCursor OUT sys_refcursor) AS BEGIN open outCursor select EAEMAL as Email from EmailTable where EmailName = searchParam; END GETALLEMAILS; I'm just afraid of leaving open cursors behind on the DB is all. If anyone can provide links to official documentation, that'd be great! Updates: Thanks for the input. I was calling com.Dispose(); conn.Close(); conn.Dispose(); but left them out of my example. I found this forum post, which states that the OracleDataAdapter.Fill(Dataset) method does release the ref cursor after the Fill() method has been executed. http://www.frontoracle.com/oracle-archive/140/386140-close-ref-cursor.html I wish the Oracle documentation was more explicit in describing this process though. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
ODP.NET requires you to clean up things. So you: have to dispose OracleParameter instances, as they contain unmanaged resources (!) and Odp.net doesn't do this have to dispose OracleCommand objects, as they too contain unmanaged resources and closing a connection doesn't close these open cursors can't live without an open connection, though in odp.net nothing gets cleaned up after a connection closes (or gets disposed), so you have to clean up these too (and before the connection closes of course). I.o.w.: clean up what you create. It can be the OracleDataAdapter already does this for you, but that's unclear (and the odp.net docs don't say this, so you've to check the (unreadable) code with reflector to make sure. Though rule of thumb with odp.net: to avoid memory leaks, always call dispose, on everything in the order: parameter, cursor, command, transaction, connection.

Related questions

0 votes
    Which of the following code opens a connection to the file foo.txt, reads from it, and closes the connection when its done? (a) data...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I'm trying to use node to print the Serial from Arduino uno connected to USB I have a file script ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    What are the components used to close a hive connection automatically in Talend?...
asked May 30, 2021 in Technology by JackTerrance
0 votes
    What component do you need to use to automatically close a Hive connection as soon as the main Job finishes execution?...
asked Mar 23, 2021 in Technology by JackTerrance
0 votes
    I don't seem to be able to close the OledbDataReader object after reading data from it. Here is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I don't seem to be able to close the OledbDataReader object after reading data from it. Here is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I don't seem to be able to close the OledbDataReader object after reading data from it. Here is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I don't seem to be able to close the OledbDataReader object after reading data from it. Here is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    While I try to answer any question in brainly app, the cursor is moving from right to left instead of moving ... Why does it happen? Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    If I use socket.makefile and then close the file object as well as the underlying socket, then subsequent ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    Does close() implicitly flush() the stream. (a) True (b) False This question was posed to me during an interview. ... JSP & API of Java Select the correct answer from above options...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    Does close() implicitly flush() the stream. (a) True (b) False This question was posed to me ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    I am getting the following error trying to read from a socket. I'm doing a readInt() on that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 30, 2022 in Education by JackTerrance
0 votes
    I am getting the following error trying to read from a socket. I'm doing a readInt() on that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    I'm having a problem with my logcat since update 1.2 Beta for Android Studio. When I run my app ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
...