locked
APPEND FROM RRS feed

  • Question

  • Hello Experts,

    I am trying to Append from a CSV file and it seems to work fine, however once the data is visible in application
    I am unable to edit the data, I get a "Record out of Range" error

    Also I dont even see the data in the dbf, i dont get it, not sure what im doing wrong here, how does it apear in the application without being in the database

    here is how I append

    IF !USED('Customers')
       USE Customers IN 0
    ENDIF
    SELECT Customers
    APPEND FROM c:\test.csv TYPE DELIMITED

    any help would be greatly appreciated


    • Edited by mikelvfp Saturday, November 22, 2014 1:18 PM added more info
    Saturday, November 22, 2014 1:14 PM

Answers

  • So you see the data in a grid, right?

    But what do you do to get "Record out of Range"? Actually there only is one command, that could cause this: GO /GOTO RECORD.

    Add a breakpoint after the APPEND and then BROWSE. Do you see data?

    Now ? RECNO(), do you get negaitve record numbers? Then your table is in buffer mode, the data you appended is not saved yet to the DBF file.

    We had buffering explained already. It was long ago, but if I'm right with my assumptions look it up in the help, you'll see.

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH http://www.tmn-systemberatung.de


    • Edited by Olaf Doschke Saturday, November 22, 2014 4:34 PM
    • Marked as answer by mikelvfp Monday, November 24, 2014 1:26 AM
    Saturday, November 22, 2014 4:07 PM

All replies

  • So you see the data in a grid, right?

    But what do you do to get "Record out of Range"? Actually there only is one command, that could cause this: GO /GOTO RECORD.

    Add a breakpoint after the APPEND and then BROWSE. Do you see data?

    Now ? RECNO(), do you get negaitve record numbers? Then your table is in buffer mode, the data you appended is not saved yet to the DBF file.

    We had buffering explained already. It was long ago, but if I'm right with my assumptions look it up in the help, you'll see.

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH http://www.tmn-systemberatung.de


    • Edited by Olaf Doschke Saturday, November 22, 2014 4:34 PM
    • Marked as answer by mikelvfp Monday, November 24, 2014 1:26 AM
    Saturday, November 22, 2014 4:07 PM
  • Your right about 98.9% of the time, this time you were right 100% I was using GOTO RECNO(), now Im using SEEK, working fine. I also had my table in buffer mode.

    So what I do to APPEND FROM my .csv file is I set buffermode to

    CURSORSETPROP("Buffering", 1, "CUSTOMERS")

    just before I APPEND, and then I set buffermode back to 

    CURSORSETPROP("Buffering", 5, "CUSTOMERS")

    I do the same with MULITLOCKS, where it is OFF before I APPEND and ON after the process is complete.
    I hope this is ok as it works flawlessly 


    Monday, November 24, 2014 1:02 AM
  • Okay, I cant understand why this stopped working 

    please help

    I see the data in the grid, its obviously commited to changes, is my seek not working?
    I dont get it

    Monday, November 24, 2014 4:21 AM
  • You changed from GOT to SEEK. That's not needed, if you change to unbuffered APPEND, because now your APPEND goes straight to the DBF and so every new record will have a recno>0. Actually GOTO also works with negative recnos, the problem is, when you remember a negative recno, the record is stored and gets a positive recno and you then go to the non existing negative recno. So my guess is you where previously at row buffering.

    You could also have added a TABLEUPDATE after the APPEND.

    Anyway, there always are more solutions and any working solution is fine. Changing from GOTO to SEEK you need an index set. A SEEK is always seeking in existing data and will never give you a "Record out of Range", it'll just eventually not find a record matching and then go to EOF.

    So what index are you using and what value are you seeking?

    Without any code it's hard to guess what's going on.

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH

    http://www.tmn-systemberatung.de

    Monday, November 24, 2014 7:14 AM
  • Hi Olaf,

    here is the code I am using

    LPARAMETERS cxid
    
    SELECT CUSTOMERS
    
    IF EMPTY (m.cxid)
    	APPEND BLANK IN CUSTOMERS
    	
    ELSE
    	SET ORDER TO CUSTOMERID
    	SEEK (m.cxid)
    
    ENDIF

    i do not get record out of range anymore. The data appears in the table and in the grid but when I double click on the record to edit or view I get a blank record?


    Monday, November 24, 2014 1:38 PM
  • Q1 - why are you appending a blank record when cxid is empty?

    Q2 what is the relationship between the form containing the grid of data and the form launched when you double click a grid line to edit the data? This "relationship" between the forms is vital. Please give more details as otherwise everyone is making assumptions that might not be true.


    The English Bob

    Monday, November 24, 2014 3:40 PM
    Answerer
  • Q1 Answer - I append blank when a new customer is created else if the customerid is found I open the existing customerid.  This works just fine with records created from within my application, the only trouble I have is viewing records appended from CSV

    Q2 - The relation is in the customerid


    • Edited by mikelvfp Monday, November 24, 2014 4:57 PM typo
    Monday, November 24, 2014 4:55 PM
  • Hey Olaf & Bob,

    I figured it out, lol kind of difficult to explain but It had to do with the way I would do a table update in a single user environment and a multi-user environment .

    It works , the issue was all on me Im sorry for the headache

    Monday, November 24, 2014 5:46 PM
  • I see you have figured it out.

    I still want to refer to this one. First you jump from appending from CSV to APPEND of a single new record with APPEND BLANK. I can't see how that relates.

    When you double click on a record in a grid and you trigger the above code without a cxid that would explain an extra empty record, wouldn't it? Anyway, it's not clear how a double click relates to all this, but you seem to have your events wired up very hard to debug. Consider a refactoring, that is a redesign of your overall grid code, to have less headaches in general.

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH http://www.tmn-systemberatung.de

    Monday, November 24, 2014 6:46 PM