Programming Guide |
Sets up a continuation file for a named or default cursor
DBMS [WITH CURSORcursor
] STORE [FILE [filename
]]
WITH CURSOR
cursor
- Name of declared
SELECT
cursor. If the clause is not used, Panther uses the defaultSELECT
cursor.filename
- Name of temporary binary file.
When
DBMS STORE
is used with aSELECT
cursor, Panther maintains a copy of the result rows in a temporary binary file. The file permits an application to scroll forward and backward in a select set, even if the database has no native support for backward scrolling.A continuation file remains open for the life of the cursor, or until the feature is turned off with the command,
DBMS [WITH CURSORcursor
] STOREExecuting the command without the keyword
FILE
closes and deletes the file and turns off the feature for the named or default cursor. Closing the cursor also closes and deletes the file. If a cursor is not closed but simply redeclared for anotherSELECT
statement, the file is cleared. Therefore, a continuation file holds the results of oneSELECT
statement only.The use of a continuation file does not force the database engine to return the entire select set when the
SELECT
is executed. Panther examines the number of occurrences in the destination variable to determine the number of rows to fetch. Each time it fetches rows from the database engine by executing theSELECT
or aCONTINUE
, Panther updates the screen and appends the new data to the continuation file. If the application wishes to see rows already fetched, Panther uses the continuation file to get the rows and update the screen. If Panther reaches the end of the continuation file and the application executes anotherDBMS CONTINUE
, Panther attempts to get more rows from the database engine. When the engine returns the no-more-rows code, Panther sets@dmretcode
to the value ofDM_NO_MORE_ROWS
. Similarly, if the application attempts to scroll back past the first row in the continuation file, Panther sets@dmretcode
toDM_NO_MORE_ROWS
. Write errors are not reported.
DBMS STORE
provides several advantages:
- A means for displaying very large select sets without keeping all rows in memory at once.
- A means for forcing an database engine to release a shared lock on a large select set.
For information on engine-specific scrolling issues, refer to "Database Drivers."
// Use of STORE FILE with JPL procedures to fetch more rows.proc title_select
DBMS DECLARE t_cursor CURSOR FOR SELECT * FROM titles
DBMS WITH CURSOR t_cursor STORE FILE
DBMS WITH CURSOR t_cursor EXECUTE
returnproc get_next
DBMS WITH CURSOR t_cursor CONTINUE_DOWN
returnproc get_previous
DBMS WITH CURSOR t_cursor CONTINUE_UP
return// Use of STORE FILE and map keys in order to fetch more rows.proc select_titles
DBMS DECLARE t_cursor CURSOR FOR SELECT * FROM titles
DBMS WITH CURSOR t_cursor STORE FILE
DBMS WITH CURSOR t_cursor EXECUTE
return// This procedure is called on screen entry.proc entry (name, flag)
if (flag & K_ENTRY)
{
call sm_keyoption (SPGD, KEY_XLATE, APP1)
call sm_keyoption (SPGU, KEY_XLATE, APP2)
}
...
return//This procedure is called on screen exit.proc exit (name, flag)
if (flag & K_EXIT)
{
call sm_keyoption (SPGU, KEY_XLATE, SPGU)
call sm_keyoption (SPGD, KEY_XLATE, SPGD)
}
...
returnproc scroll_up
// Control strings contains:
// APP1 = ^scroll_up
DBMS WITH CURSOR t_cursor CONTINUE_UP
returnproc scroll_down
// Control strings contains:
// APP2 = ^scroll_down
DBMS WITH CURSOR t_cursor CONTINUE
return