HI All,
I know that there are two types of cursors. Implicit and Explicit cursors. But in some places I read there were more than 2, actually 5. So what are they. And this interview question has been a mystery and where this search has all started: - Delete from emp wher e emp_id >1000;
Which one of the following types of cursors do you use to execute this DML statement in the above sample code?
Explicit, Implicit, Static, Dynamic and Referenced
As per my knowledge a cursor is a temp buffer to load data into other variables or loop through this buffer and work on the data. But what is a cursor got to do with a DML statement?
Thanks in advance,
Aj
4 9685 @eeriehunk
DMLs like INSERT,UPDATE,DELETE,SELECT INTO have implicit cursor associated with them by default.
Update and delete operation have the Implicit cursor associted with them to point the set of Rows getting affected by the opeartion and Insert opeartion need the implicit cursor in order to hold the data for insertion.
All these opration make use of implicit cursor by default unless the Explicit Cursor are defined for them.
I hope , I cleared you doubt.
Thanks!
Explicit Cursor - used for the select statements
Referenced Cursor - Used when you need to send the set of records as an output to the calling side. This cursor used as out parameter in procedures
Static/Dynamic Cursor - Used mainly for SELECT statements
Implicit Cursor - Created implicitly for any DML operaition within a procedure. They are created Implicitly and you need not seperately create a cursor for DML statements
Hi Guys,
Thanks for your replies, and it’s clear that DML statements use Implicit Cursors implicitly. But what’s still confusing is, why does the question says.. "What cursors do you use to execute this DML statement ". If it’s implicit, we don’t have to USE anything to execute it? Unless this a wrongly phrased question. If it is, kindly ignore it and I appreciate your replies.
Regards,
Aj
@eeriehunk
Your interpretation is correct, in that one could/may read too much into the question.
The simpler way to have worded that, as the above have already answer 'what cursors to you use' is when using a DML statement, indicate which type of cursor is used. That is, implicit and other indicators mentioned. The inclussion of the word 'use' makes one believe they are having to EXPLICITLY indicate the cursor, which as you have been shown, is not necessary. It is a 'trick' question if one want to go that route.
r
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tim Williams |
last post by:
I'm trying to write a simple python program to access a MySQL
database. I'm having a problem with using MySQLdb to get the results
of a SQL command in a cursor. Sometimes the cursor.execute works,...
|
by: William Gill |
last post by:
I have been trying to pass parameters as indicated in the api.
when I use:
sql= 'select * from %s where cusid = %s ' % name,recID)
Cursor.execute(sql)
it works fine, but when I try :
sql=...
|
by: mrstephengross |
last post by:
I'd like to do some basic SQL stuff in Python. It seems like there are
a heck of a lot of SQL modules for Python. What's the simplest and
easiest one to use?
Thanks,
--Steve...
|
by: klalonde |
last post by:
I was researching opinions on using cursors in stored procedures and found a thread http://www.thescripts.com/forum/thread143091.html discussing (generally) why not to use them.
I took a...
|
by: johnlichtenstein |
last post by:
I am using cx_Oracle and MySQLdb to pull a lot of data from some tables
and I find that the cursor.execute method uses a lot of memory that
never gets garbage collected. Using fetchmany instead of...
|
by: Florian Lindner |
last post by:
Hello,
I have a function that executes a SQL statement with MySQLdb:
def executeSQL(sql, *args):
print sql % args
cursor = conn.cursor()
cursor.execute(sql, args)
cursor.close()
it's...
|
by: Florian Lindner |
last post by:
Hello,
I have a string:
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`,
`gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s)
that is passed to a MySQL cursor from MySQLdb:...
|
by: Charles V. |
last post by:
Hi,
I hope this is not already known. But Google wasn't any help. So here begins a
script to explain my problem.
-------------------------
import sqlite3
conn = sqlite3.connect(':memory:')...
|
by: Michiel Overtoom |
last post by:
Charles V. wrote:
Maybe introduce a second cursor?
import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
d = conn.cursor() # second cursor
c.execute('''create table stocks
|
by: vituko |
last post by:
plpgsql (postgresql 8.3 but I can upgrade)
I can open a cursor with a dynamic query (table / column variable) :
-open cursor for execute '...' ;
But if I want do updates...
- execute 'update...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |