Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SET RELATION TO to update a cursor
Message
 
 
To
15/08/2019 17:04:23
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01670104
Message ID:
01670130
Views:
54
>>>>>Again, I would repeat do not follow this path of set relation for a simple update. That just creates a mess.
>>>>
>>>>Thank you for correcting me as far as which cursor should be indexed.
>>>>But you are saying the SET RELATION TO is not necessary and then you use it in your code.
>>>>Am I missing something?
>>>
>>>Nope, I am just correcting your code, I am not writing it the way I would write. Actually, set relation to approach would be one of my last choices (even before SQL - UPDATE's support, using xBase). I sent you how would I write it with UPDATE for the second time really.
>>
>>I understand now. I am not married to SET RELATION TO code :) So, I don't have to use it.
>>Actually I like your approach with UPDATE. As I wrote, I must have missed or misread it.
>>Thank you.
>
>One of your previous threads from yesterday, check
>Message ID: 01670095

Yes, you are right. I missed that suggestion from yesterday.

Now, I have a follow up question. In my production code I use the EVALUATE instead of hard-coded cursor names. And so far, I don't get the result that I expect. Could EVALUATE be the problem? Here is the production code:
Update (tcCursorName) set week_no = EVALUATE( tcBatchUpdCursor + ".week_no"), ;
week_fr = EVALUATE( tcBatchUpdCursor + ".MON_WK_FR"), ; 
week_to = EVALUATE( tcBatchUpdCursor + ".MON_WK_TO")  ;
from (tcBatchUpdCursor) ;
where EVALUATE( tcCursorName + ".TASK_NO" ) = EVALUATE( tcBatchUpdCursor + ".TASK_NO")
Please let me know if you see anything wrong with my code.

UPDATE. I replaced the above code with hard-coded cursor names (e.g. C_MYCURSOR.WEEK_NO) and I get the expected results. Apparently the EVALUATE in UPDATE is not allowed.

UPDATE 2. I figured how I can have the SQL Update without hard-coded cursor names. Your approach (your SQL Update) works if I use alias (e.g. "XY") in the SQL Update. Here is the example:
cTarget = "Target"
cSource = "Source"
Update (cTarget) ;
	set week_no = XY.week_no, week_fr = XY.week_fr, week_to = XY.week_to ;
from (cSource) XY where EVALUATE( cTarget + ".Pk_field" ) = XY.Pk_field
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform