Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP new bug: UPDATE with SET RELATION fails
Message
De
09/12/2001 10:16:57
 
 
À
09/12/2001 09:56:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00588420
Message ID:
00591828
Vues:
30
REPLACE ALL attempts to lock the entire table before executing.

The simplest way around this is:
SELECT Cursor1
SCAN
    REPLACE Field2 WITH LOOKUP(RCursor.Field2, Cursor1.Field1, RCursor.Field1)
ENDSCAN
Of course, you'd want to perform that operation only if you can lock each record to ensure the update takes place.

Jay


>My cursor1 is a large table on network server having 25 concurrent users.
>I have found thet replace all causes error if table is used by other users.
>
>
>>Andrus,
>>I may be missing something, but you can definitely update a record with a single line and without SET RELATION. See the bold line below:
>>
>>CREATE CURSOR Cursor1 ( Field1 c(10), Field2 c(10))
>>INSERT INTO Cursor1 VALUES ('001', '')
>>INSERT INTO Cursor1 VALUES ('002', '')
>>INSERT INTO Cursor1 VALUES ('003', '')
>>INSERT INTO Cursor1 VALUES ('004', '')
>>INSERT INTO Cursor1 VALUES ('005', '')
>>
>>CREATE CURSOR RCursor ( Field1 c(10), Field2 c(10))
>>INSERT INTO RCursor VALUES ('001', 'AAA')
>>INSERT INTO RCursor VALUES ('002', 'BBB')
>>*INSERT INTO RCursor VALUES ('003', '')
>>INSERT INTO RCursor VALUES ('004', 'DDD')
>>INSERT INTO RCursor VALUES ('005', 'EEE')
>>
>>SELECT Cursor1
>><b>REPLACE ALL Field2 WITH LOOKUP(RCursor.Field2, Cursor1.Field1, RCursor.Field1)</b>
>>
>>
>>HTH
>>>I need to update a field in Cursor1 from a related record in RCursor.
>>>IMHO this is impossible in single statement without using SET RELATION
>>>
>>>>Andrus,
>>>>I don't understand why you think you need the relation and the EOF() check. If you simply use the following:
>>>>UPDATE Cursor1 ;
>>>>    SET Field1=Field1 ;
>>>>    WHERE Field1 in (select field1 from RCursor)
>>>>It appears to do what you need and that is update all records in Cursor1 with a matching record in RCursor. Unless you are running an internal function that updates something in RCursor during the Update statement, I don't think you need it.
>>>>
>>>>HTH.
>>>>
>>>>>Please confirm, is this VFP bug ?
>>>>>
>>>>>
>>>>>CREATE CURSOR Cursor1 ( Field1 c(10) )
>>>>>INSERT INTO Cursor1 VALUES ('HLADU' )
>>>>>INSERT INTO Cursor1 VALUES ('POOD')
>>>>>
>>>>>CREATE CURSOR RCursor ( Field1 c(10) )
>>>>>INSERT INTO RCursor VALUES ( 'HLADU' )
>>>>>INDEX ON Field1 TAG T
>>>>>
>>>>>SELECT Cursor1
>>>>>SET RELA TO Field1 INTO RCursor
>>>>>
>>>>>UPDATE Cursor1 ;
>>>>>    SET Field1=Field1 ;
>>>>>    WHERE !EOF('RCursor') AND ;
>>>>>       Field1 IN (SELECT Field1 FROM RCursor )
>>>>>* Result: 0
>>>>>* Expected result: 1
>>>>>messagebox( STR(_TALLY) )
>>>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform