X-Sharp / XSharpPublic

Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools.
Apache License 2.0
113 stars 38 forks source link

[VFP] Cursor operation - SQL UPDATE #1576

Open MarioV-GH opened 1 month ago

MarioV-GH commented 1 month ago

Describe the bug Support SQL Update (xsharp-error)

To Reproduce Code:

USING System USING System.Collections.Generic USING System.Text

FUNCTION check_cursor AS VOID create cursor abc (mkey i, mident c(10)) insert into abc (mkey,mident) values (1,"a") insert into abc (mkey,mident) values (2,"b") insert into abc (mkey,mident) values (3,"c")

    create cursor def (mkey_fk i,mtext c(10))
    insert into def (mkey_fk,mtext) values  (1,"inf1")
    insert into def  (mkey_fk,mtext)  values (1,"inf2")
    insert into def  (mkey_fk,mtext)  values (2,"infA")

    insert into def  (mkey_fk,mtext)  values (3,"to_del")
    insert into def  (mkey_fk,mtext)  values (4,"to_del")
    update def set mtext = "newtext" where mkey_fk = 2

RETURN Expected behavior Support VFP Update Command

RobertvanderHulst commented 1 month ago

For now you can make this with with the following UDC.

#command UPDATE <(a)> SET <(f1)> = <x1> [, <(fn)> = <xn>]               ;
         [WHERE <lfor>]                                                   ;
                                                                        ;
      => (<(a)>)->(DbEval(                                              ;
                 {||DbAutoLock(), __FieldSet(<(f1)>,<x1>) [, __FieldSet(<(fn)>, <xn>)], DbAutoUnLock()},    ;
                 <{lfor}>))

Please note that the JOIN clause is not supported yet.