Paradox Community

Items in pnews.paradox-programming

Subject:Re: New fields to existing table
Date:Wed, 4 Apr 2018 11:53:28 +0100
From:Roger Phil <roger@agent2000.co.uk>
Newsgroups:pnews.paradox-programming
Ah restructureadd seems like the comand I'm looking for. Thanks very 
much Kevin I shall look through that.

Kevin Zawicki wrote:
> 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
>>
>


-- 
RogerD


Copyright © 2004 thedbcommunity.com