Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP new bug: UPDATE with SET RELATION fails
Message
From
08/12/2001 16:53:17
 
 
To
08/12/2001 13:55:46
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00588420
Message ID:
00591704
Views:
32
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) )
>>>
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform