ORA-01000: maximum open cursors exceeded goracle

I have a service that runs a stack. For this, it performs the reading of this stack through a query in Oracle. It turns out that after hours of execution I get the message:

ORA-01000: maximum open cursors exceeded

I wonder what may be going on. I have a global variable that opens the connection and I always check its connection and copy it to the local variable.

In Rows.Next () from what I read, when he checks that there are no more lines he closes the cursor, so I couldn’t have accumulated so many cursors to exceed the limit.

Connection to the bank:

 type GERENCIACON struct {
DataBase *sql.DB


if gc.DataBase == nil || gc.DataBase.Ping() != nil {	
	gc.DataBase, _ = sql.Open("goracle", "X/X@")

var VGGerenciaConexao GERENCIACON

Struct for consultation:

  type GERENCIACONSULTA struct {
DataBase *sql.DB
Rows *sql.Rows

gc.DataBase = VGGerenciaConexao.DataBase
gc.Rows, _ = gc.DataBase.Query(pSql)

Service fetching the stack:

   var vGerenciaConsulta CertanoLabsPackage.GERENCIACONSULTA
   var vSQL string

  for {
    	vSQL = "select * from stack "	


          for vGerenciaConsulta.Rows.Next() {


What could be happening?

It is possible that an error occurred during the call to vGerenciaConsulta.Rows.Next() causing it to return false and exit the loop. In this case, Close() is not automatically called.

1 Like

Move opening and closing of database connections out of loops.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.