Paradox Community

Items in pnews.paradox-programming

Subject:Re: New fields to existing table
Date:3 Apr 2018 23:44:47 -0400
From:"Kevin Zawicki" <numberjack@wi.rr.com>
Newsgroups:pnews.paradox-programming

Yes, I think you can use the restructure method....

restructure uses a dynamic array named createSpec, which contains the information
on the changes to make to the table.

To specify the kind of change to be made, the field, index, referential integrity,
and security structure tables, if specified, must include an ID field. This
ID field is named slightly differently in each structure file, however, all
end with id. Use this ID field to specify the type of operation to perform.
The RestructureOperations constants RestructureModify, RestructureAdd, and
RestructureDrop are provided for each operation.


The following example appears in a script window and modifies the Customer
table by changing a field name. This code uses enumFieldStruct to create
the field structure information, updates the information, copies the updated
information to a dynamic array and passes the dynamic array to the restructure
method:


method run(var eventInfo Event)
var
     tbl         Table
     tcFlds      TCursor
     dynNewStru  DynArray[] Anytype
endvar

tbl.attach( "Customer.db" )
tbl.enumFieldStruct( "field_struct.db" )

tcFlds.open("field_struct.db" )
tcFlds.edit()

scan tcFlds :
   if tcFlds."Field Name" = "Name" then
      tcFlds."Field Name" = "Company Name"
      quitLoop
   endif
endscan
tcFlds.endEdit()
tcFlds.close()

dynNewStru["FIELDSTRUCT"] = "field_struct.db"
tbl.restructure( dynNewStru )
endmethod

Roger Phil <roger@agent2000.co.uk> wrote:
>Would anyone know if it's possible in opal to add extra fields to an 
>existing table without using enumfieldstruct to create a new table and 
>then adding records ?
>
>
>-- 
>RogerD
>
>---
>This email has been checked for viruses by Avast antivirus software.
>https://www.avast.com/antivirus
>


Copyright © 2004 thedbcommunity.com