If I run an query in prg file, say : select * from customers, I see the
result.

How can I view this query text "Select * from customers" after the prg is
run, without opening the prg file.

I actually want to view the last run query, not the result.

I tried following:-
Set talk on
Set talk to window mywindows

but it just give me: Selected 4 records in 0.00 seconds.

I tried using display memory but could not get it. any idea please ?

Best Regards,

Luqman

Re: display select query in window ? by Andrew

Andrew
Fri Feb 03 05:59:21 CST 2006

"Luqman" <pearlsoft@cyber.net.pk> wrote in message
news:Oj0I2kJKGHA.2088@TK2MSFTNGP11.phx.gbl...
> If I run an query in prg file, say : select * from customers, I see the
> result.
>
> How can I view this query text "Select * from customers" after the prg is
> run, without opening the prg file.

Check the TYPE command in help file.

--
HTH
Andrew Howell



Re: display select query in window ? by Andrew

Andrew
Fri Feb 03 06:08:39 CST 2006

"Andrew Howell" <ajh@work> wrote in message
news:%23K2IIlLKGHA.2696@TK2MSFTNGP14.phx.gbl...
> "Luqman" <pearlsoft@cyber.net.pk> wrote in message
> news:Oj0I2kJKGHA.2088@TK2MSFTNGP11.phx.gbl...
>> If I run an query in prg file, say : select * from customers, I see the
>> result.
>>
>> How can I view this query text "Select * from customers" after the prg
>> is
>> run, without opening the prg file.
>
> Check the TYPE command in help file.


Actually, sorry, you said you didn't want to read the prg.

To my knowledge the last command is not held anywhere we can get to (if at
all.) Perhaps the easiest thing to do is to display the query to screen in
your program.

Maybe something like

=cmdecho('SELECT * FROM table WHERE something INTO CURSOR foo')

*****************
FUNCTION cmdecho
*****************
* display command to active window, then execute it
PARAMETERS m.pcommand
* pcommand C [R] - command string to execute
?TIME()
?m.pcommand
&pcommand



Re: display select query in window ? by Olaf

Olaf
Fri Feb 03 06:25:56 CST 2006

> I tried using display memory but could not get it. any idea please ?

As SQL is native part of the vfp language you don't have such
a mechanism. As there is no command to show you what
commands have run, there is also none especially for sql.

You can do it yourself. Andrew already showed an example using
macro substitution, where you execute the query that is stored
in a string.

lcSQL = "your query here"
? lcSQL => echo the query to _screen or active window
&lcSQL => executing the sql

This also has limits if you use macrosubstitution within the
sql command itself again. And as you store some sql command
inside a string now, you give away the capability of vfp to make
syntax checks at design time.

If you have problems with a sql and try to locate it you need
an error handler that allows you to start the debugger. Then
you'd have access to the sql command and local variables etc.

Bye, Olaf.



Re: display select query in window ? by Cindy

Cindy
Fri Feb 03 10:13:16 CST 2006

Hi Luqman,

You haven't said which version of FoxPro you are using but you can copy the
query and paste it into the Command window, which saves everything you type.
Then when you want it to run again you can scroll back in the Command window
and run it.

Alternatively, if that particular query is something you want to do a lot
you could add a hot key for it in your startup program.

If you want to see the SQL text you can select and copy it and then use ?
_ClipText in the Command window to write it to the VFP desktop.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn.com www.cindywinegarden.com


"Luqman" <pearlsoft@cyber.net.pk> wrote in message
news:Oj0I2kJKGHA.2088@TK2MSFTNGP11.phx.gbl...
> If I run an query in prg file, say : select * from customers, I see the
> result.
>
> How can I view this query text "Select * from customers" after the prg is
> run, without opening the prg file.
>
> I actually want to view the last run query, not the result.
>