Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
INSERT ... SELECT and row buffering, bug or not bug ?
Message
From
23/12/2004 09:46:40
 
 
To
23/12/2004 02:22:38
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00971447
Message ID:
00971775
Views:
20
Hi Walter,

>Hi Fabio,
>
>I'd say this is undocumented behaviour. the INSERT in the first example is limited to inserting one record, the second does not have this limitation. Therefore I guess that the second implementation automatically updates any record that is inserted.

Of course my choice of INSERT ... FROM ARRAY is not accidental.
INSERT FROM ARRAY can add many records, and the last inserted still on the buffer.

See this code:
CLEAR
CREATE CURSOR PIVOT (FF I)
CURSORSETPROP("Buffering",3)
APPEND BLANK 
APPEND BLANK
? 'APPEND BLANK',GETFLDSTATE(-1) AT 30,RECCOUNT() && LAST IS 33
TABLEUPDATE()

CREATE CURSOR abba (ff I)
CURSORSETPROP("Buffering",3)
 
SELECT 0 FROM PIVOT INTO ARRAY vv
? ALEN(VV,1) && TWO ROWS

APPEND FROM ARRAY vv 
? 'APPEND ARRAY',GETFLDSTATE(-1) AT 30,RECCOUNT() && LAST IS 34

INSERT INTO ABBA FROM ARRAY vv
? 'INSERT FROM ARRAY',GETFLDSTATE(-1) AT 30,RECCOUNT() && LAST IS 34
** OPERATION WITH TABLES
APPEND FROM DBF('PIVOT')
? 'APPEND TABLE',GETFLDSTATE(-1) AT 30,RECCOUNT() && LAST IS 11

INSERT INTO ABBA SELECT * FROM PIVOT
? 'APPEND TABLE',GETFLDSTATE(-1) AT 30,RECCOUNT() && LAST IS 11
>
>This behaviour probably is to be expected as this would make it consistent for INSERT INTO .... SELECT ... regardless of how many records are returned by the select statement. Otherwise you will have buffered data in the case only 1 record is returned or either only the last record added or none at all if multiple records are returned.
>
>Walter,

I think this too, and this can have sense, but the operation is different,
and it does not seem documented to me.

One good implementation:
1. To document what happens
2. To choose a behavior that separates different behaviors.
In this case, send the cursor in EOF() could to be very well,
removing every ambiguity
(this is cerente why it is like making SKIP after to have added the last record)

Wanting to make better:
- with _ TALLY = 1 put record in the buffer with state 34,
- with _ TALLY>1 update all and go in EOF().

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform