Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Koen Piller
  Where is Koen Piller?
 Santpoort-Zuid
 Netherlands
 Koen Piller
 To: Matt Slay
  Where is Matt Slay?
 Birmingham
 Alabama - United States
 Matt Slay
 Tags
Subject: RE: Help with Gather and AutoInc field
Thread ID: 209377 Message ID: 209385 # Views: 1 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Sunday, December 28, 2008 8:49:44 AM         
   


> Need some guidance here... I am trying to copy the data in one record to a new record in the same table, then change the JobNo field to some new Job umber that I already have and validated as unique.
>
> The problem is that the table has an AutoInc field named "ipkey", and VFP does not want to let me do a GATHER for obvious reasons.
>
> So, I understand why it has this limitation because of autoinc, I just want to know how one works around it.
>
> Presently, to get around it, I am doing a REPLACE command on every field except ipkey, but I was hoping to use the SCATTER NAME / GATHER NAME method to avoid having to list out every field, and so I would have code that is independent of the field names.
>
> Here's what I wanted to use:
>
> Select 0
> Use Jobs order jobno
> ... navigate to the desired record ..
> SCATTER NAME loCurrentJob
> Append Blank
> Gather NAME loCurrentJob
> replace JobNo with lcNewJobNo && a passed in value, already validated
Matt,

you could try:

select myTargetTable 
append blank
lcID = myPKfield
select mySourceTable
scatter fields except myPKField name lrMySource
select myTargetTable 
locate for lcID = myPKField
gather from lrMySource


regards,

Koen

ENTIRE THREAD

Help with Gather and AutoInc field Posted by Matt Slay @ 12/28/2008 4:50:36 AM
RE: Help with Gather and AutoInc field Posted by Jun Tangunan @ 12/28/2008 6:28:57 AM
RE: Help with Gather and AutoInc field Posted by tushar @ 12/28/2008 10:06:17 AM
RE: Help with Gather and AutoInc field Posted by Matt Slay @ 12/28/2008 9:24:39 PM
RE: Help with Gather and AutoInc field Posted by Koen Piller @ 12/28/2008 8:49:44 AM