|
Home > Archive > FoxPro database connector > June 2005 > Help with INSERTing from a SELECT
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Help with INSERTing from a SELECT
|
|
| John Cosmas 2005-06-30, 3:24 am |
| I have a SELECT statement that I run, which returns a set of records/rows.
After I run the first SELECT, I need to take those results and put it into
another TABLE. However, I don't want to use an INTO TABLE because the
destination table may be in use. I used SCATTER MEMVAR, but it only handles
the first record. Please let me know if there is a workaround to this.
Here is my original code.
SELECT * FROM car_stat ;
WHERE car_stat.K4 = m.pstrSearchK4 AND car_stat.a = m.pstrSearchA ;
PLAIN NOWAIT
SCATTER MEMVAR
USE wrk_car_stat SHARED AGAIN
INSERT INTO wrk_car_stat FROM MEMVAR
USE
| |
| Eric den Doop 2005-06-30, 7:25 am |
| INSERT INTO wrk_car_stat ;
SELECT * FROM car_stat ;
WHERE car_stat.K4 = m.pstrSearchK4 AND car_stat.a = m.pstrSearchA
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
"John Cosmas" <johncosmas@charter.net> wrote in message
news:2kKwe.12614$2S.8744@fe03.lga...
>I have a SELECT statement that I run, which returns a set of records/rows.
>After I run the first SELECT, I need to take those results and put it into
>another TABLE. However, I don't want to use an INTO TABLE because the
>destination table may be in use. I used SCATTER MEMVAR, but it only
>handles the first record. Please let me know if there is a workaround to
>this. Here is my original code.
>
> SELECT * FROM car_stat ;
> WHERE car_stat.K4 = m.pstrSearchK4 AND car_stat.a = m.pstrSearchA ;
> PLAIN NOWAIT
> SCATTER MEMVAR
> USE wrk_car_stat SHARED AGAIN
> INSERT INTO wrk_car_stat FROM MEMVAR
> USE
>
| |
| Jeroen van Kalken 2005-06-30, 7:25 am |
| On Wed, 29 Jun 2005 23:13:52 -0500, "John Cosmas"
<johncosmas@charter.net> wrote:
>I have a SELECT statement that I run, which returns a set of records/rows.
>After I run the first SELECT, I need to take those results and put it into
>another TABLE. However, I don't want to use an INTO TABLE because the
>destination table may be in use. I used SCATTER MEMVAR, but it only handles
>the first record. Please let me know if there is a workaround to this.
>Here is my original code.
Insert a SCAN/ENDSCAN loop:
> USE wrk_car_stat SHARED AGAIN && moved !
> SELECT * FROM car_stat ;
> WHERE car_stat.K4 = m.pstrSearchK4 AND car_stat.a = m.pstrSearchA ;
> PLAIN NOWAIT
SCAN
> SCATTER MEMVAR
> INSERT INTO wrk_car_stat FROM MEMVAR
ENDSCAN
> USE
>
Or rewrite it to make it easier to understand (and faster)
SELECT * FROM car_stat ;
WHERE car_stat.K4 = m.pstrSearchK4 AND car_stat.a = m.pstrSearchA ;
INTO CURSOR myresult NOFILTER
SELECT 0
USE wrk_car_stat SHARED AGAIN
APPEND FROM DBF('myresult')
USE IN wrk_car_stat
USE IN myresult
TIP's:
Always give SELECT-results a cursor name, don't rely on it to result
in the cursor 'QUERY'.
Try to minimize the use of memory-variables, if possible use cursors.
SCATTER might overwrite a variable you didn't realize was also a table
field.
| |
| Kurt Grassl 2005-06-30, 7:25 am |
| Hi,
> TIP's:
> Always give SELECT-results a cursor name, don't rely on it to result
> in the cursor 'QUERY'.
> Try to minimize the use of memory-variables, if possible use cursors.
> SCATTER might overwrite a variable you didn't realize was also a table
> field.
.... or use SCATTER NAME lo...
Kurt
| |
| John Cosmas 2005-06-30, 11:24 am |
| OK. So now that I have the table populated, I need to refresh the grid
whose recordsource is the wrk_car_stat. I ran the
ThisForm.gridCarStat.Refresh, but the data does not seem to appear in it.
Should I have some other settings in there as well?
"Jeroen van Kalken" <I@dont.like.spam> wrote in message
news:18i7c1p9ukjjnn0
lopnufgj45q222uestk@
4ax.com...
> On Wed, 29 Jun 2005 23:13:52 -0500, "John Cosmas"
> <johncosmas@charter.net> wrote:
>
>
> Insert a SCAN/ENDSCAN loop:
>
> SCAN
> ENDSCAN
>
> Or rewrite it to make it easier to understand (and faster)
>
> SELECT * FROM car_stat ;
> WHERE car_stat.K4 = m.pstrSearchK4 AND car_stat.a = m.pstrSearchA ;
> INTO CURSOR myresult NOFILTER
> SELECT 0
> USE wrk_car_stat SHARED AGAIN
> APPEND FROM DBF('myresult')
>
> USE IN wrk_car_stat
> USE IN myresult
>
>
> TIP's:
> Always give SELECT-results a cursor name, don't rely on it to result
> in the cursor 'QUERY'.
> Try to minimize the use of memory-variables, if possible use cursors.
> SCATTER might overwrite a variable you didn't realize was also a table
> field.
|
|
|
|
|