Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding columns to a table programmatically...

Status
Not open for further replies.

brigmar

Programmer
Mar 21, 2006
414
US
As there is no builtin command in FPW2.6 that allows additions of columns to a table programmatically, I decided to write something to do the job... (call it a training exercise)

I'm doing a COPY STRUCTURE EXTENDED TO... to a SYS(3) file.
I'm then appending records for the new columns into that table.

I then CREATE ... FROM ... into another SYS(3) file.

Which gives me:
My original table.
A Uniquely Named new table that describes a structure.
A Uniquely Named new table of that structure.

So, now I want to fill the new table with the data from the old table, and I've been given two conflicting stories of how to do this. Please bear in mind that I want to also transfer deleted records to the new table (but marked as deleted).

I was told first that all I need to do is:
SET DELETED OFF
APPEND FROM oldtable
SET DELETED ON

...but later told that this would NOT transfer deleted records...

So I was then given something along the lines of:
SET DELETED OFF
SELECT oldtable
SCAN
SCATTER BLANK MEMVAR
SELECT newtable
APPEND BLANK
GATHER MEMVAR
IF DELETED(oldtable)
DELETE
ENDIF
SELECT oldtable
ENDSCAN
SET DELETED ON

What's the story, and is there a 'cleaner' way to do it if the latter is the 'solution' ???
 
It seems to me a line is missing...
Code:
FUNCTION cSys3
PRIVATE cName
  [COLOR=blue]cName = SYS(3)[/color]
  DO WHILE FILE(cName)
    cName=SYS(3)
  ENDDO
RETURN cName
 
Try this code:
I was thinking that I'd have to write that tight a loop to see SYS(3) repeating itself. Last week I was getting duplicates by creating a cursor with a SYS(3) name, adding a new page to a page frame, adding a grid that page and calling SYS(3) again to create another cursor.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top