Wiki Home

Sql Cursor


Namespace: VFP
Can someone please give me the definition on SQLCursor ? VFP-help assumes everybody knows this already. Well, I don't. -- Peter Stordiau

SQL Cursor is not an exact term. There are 2 definitions:

1. It is a result cursor created by the SELECT ... INTO CURSOR command. It is a read-only cursor. Usually it is a temporary table on the disk with unique name that disappears as soon as all aliases of it are closed. You can make it changeable using USE (DBF('ResultAlias')) AGAIN command. It is available for changes by ALTER TABLE command.

The temporary table may or may not exist on disk. If there is enough memory available for the table, it will be completely stored in RAM. Also, under VFP7 you can SELECT blah FROM blahblah INTO CURSOR Result READWRITE to make the cursor updateable. -- Craig Berntson

2. It is a result set returned by the SQLEXEC() or SQLMORERESULT() functions after query through ODBC from the remote database. Returned cursor have all properties of the remote view except the database. You can change it. In the MSDN there is also an article that explains how to make this cursor updatable like Remote View. You cannot alter the structure of this cursor.

-- Vlad Grynchyshyn
Looked at all the Help containing "cursor" again;
Having this all on one pile now, I myself come to the following :

A Cursor is a representative of (a part of) one or more Tables and is never any originating Table itself; Most of the time a Cursor is referred to as a phenomenon indicating a Result from any SQL Selection, but in other cases a Cursor is explicitly there - or by being a visible phenomenon (CREATE CURSOR) or implied by a more implicit action (SQL SELECT ... INTO CURSOR). In all cases a Cursor implies a physical native Table, which in most occasions is temporary an which may not even be visible on disk, but which can be made explicitly permanent under certain circumstances and after closing - be opened again. In other occasions a Cursor may be ment permanent from the beginning (CREATE SQL VIEW).
In any situation a Cursor should be read as - and treated as a representative of other data, and is therefore redundant (which does not say it isn't useful).

Anyone disagreeing on this ?

How does "SELECT INTO CURSOR" implicitly create a cursor? Sounds rather explicit to me. A cursor is nothing more than a two dimensional set of data. In VFP cursors are created by CREATE CURSOR, USEing a DBF file, or a SQL statement. -- Mike Helland

Okay, if you like to name this implicitly ...(BTW I sayd *more* implicit {g}). Of course you're right that it is explicit since this option (INTO CURSOR) may not be used or may. However, CREATE CURSOR is more explicit and ... I don't know what it's for. Earlier today I pasted a number of A4 of VFP-Helplines on "cursor"topics which all contradict. I can paste them into here to proove this, but why ? I anticipated on you all already know where I just can't find the truth in here (VFP Help). The "nothing more than a two dimensional set of data" seems useful, but the USE ? So sure, you may be right (and probably will be), but it leaves the unknown with nothing on finding out what to choose as a concept. Thus :
If I create a View I might call this the implicit creation of a cursor if it is one, though of course I do this explicitly; I don't want let anyone triple over words used, but for now I do myself; Please ask for Search in VFP Help on "cursor", and look what it brings you.
Let make it exact.

View is a cursor query template - it is not a cursor in the database.

USE command opens the table as ALIAS, not the cursor.

In VFP, cursor is a subset of the data queried from the main data, as already mentioned. So it could be only a cursor created by CREATE CURSOR commnad, result of SELECT statement or result of SQLEXEC command.

-- Vlad Grynchyshyn

VFP Trivia: CURSOR stands for CURrent Set Of Records -- Jon Goad
Category Data
( Topic last updated: 2007.11.14 05:55:13 PM )