Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Christian Tabligan
  Where is Christian Tabligan?
 Bacolod City, Neg. Occ.
 Philippines
 Christian Tabligan
 To: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 Tags
Subject: RE: replacing fields using SQL statements?
Thread ID: 188802 Message ID: 189022 # Views: 1 # Ratings: 0
Version: Visual FoxPro 7 Category: Databases, Tables and SQL Server
Date: Wednesday, August 13, 2008 1:37:43 AM         
   


> >
> > If Students is a very small table and Personal a very big table it would be most efficient to SCAN Students
> >
> > It's efficient if you select all records from students before you scan it.
> >
> > I prefer to save what record has been updated.
> >
> >
create cursor temp (cId c(4))
> > insert into temp values ("0001") && save here what PK has been updated.
> > insert into temp values ("0002")
> > insert into temp values ("0003")
> > SELECT * FROM Student Where Student.Studentid IN (SELECT temp.cId FROM temp) INTO CURSOR curStudent
> > SELECT curStudent
> > SCAN
> >     lcFname = curStudent.FirstName
> >     lcLname = curStudent.LastName
> >     lnStudentId = curStudent.Studentid
> >     Update Personal Set Personal.FirstName = lcFname, ;
> >          Personal.LastName = lcLname ;
> >          Where Personal.Studentid == lnStudentId 
> > ENDSCAN

> >
> > That way, you only SCANned selected students.
> >
> > CriZ (,")
> >
> > "Everyone is entitled to their own opinion, but not their own facts."
>
> We are on the same wavelength here. It's part of the solution in message 188867.
> What I don't think is a good idea is starting up the Update command 2000 times in a SCAN loop. Every SQL comand has a slight setup time. Multiplied by 2000 it can grow into a lot of time.
> A command like
>
 Update Personal Set Personal.FirstName = curStudent.firstname, ;
>           Personal.LastName = Curstudent.lastname ;
>           WHERE SEEK(studentid,'curstudent') 
> 
which is a VFP solution and only starts UPDATE once will likely be more efficient.
> A single REPLACE ALL .. FOR .. or a SCAN loop with REPLACE also work faster.

Oh! i noticed earlier that i used sql update...where which starts searching the record from the beginning of the record while replace...for is a little bit faster because it only search where the certain record must be located.

CriZ (,")

"Everyone is entitled to their own opinion, but not their own facts."

ENTIRE THREAD

replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 7:32:01 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 7:51:41 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 8:50:13 AM
RE: replacing fields using SQL statements? Posted by surinder singh @ 8/12/2008 8:58:04 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 8:59:56 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 9:13:52 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 9:21:39 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 9:26:53 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 9:31:13 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 9:42:44 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 9:51:47 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 9:32:13 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 9:36:22 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 9:40:11 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 9:47:46 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 9:51:54 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 10:08:44 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 10:15:04 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 10:30:31 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 10:04:03 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 10:06:09 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 10:08:47 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 10:16:18 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 10:16:33 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 10:17:46 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 10:33:16 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 10:38:20 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 10:46:36 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 10:50:52 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 10:57:30 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 10:55:20 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/12/2008 11:04:20 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 10:15:09 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 10:17:07 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 10:41:58 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 10:45:06 AM
RE: replacing fields using SQL statements? Posted by Anders Altberg @ 8/12/2008 11:03:29 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/12/2008 11:34:10 AM
RE: replacing fields using SQL statements? Posted by Anders Altberg @ 8/12/2008 11:39:25 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 12:03:04 PM
RE: replacing fields using SQL statements? Posted by Anders Altberg @ 8/12/2008 12:06:56 PM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/12/2008 12:16:09 PM
RE: replacing fields using SQL statements? Posted by Anders Altberg @ 8/12/2008 2:37:59 PM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/13/2008 1:37:43 AM
RE: replacing fields using SQL statements? Posted by suhas hegde @ 8/18/2008 9:34:27 AM
RE: replacing fields using SQL statements? Posted by Anders Altberg @ 8/18/2008 12:06:57 PM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/14/2008 2:54:04 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/19/2008 3:16:17 AM
RE: replacing fields using SQL statements? Posted by Christian Tabligan @ 8/19/2008 6:30:36 AM
RE: replacing fields using SQL statements? Posted by Anders Altberg @ 8/14/2008 5:54:42 PM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/18/2008 3:08:54 AM
RE: replacing fields using SQL statements? Posted by Jim Booth @ 8/18/2008 4:06:05 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/18/2008 6:22:33 AM
RE: replacing fields using SQL statements? Posted by Anders Altberg @ 8/18/2008 11:58:04 AM
RE: replacing fields using SQL statements? Posted by Glenn Villar @ 8/18/2008 12:29:21 PM
RE: replacing fields using SQL statements? Posted by lopera @ 8/14/2008 3:27:18 AM
RE: replacing fields using SQL statements? Posted by Dianne Benedicto @ 8/14/2008 10:05:58 AM
RE: replacing fields using SQL statements? Posted by Anders Altberg @ 8/14/2008 6:02:54 PM