Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Auto cdoe SQL and inserting a variable
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00509864
Message ID:
00511632
Views:
15
>I am working on a prototype VFP 6.0 front end to an Oracle 8i database, and I have one requirement view that selects data from 5 tables that will populate a form. When a view is created the SQL is generated by the query builder, and by default it is viewable as read-only, and retrieves all records.
>This is not a good thing as relates to netwark travffic, when all I want is to execute the query and search for one record,
>
>What I want to do is to open the form with noDataOnLoad and do a search on a key field, assign that to a variable and have the variable in the WHERE clause of the SQL statement to retrieve a single record for updating. Next it would populate the form with the fields from that one record in the view. I probably have already done the code, programmically, but I would like to hear some of your ideas as to best practices.

What I do for my Search/Query form is not have any views or tables. I have some textboxes for users to input their search criteria. I then have code that builds the SQL string. This string has the minimal number of fields needed for the user to make an intelligent decision on what record to select to work with.

I return the entire SQL string to a results form that sends the SQL string via SQLExec() to the Oracle server. The results form has a grid that displays the matching records. The user selects a record. I then populate a global app object property with the key ID of this record [e.g., goApp.nMyTable_ID = cursorname.KeyID].

Then I call another form to do the editing. In the Activate of the form, I check the value of the goApp ID. This form uses a parameterized view where the parameter is the KeyID of the table. If the goApp ID is different than the current record being edited, I issue a tableupdate, then a requery. If there is no record being edited, I just requery.

The order of form instanciation:

Results Form -- Init checks to see if there is a results cursor, if not or if the cursor is empty, the Query form is called -- DO FORM MYQUERY TO lcSQL

If lcSQL is empty, I release the form and return false. Otherwise, I continue loading the results form, execute the SQL in the lcSQL and populate the grid.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform