Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Stewart Chew
  Where is Stewart Chew?
 
 Malaysia
 Stewart Chew
 Tags
Subject: RE: Insert & Update records
Thread ID: 145129 Message ID: 145996 # Views: 18 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, September 20, 2007 1:45:31 PM         
   


> Dear Ken,
>
> Thanks for your feedback and advise. I've another question need your advise. At first i SELECT all the data INTO CURSOR cMrsShare READWRITE and SELECT * FROM wrk_ordr WHERE date = {^1999/01/01} INTO CURSOR cWrkOrdr READWRITE (i need to create a blank READWRITE CURSOR, that's why i select the date on {^1999/01/01} ).
>
> Then i click on THISFORM.Command1 (Update MRS) to update & insert records at m_updmrs.scx and save it on CURSOR cWrkOrdr & cMrsShare. My EndUser need to insert and update a lot of records at the same time. After they finish, i create another FORM to let them POST (Update and Insert all the records) all the records from CURSOR cWrkOrdr to fews database.
>
> My question is :-
> 1. Is it the way to do that?
> 2. If a lot of data inside the CURSOR cWrkOrdr, take time to update & insert records. Is there anyway to change any method to doing this? Maybe need to change all the structure?
>
> I'll resolve my previous problem by using SET MULTILOCK ON & CURSORSETPROP("Buffering", 5).
>
> Thanks.
>
> Regards,
>
> Stewart Chew

It sounds as if you want to create a "data input batch." If this is the case, then you probably want to use a local table stored in a c:\Documents and Settings\UserName\Application Data\MyApp folder. This way, your user can enter part of a batch, exit the app, and then come back and finish it later. Using a cursor, created from a SELECT ... WHERE .f. INTO CURSOR ... when the user exits the app, your cursor (and any data entry work) is destroyed if it is not saved to a table.

If your updates take a long time to do, it is typically because your UPDATE and INSERT commands are not optimized. Take a look at your UPDATE and INSERT commands, especially the WHERE clause and make sure that you have an index on every field that you see in your WHERE clause.

You ask, "Is it the way to do that?" Most VFP developers will tell you that "if you haven't found three ways to do anything in VFP you haven't tried." There are always other ways to do things :) Is this the "best" way to do it? Again, if you ask three VFP developers "what is the best way to ..." you are likely going to get four answers. Good design always follows the function. Do you need to be able to "save a data input batch" and then go back in to complete it later? It may be that when you look at the requirements more closely, you will find that what you really want is to restrict the user to one open item (work order/Invoice/what ever) at a time.

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)



COMPLETE THREAD
Insert & Update records Posted by Stewart Chew @ 9/13/2007 8:47:55 AM
RE: Insert & Update records Posted by tushar @ 9/13/2007 10:12:55 AM
RE: Insert & Update records Posted by Stewart Chew @ 9/13/2007 11:33:53 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/13/2007 12:40:19 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/18/2007 3:54:33 AM
RE: Insert & Update records Posted by tushar @ 9/18/2007 11:44:22 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/18/2007 2:12:41 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/19/2007 2:39:21 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/19/2007 2:55:43 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/20/2007 4:18:16 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 1:45:31 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:05:02 PM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 2:14:16 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:26:32 PM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 2:43:10 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:00:53 PM