fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

[2.5b] DBSERVER:Zap 17 Sep 2020 10:01 #15892

  • FFF's Avatar

  • FFF

  • Topic Author


  • Posts: 1014
  • Guys,
    anyone succeeded using Zap() on a table?
    Simple dbServer,
    METHOD kill() AS LOGIC
    		LOCAL oD AS Schicht
    	oD:=Schicht{}
    	oD:Flock()
    oD:Zap()
    oD:Commit()
    RETURN
    Compiles, runs - and does nothing.

    OK, changed my method call to:
    METHOD kill() AS LOGIC
    
    	USE "D:\Misc\TuK\VN_Version\DATA\Schicht.dbf" EXCLUSIVE NEW
    	IF !NetErr()
    //   SET INDEX TO sales, branch, salesman
    		IF DbZap()
    			? "Zapped OK"
    		ELSE
    			? "Error detected during ZAP"
    		ENDIF
    		CLOSE "D:\Misc\TuK\VN_Version\DATA\Schicht.dbf"
    	ELSE
    		? "Error detected when opening the file"
    	ENDIF
    RETURN
    using the sample from X# helpfile.
    Compiling, i get:
    error XS9002: Parser: unexpected input '->' 772,3 _Tom_Shell.prg TomShellWindow:kill
    Line 772 is the "close" call.

    I'm totally blank on using "commands", but i doubt, this should be as is.



    PS, looking into Helfp for DBServer, it seems, in the description part quite some line breaks where lost...;)
    Regards
    Karl (X# 2.6; Xide 1.26; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    [2.5b] DBSERVER:Zap 17 Sep 2020 10:30 #15893

  • Chris's Avatar

  • Chris


  • Posts: 2166
  • Hi Karl,

    Maybe the dbf is opened in shared mode? Zap and Pack can only work in exclusive mode.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    [2.5b] DBSERVER:Zap 17 Sep 2020 10:38 #15894

  • robert's Avatar

  • robert


  • Posts: 1895
  • Karl,

    What Chris said.
    And if you want to help format the documentation, please let me know.
    It's all in source code format (XML).:

    github.com/X-Sharp/XSharpPublic/blob/mas...cs/VOSDK_Classes.xml

    It's probably enough to add some breaks (<br />) at the right locations.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Last edit: by robert.

    [2.5b] DBSERVER:Zap 17 Sep 2020 11:08 #15895

  • FFF's Avatar

  • FFF

  • Topic Author


  • Posts: 1014
  • Chris wrote: Maybe the dbf is opened in shared mode? Zap and Pack can only work in exclusive mode.

    That i thought, too. But then, why doesn't FLock fail? I wrapped it into an If clause, debugged, Flock succeeds, stepping to the zap line i get an XSharp.RDD.RddError (no further information given). Added a SetExclusive(true) in front, which returned "False", so yes, whithout this it shouldn't work, but AFAIU the docs, Flock should correct that or return false, which it does not.

    FTM i simply deleted the file and exported anew from Editor, but it feels strange.
    Regards
    Karl (X# 2.6; Xide 1.26; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    [2.5b] DBSERVER:Zap 17 Sep 2020 11:40 #15896

  • Chris's Avatar

  • Chris


  • Posts: 2166
  • Hi Karl,

    And FLock() will succeed, and it will work for updating single records, but this is not enough for Zap and Pack, those require the files to be opened in exclusive mode. Please try it also in VO, you will see that also in it exclusive is a requirement, an flock is not enough.

    Btw, it is not necessary to use SetExclusive(), because this will affect opening of all files. You can instead open the file with the appropriate parameter when you instantiate the dbserver. For a simple DBServer class (not a subclass), you'd do something like

    DBServer{<filename>,FALSE}

    Also SetExclusive() returns the _previous_ state of the setting (so you can easily save it and restore it later) when you change it, this is why it returned FALSE in your case, because this is the default setting.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    [2.5b] DBSERVER:Zap 17 Sep 2020 11:45 #15897

  • FFF's Avatar

  • FFF

  • Topic Author


  • Posts: 1014
  • Chris wrote: Also SetExclusive() returns the _previous_ state of the setting (so you can easily save it and restore it later) when you change it, this is why it returned FALSE in your case, because this is the default setting.

    That i grokked ;) - but nevertheless, even with the SetExclusive(true), the Zap fails. Why?

    As for Flock is not enough, under Function SetExclusive the help says:
    ...Use this only for operations that absolutely require exclusive use of a database file, such as PACK, REINDEX, and ZAP. ... You can control access programmatically using RLock() and FLock(). SetExclusive() is a compatibility function and not recommended...

    A bit mislieading, is it not?
    Regards
    Karl (X# 2.6; Xide 1.26; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    [2.5b] DBSERVER:Zap 17 Sep 2020 11:56 #15898

  • Chris's Avatar

  • Chris


  • Posts: 2166
  • Hi Karl,

    Not sure, it seems to work fine here. Maybe there's something about this dbf, can you try with others? Or maybe when you instantiate the (dbserver descedant) Schicht class, this actually opens the file always in shared mode, ignoring the SetExclusive() setting? Please check the constructor of this class, it should be obvious what it is doing.

    Yeah, I agree this documentation in SetExclusive() is bad. You need to blame the team that wrote the VO documentation for that :)
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1