fbpx
Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC: USED(), DELETED(), INSERT INTO

USED(), DELETED(), INSERT INTO 25 Nov 2019 03:01 #11911

  • cecilchamp's Avatar

  • cecilchamp

  • Topic Author


  • Posts: 49
  • I suppose these are not working yet? USED(), DELETED() and INSERT INTO? I tried them out in code and they are not recognized. I think I read that INSERT INTO is not working. APPEND BLANK and REPLACE work well.

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

    #command SET DEFAULT TO <*path*> => SetDefault(<(path)>)

    FUNCTION Start() AS VOID STRICT
    LOCAL i AS INT
    SET DEFAULT TO C:\addr\data
    SELECT 0
    IF !USED("names")
    USE names Index LastName
    SELECT NAMES
    * INSERT INTO does not work.
    *INSERT INTO Names (LastName, FirstName) Values ('Champenois', 'Sean')
    *APPEND BLANK
    *REPLACE LastName WITH 'Champenois', FirstName WITH 'Sean'
    SCAN for LastName = "Champenois" AND !DELETED()
    ? LastName, FirstName
    ENDSCAN
    WAIT
    SELECT Names
    USE
    ELSE
    ? "The table, NAMES, is in use by another program."
    ENDIF
    RETURN

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

    USED(), DELETED(), INSERT INTO 25 Nov 2019 06:31 #11913

  • Karl-Heinz's Avatar

  • Karl-Heinz


  • Posts: 555
  • Hi Cecil,

    when you look at the latest Used() and Deleted() Github sources you´ll see that the next release will contain the overloads:
    FUNCTION Deleted(uArea AS USUAL) AS LOGIC STRICT
    	RETURN (uArea)->(Deleted())
    
    
    FUNCTION Used(uArea AS USUAL) AS LOGIC
        RETURN (uArea)->(Used())

    github.com/X-Sharp/XSharpPublic/blob/5da...Dbfunctions.prg#L383

    For the moment simply add both funcs to your sources and you can already do something like:
    IF !USED("names") 

    !! But don´t forget to remove both funcs from your sources as soon the next release is published !!

    regards
    Karl-Heinz

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

    USED(), DELETED(), INSERT INTO 25 Nov 2019 08:39 #11916

  • robert's Avatar

  • robert


  • Posts: 1692
  • Cecil,
    The function overloads that take an alias or workarea number will be added in the next build.
    You can already see that code in Githib:
    github.com/X-Sharp/XSharpPublic/blob/mas...Dbfunctions.prg#L383

    Robert
    XSharp Development Team
    The Netherlands

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

    USED(), DELETED(), INSERT INTO 25 Nov 2019 15:02 #11920

  • FoxProMatt's Avatar

  • FoxProMatt


  • Posts: 385
  • I suppose these are not working yet? USED(), DELETED() and INSERT INTO?


    Cecil - Used() and Deleted() are VFP functions, and it sounds like those are easy, if not already done, ready for next release.

    However, INSERT INTO is a different beast that X# Team will have to tackle. It's not quite as easy, if I had guess.

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

    Last edit: by FoxProMatt.

    USED(), DELETED(), INSERT INTO 25 Nov 2019 15:36 #11921

  • robert's Avatar

  • robert


  • Posts: 1692
  • Matt,

    Yes you are right. INSERT TO belongs to the "embedded SQL" commands.
    We will implement these but this requires some work.

    Robert
    XSharp Development Team
    The Netherlands

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

    USED(), DELETED(), INSERT INTO 25 Nov 2019 16:10 #11922

  • FoxProMatt's Avatar

  • FoxProMatt


  • Posts: 385
  • Robert - what is your priority between the "embedded SQL" commands, and the SqlExec() stack?

    I bet SqlExec() is an easier task, but I think the "embedded SQL" commands are an important piece to demonstrate to VFP community to show X# is ready for serious consideration.

    I know you mentioned using VFPOLEDB to handle embedded SQL, but one thing my little brain sees as an issue with that is that it seems like VFPOLEDB expects that the query will be run against all DISK-based DBFs, but in real apps we also need to execute embedded SQL commands against existing local cursors that are not on disk.

    For instance, I often run SqlExec() to pull over a few separate cursors from Sql Server into VFP, then I run embedded SQL commands on the cursors to do JOINs, UNIONS, UPDATEs, INSERTs, etc on those local cursors to present data to user in reports, grids, etc.

    Can you see getting VFPOLEDB to work with local cursors?

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

    Last edit: by FoxProMatt.

    USED(), DELETED(), INSERT INTO 25 Nov 2019 18:32 #11927

  • robert's Avatar

  • robert


  • Posts: 1692
  • Matt,

    VFPOLEDB was an idea, nothing more.We now realize that VFP also uses SQL against open cursors and that won't work.
    We realize how important these queries are, so we will work on them, you can be assured of that.
    I don't want to make promises here about priorities. We are doing some research into this at this moment. Based on the results of this research we will make the decision about priorities.

    And yes we know what you want:



    Robert
    XSharp Development Team
    The Netherlands

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

    USED(), DELETED(), INSERT INTO 15 Dec 2019 23:58 #12206

  • mainhatten's Avatar

  • mainhatten


  • Posts: 139
  • Matt,
    have not thought this through totally, but perhaps a quick way to get Sql select into xsharp might be to implement parts of cursor adapter.
    This should be easier to map into Dotnet data structures and eliminates treating SQL as source - it is in the string property.
    That way FPW2.6 level at least could be reached without adding oodles of responsibilities to the compiler, but delegating to existing Dotnet objects already sporting such capability.
    Must think about it some more, but ADO.net should be up to provide executing a SQL string on both SQL backend and local tables.
    Just a hunch...
    thomas

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

    USED(), DELETED(), INSERT INTO 16 Dec 2019 01:45 #12207

  • mainhatten's Avatar

  • mainhatten


  • Posts: 139
  • robert wrote: VFPOLEDB was an idea, nothing more.We now realize that VFP also uses SQL against open cursors and that won't work.
    We realize how important these queries are, so we will work on them, you can be assured of that.
    I don't want to make promises here about priorities. We are doing some research into this at this moment. Based on the results of this research we will make the decision about priorities.

    Robert,

    I know you think mostly about cursors to be implemented via ADO.Net Datatable or something similar - which by being "in memory" is fast. For me the local cursor being on disk is a nice cache of the remote data store, even if not as fast as memory, although SSD helped a lot in the last years. Getting rid of the LAN or internet hop is more important than HANA-like analysis. Small, often accessed tables will be already OS-cached, so hopefully a bit faster than pure disc based stuff.

    Piping into a local dbf from a firehose reader from ADO.Net should be doable, from then on data access to local dbf via SQL could follow via ADO.Net based data objects. Perhaps a ADO.net Commandobject containing the previous "inline" SQL is an alternative good enough to consider. If a memory based cursor can be added to be handled via same or similar code, all the better. Having identical method/code to interact with remote/local/cursor data IMO is more important than forcing the cursor data into RAM (which might again be swapped out to disc...)

    And yes we know what you want:

    Well, I sincerely hope the answer of xSharp dev team will be along the lines of

    regards

    thomas

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

    Last edit: by mainhatten.

    USED(), DELETED(), INSERT INTO 16 Dec 2019 18:25 #12210

  • robert's Avatar

  • robert


  • Posts: 1692
  • Thomas,

    LOL.

    Fasten your seatbelts. Be prepared to be rocked !

    Robert
    XSharp Development Team
    The Netherlands

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

    USED(), DELETED(), INSERT INTO 16 Dec 2019 19:02 #12211

  • Kevin Clark's Avatar

  • Kevin Clark


  • Posts: 68
  • Since X# already supports LINQ, would it be possible to create a Visual Foxpro SQL to LINQ converter and then run the LINQ query?

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

    USED(), DELETED(), INSERT INTO 16 Dec 2019 21:13 #12214

  • robert's Avatar

  • robert


  • Posts: 1692
  • Kevin,
    That could work if the cursor(s) are IEnumarable collections, and that is something that we will indeed look at. Not just for this but also to allow to bind a cursor/workarea to a grid or form natively.

    Robert
    XSharp Development Team
    The Netherlands

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

    • Page:
    • 1