THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.

 Documentation /  Database Access Kit /  User's Guide /  Appendices /

Structuring Text FilesData Types

Appendix C: Cursors and Asynchronous Execution

If you want to go through the commands in this section, then you must first complete Section 2.1.

Cursors are in this package for two reasons. First, they allow result sets can be returned a single row at a time. You may want to do this if you have large result sets or result sets that require a lot of memory, or if you want to deal with one row at a time. Second, you may want to have multiple queries running at once. Three functions are provided for dealing with cursors: DataSourceCursorOpen to open a cursor, DataSourceCursorNext to retrieve the next row of a result set, and DataSourceCursorClose to close a cursor.

Cursor functions.

In[1]:=

Out[2]=

DataSourceCursorOpen takes two arguments, a data source object and a string. In this example SQLSelect returns a string. A cursor is opened and given the variable name query.

In[3]:=

Out[3]=

Now, the cursor can be used to retreive data from dbselect with DataSourceCursorNext.

In[4]:=

Out[4]=

Continue using DataSourceCursorNext until an empty list is returned.

In[5]:=

Out[5]=

In[6]:=

Out[6]=

In[7]:=

Out[7]=

If you continue executing the above statement, an empty list will be returned every time. A cursor cannot be reset; the command must be executed again with DataSourceCursorOpen. Also, you should remember to always close a cursor when you are finished with it. Use the DataSourceCursorClose function to accomplish this. If you do not close cursors, then you are wasting memory.

In[8]:=

Out[8]=

The options that DataSourceCursorOpen takes are exactly the same as DataSourceEvaluate. Here is an example of using ShowDimensions with DataSourceCursorOpen.

In[9]:=

Out[9]=

In[10]:=

Out[10]=

In[11]:=

Out[11]=

In[12]:=

Out[12]=

Here is an example of using two cursors at once. It's possible to have more open cursors.

In[13]:=

Out[13]=

In[14]:=

Out[14]=

Now, you can query the two open cursors in whichever order you want.

In[15]:=

Out[15]=

In[16]:=

Out[16]=

In[17]:=

Out[17]=

In[18]:=

Out[18]=

In[19]:=

Out[19]=

In[20]:=

Out[20]=

Both of the cursors are empty.

In[21]:=

Out[21]=

In[22]:=

Out[22]=

As was said previously, always close cursors when you are done with them.

In[23]:=

Out[23]=

In[24]:=

Out[24]=

In[25]:=

If you lose track of open cursors, you can use the DataSourceCursors function to find out which cursors are currently open.

In[26]:=

Out[26]=

In[27]:=

Out[27]=

In[28]:=

Out[28]=

In[29]:=

Out[29]=

In[30]:=

Out[30]=

In[31]:=

Out[31]=

In[32]:=

Out[32]=

In[33]:=

Out[33]=

In[34]:=

Out[34]=

In[35]:=

Out[35]=

In[36]:=

Out[36]=

In[37]:=

Out[37]=

In[38]:=

Out[38]=

In[39]:=

Structuring Text FilesData Types