Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using variable in SQL Select statement
Message
From
08/01/2001 21:01:08
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00460861
Message ID:
00460946
Views:
9
Hi Allan,
One way of doing this is with a parameterized view and indices. That way, if the SELECT changes its constraints, a simple REQUERY("CursorName") will fix it.
Remember, if you have an updateable cursor, and buffering is set to 5, you can't index the view. But, with buffering at 3 you can. Working with Grids is often difficult with straight SELECTs because when you issue the SELECT the existing cursor is killed and a new one created. The Grid's RecordSource doesn't like that. You can set the RecordSource to '', then back, but the View does this with no work. I would, (assuming buffering--if not, just forget about the CURSORSETPROPs):
CURSORSETPROP("Buffering", 3, "ViewName")
INDEX ON Field1 TAG Field1
INDEX ON Field2 TAG Field2
INDEX ON &SomeOtherExpression. TAG Other
CURSORSETPROP("Buffering", 5, "ViewName")
then in your combos just
SET ORDER TO This.Value IN ViewName
ThisForm.Grid1.Refresh()

If a combo changes records in the view just set the variable you used in the view and requery.
ParaVar = This.Combo3.Value
REQUERY("ViewName")
ThisForm.Grid1.Refresh()



>I have a grid with a cursor (alias) rowsource. There are also a few comboboxes on the same form that control the contents of the grid. One of the comboboxes controls the sort order. In my code right now, I have seperate SQL statements for each sort order. I'd like to have one SQL statement using a variable to control the 'order by' section.
>
>For example, the following code works:
>
>select * from tblgl order by tblgl.tempgl into cursor test
>
>The code below does not work:
>
>ctemp = "tblgl.tempgl"
>
>select * from tblgl order by (ctemp) into cursor test
>
>Is there a way to use a memory variable in a SQL Select statement?
Charlie
Previous
Reply
Map
View

Click here to load this message in the networking platform