Coder Social home page Coder Social logo

Comments (7)

kubo avatar kubo commented on July 18, 2024

It depends on DBMS (Oracle, MySQL, etc.) and the programming language.
As for ruby-oci8, cursor.exec() sends the SQL statement in the ruby-side cursor to the database server, then the database server creates a server-side cursor implicitly when the statement is select.

from ruby-oci8.

ShisiJu avatar ShisiJu commented on July 18, 2024

Thanks for your reply.

So you mean ruby-oci8 do not explicitly declare a cursor when the statement is select.

From docs.oracle sql_cursor, I saw

An implicit cursor has attributes that return information about the most recently run SELECT or DML statement that is not associated with a named cursor.

But I am still confused. Implicit cursors how to return the database cursor from the DBMS to the ruby code?

Does the implicit cursors will automatically open, fetch and close?

from ruby-oci8.

kubo avatar kubo commented on July 18, 2024

So you mean ruby-oci8 do not explicitly declare a cursor when the statement is select.

Correct.

Implicit cursors how to return the database cursor from the DBMS to the ruby code?

Implicit cursors and explicit cursors are concept specific to the PL/SQL language.
Oracle database engine itself doesn't have such concept.
For example, PL/SQL explicit cursors must have names. However the database engine
doesn't know the names. I guess that the name is used only to tie the PL/SQL explicit
cursor and a reference to the cursor in the database engine. As for implicit cursor,
I guess that PL/SQL internally has a reference to the cursor in the database engine.

Does the implicit cursors will automatically open, fetch and close?

Ruby-oci8 uses Oracle Call Interface (OCI).

  • The OCI function OCIStmtPrepare2 creates a statement handle.
  • OCIStmtExecute sends the SQL statement and ties the statement handle and a reference to the opened cursor in the database engine.
  • OCIStmtFetch fetches rows.
  • OCIStmtRelease frees the statement handle though OCI doesn't close the cursor in the database side immediately. It is closed at the next network round trip to the database.

from ruby-oci8.

ShisiJu avatar ShisiJu commented on July 18, 2024

Thanks!
I will try to search more information from oracle oci.
Hope to get the key information.

from ruby-oci8.

kubo avatar kubo commented on July 18, 2024

What I wrote in #239 (comment) is not documented in the OCI manual. I checked it by network capture. I have made a prototype of Oracle network protocol decoder more than a decade ago.
The OCI manual explains how to use OCI functions, not their internal behavior.

from ruby-oci8.

ShisiJu avatar ShisiJu commented on July 18, 2024

So that is it.
Maybe need to deep into Oralce, then it will be clear.
There are so many things to learn. It is a cheering thing.

I closed the issue. Because the issue is related to Oracle, not ruby-oci8.
I will be back, if I find the answer.

Thanks for your patience again.

from ruby-oci8.

ShisiJu avatar ShisiJu commented on July 18, 2024

https://docs.oracle.com/cd/E11882_01/server.112/e40540/sqllangu.htm#CNCPT1741

When an application issues a SQL statement, the application makes a parse call to the database to prepare the statement for execution. The parse call opens or creates a cursor, which is a handle for the session-specific private SQL area that holds a parsed SQL statement and other processing information. The cursor and private SQL area are in the PGA.

from ruby-oci8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.