Discussion:
SELECT
(too old to reply)
Marc
2008-07-04 10:20:45 UTC
Permalink
I have a command in a PRG
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
Before executing this command two tables are opened and 'fNames'
table is selected as the current alias.
After executing this command fTrmVars table is created and relevant records
also there.
But 'fTmpNames' doesn't select as the current alias
Still the current alias is 'fNames'

lcAliasBef = ALIAS()
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
lcAliasAfter = ALIAS()
Stefan Wuebbe
2008-07-04 11:00:00 UTC
Permalink
Post by Marc
I have a command in a PRG
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
Before executing this command two tables are opened and 'fNames'
table is selected as the current alias.
After executing this command fTrmVars table is created and relevant records also there.
But 'fTmpNames' doesn't select as the current alias
Still the current alias is 'fNames'
lcAliasBef = ALIAS()
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
lcAliasAfter = ALIAS()
But you would have expected that the "Into Cursor" alias should be
the selected one afterwards, right?
A typical thing causing unexpected current workareas is a Grid as the
active control of an active form while your code (or even report) is
running, so the workaround would be to do anotherControl.SetFocus()
in advance.


Does that help?
-Stefan
--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------
Marc
2008-07-07 03:49:54 UTC
Permalink
Thanks Stefan
It solved the problem
I set the SetFocus to another object.
Post by Stefan Wuebbe
Post by Marc
I have a command in a PRG
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
Before executing this command two tables are opened and 'fNames'
table is selected as the current alias.
After executing this command fTrmVars table is created and relevant records also there.
But 'fTmpNames' doesn't select as the current alias
Still the current alias is 'fNames'
lcAliasBef = ALIAS()
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
lcAliasAfter = ALIAS()
But you would have expected that the "Into Cursor" alias should be
the selected one afterwards, right?
A typical thing causing unexpected current workareas is a Grid as the
active control of an active form while your code (or even report) is
running, so the workaround would be to do anotherControl.SetFocus()
in advance.
Does that help?
-Stefan
--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------
Craig Berntson
2008-07-09 14:57:35 UTC
Permalink
Just a point of clarification. The SELECT command in the question does not
create a table. It creates a cursor. What's the difference? A table resides
on disk and is generally considered permanent. A cursor may reside totally
in memory, is read-only by default, and is automatically deleted when
closed.
--
Craig Berntson
Microsoft MVP

-------------
Post by Marc
I have a command in a PRG
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
Before executing this command two tables are opened and 'fNames'
table is selected as the current alias.
After executing this command fTrmVars table is created and relevant
records also there.
But 'fTmpNames' doesn't select as the current alias
Still the current alias is 'fNames'
lcAliasBef = ALIAS()
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
lcAliasAfter = ALIAS()
Marc
2008-07-11 08:54:46 UTC
Permalink
Yes that is a temporary cursor. But afterthat SELECT * .... command the
creating cursor should be selected, but it not happens like that. Im calling
that prg by doubleClicking the grid. Therefore the grid recordsource table
is always selected. Because of that the creating cursor is not selecting.
Is there any way to avoid this.?
Post by Craig Berntson
Just a point of clarification. The SELECT command in the question does
not create a table. It creates a cursor. What's the difference? A table
resides on disk and is generally considered permanent. A cursor may reside
totally in memory, is read-only by default, and is automatically deleted
when closed.
--
Craig Berntson
Microsoft MVP
-------------
Post by Marc
I have a command in a PRG
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
Before executing this command two tables are opened and 'fNames'
table is selected as the current alias.
After executing this command fTrmVars table is created and relevant
records also there.
But 'fTmpNames' doesn't select as the current alias
Still the current alias is 'fNames'
lcAliasBef = ALIAS()
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
lcAliasAfter = ALIAS()
Craig Berntson
2008-07-11 14:49:47 UTC
Permalink
Explicitly SELECT the cursor/table you want
--
Craig Berntson
Microsoft MVP

-------------
Post by Marc
Yes that is a temporary cursor. But afterthat SELECT * .... command the
creating cursor should be selected, but it not happens like that. Im
calling that prg by doubleClicking the grid. Therefore the grid
recordsource table is always selected. Because of that the creating cursor
is not selecting.
Is there any way to avoid this.?
Fred Taylor
2008-07-11 22:38:33 UTC
Permalink
The grid ALWAYS wants to have as the current area its recordsource. You'll
have to either move the Focus off the grid to some other control before you
do your SQL SELECT, or you'll have to SELECT the cursor before you try to
use it.
--
Fred
Microsoft Visual FoxPro MVP
Post by Marc
Yes that is a temporary cursor. But afterthat SELECT * .... command the
creating cursor should be selected, but it not happens like that. Im
calling that prg by doubleClicking the grid. Therefore the grid
recordsource table is always selected. Because of that the creating cursor
is not selecting.
Is there any way to avoid this.?
Post by Craig Berntson
Just a point of clarification. The SELECT command in the question does
not create a table. It creates a cursor. What's the difference? A table
resides on disk and is generally considered permanent. A cursor may
reside totally in memory, is read-only by default, and is automatically
deleted when closed.
--
Craig Berntson
Microsoft MVP
-------------
Post by Marc
I have a command in a PRG
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
Before executing this command two tables are opened and 'fNames'
table is selected as the current alias.
After executing this command fTrmVars table is created and relevant
records also there.
But 'fTmpNames' doesn't select as the current alias
Still the current alias is 'fNames'
lcAliasBef = ALIAS()
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
lcAliasAfter = ALIAS()
Anders Altberg
2008-07-12 21:55:24 UTC
Permalink
Hi Marc
Functions that operate on cursor, practically always take the cursorname as
a last, optional parameter.
Commands tha operate on table proctacally always take an optional clause 'IN
cursoralias'
Make a habit of using them and you don't have to very much about selecting a
workarea.

-Anders
Post by Marc
Yes that is a temporary cursor. But afterthat SELECT * .... command the
creating cursor should be selected, but it not happens like that. Im
calling that prg by doubleClicking the grid. Therefore the grid
recordsource table is always selected. Because of that the creating cursor
is not selecting.
Is there any way to avoid this.?
Post by Craig Berntson
Just a point of clarification. The SELECT command in the question does
not create a table. It creates a cursor. What's the difference? A table
resides on disk and is generally considered permanent. A cursor may
reside totally in memory, is read-only by default, and is automatically
deleted when closed.
--
Craig Berntson
Microsoft MVP
-------------
Post by Marc
I have a command in a PRG
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
Before executing this command two tables are opened and 'fNames'
table is selected as the current alias.
After executing this command fTrmVars table is created and relevant
records also there.
But 'fTmpNames' doesn't select as the current alias
Still the current alias is 'fNames'
lcAliasBef = ALIAS()
SELECT * FROM fNames INTO CURSOR fTmpNames WHERE Int_key=11
lcAliasAfter = ALIAS()
Loading...