Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query vs. Select 2

Status
Not open for further replies.

sheronne

Programmer
Jun 1, 2001
71
US
I am creating a program that polls a table every 30 seconds looking for new entries. If FOUND() it displays the new entries on a grid for the users. What are the advantages/disadvantages of using using a do query vs. SQL's Select statement.

TiA

R
 
Query is stored in DBC container. Query can be used to update database, with very easy code and simple code input.
Once you code the SQL in the query, you can forget about that and use the query as if it is your table, from any of your routines. So query is more advantageous.

If you are talking about a single situation only, I do not find any major difference. But in a single programme also, requery() with a variable built into the query is so handy, you will not want to code an SQL everytime.

ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Hello,

Ramani, please, please, don't take my message personally. Ok?

Query is not stored in dbc. Is a text file on disk, having the .QPR extension. You are talking about views. It is correct what are you saying, but those are views. You cannot issue such command "DO MyView", but "DO myquery.qpr" it's perfecly possible.

So: the query is, in fact, a SQL select statement. The query designer looks exacly the same as view designer, except the "Update criteria" page. Queries are read-only and nothing can be done about this.

Now, sticking to the first message posted: there will be no difference betwen a DO QUERY and SELECT statement. DO QUERY will run a program containing that SQL statement.

There is a subtile difference, though: the view designer (assuming the SQL statement is in fact a view stored in DBC) is not a very performant tool. So, using a hand-coded SQL statement (a complicated one) is better, in some cases, than using the View Designer. But in the first message the situation is very clear: sheronne needs a SELECT * FROM <table> INTO CURSOR <cursor>. In this case, DO QUERY or hand-coded SQL statement or (if he use DBC's) a view will make no difference.

Also, about the queries: they are handy in one situation (I've seen it): when a listbox or a combo box should be populated by a SQL statement (you know - RowSourceType = 3). That SQL statement is stored in SCX in a character data field. And the maximum length is 254 chars. If the SQL statement is bigger, it will be truncated. The trick is to set the RowSourceType to 4 and point the query. Query being a text file, the limitation disappears.

Hope this helps Grigore Dolghin
Class Software
Bucharest, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top