My first time working with remote data, connections, and views. A simple
form accepts input (user id) that is passed as a filter in the SELECT
portion of a CREATE SQL VIEW command. A view is created and a local query
against the view retrieves data into a cursor. Since the view is
parameterized only one record is available in the cursor (the record that
matches the user id). A child form displays the cursor data. Afterward, the
cursor is destroyed with the USE command and the parameterized view is
eliminated with DELETE VIEW. The process works fine the fist time in a
session.
The problem is, each successive time in a session that the use inputs data
and launches the process, the data from the first time through is
persistent. In other words, the first user in a session (user A) inputs
their id and gets back their information (Data A) as intended. All
subsequent users in a session enter their id (user X) and get back the
original user's information (Data A).
Sleuthing reveals that the .TMP file created for the local cursor has the
same name each time a user launches the process. I would normally expect
.TMP file names to be randomly generated each time a cursor is created. I
have confirmed that the .TMP file is deleted from the drive each time the
cursor is cleared. But the next cursor creates the same .TMP file name.
Using INDBC() I have also confirmed that the parameterized view is deleted
each time the process completes. I also confirmed that a different parameter
(user ID) is passed in the SELECT portion of subsequent CREATE SQL VIEW
command iterations.
Where does the persistence come from and how do I get rid of it?
* Load event of form contains
OPEN DATABASE mydbc
*mydbc contains CONNECTION (dbccon) to remote data source
*capture user input
lcUserId = THISFORM.Text1.Value
*validate locally
*concatenate user input to SELECT statement and assign to local variable
lcSelStr = "SELECT fields FROM remotetable WHERE somefield = " +
lcUserId
*create athe parameterized view
CREATE SQL VIEW myview CONNECTION dbccon AS &lcSelStr
*query data from view
SELECT fields FROM myview INTO CURSOR csrFromView
* validate non-empty cursor
*display retrieved data in child form
DO FORM childform WITH fields
*close query and cursor
USE IN csrFromView
*delete view from database
DELETE VIEW myview