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()
TABLEUPDATE()
CREATE CURSOR abba (ff I)
CURSORSETPROP("Buffering",3)
SELECT 0 FROM PIVOT INTO ARRAY vv
? ALEN(VV,1)
APPEND FROM ARRAY vv
? 'APPEND ARRAY',GETFLDSTATE(-1) AT 30,RECCOUNT()
INSERT INTO ABBA FROM ARRAY vv
? 'INSERT FROM ARRAY',GETFLDSTATE(-1) AT 30,RECCOUNT()
APPEND FROM DBF('PIVOT')
? 'APPEND TABLE',GETFLDSTATE(-1) AT 30,RECCOUNT()
INSERT INTO ABBA SELECT * FROM PIVOT
? 'APPEND TABLE',GETFLDSTATE(-1) AT 30,RECCOUNT()
>
>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