#7 Components - TRestructure Lite/Pro
Contents
This is a component written to help you restructure your tables in a very straightforward and efficient way. The component is a wrapper around BDE's DbiDoRestructure function. You don't have to worry about all those C-like function calls any more.
Now it's very easy to restructure a table, for example:
or, the same thing in Borland C++ Builder:Restructure1.DatabaseName := 'TestAlias';
Restructure1.TableName := 'TestTable.DB';
Restructure1.Field.Name := 'TestField';
Restructure1.Field.FieldType := pxAlpha;
Restructure1.Field.Length := 25;
Restructure1.ValCheck.Required := True;
Restructure1.PackTable := True;
Restructure1.InsertField(2, True);
Restructure1.Apply;
Restructure1->DatabaseName = "TestAlias";
Restructure1->TableName = "TestTable.DB";
Restructure1->Field->Name = "TestField";
Restructure1->Field->FieldType = pxAlpha;
Restructure1->Field->Length = 25;
Restructure1->ValCheck->Required = True;
Restructure1->PackTable = True;
Restructure1->InsertField(2, True);
Restructure1->Apply();
The above example will insert TestField as the second field in TestTable, and assign it a Required validity check. The table will also be packed in the process of restructuring. Have a look at the DEMO source code (included in this zip) for more examples on component usage.
Properties, methods and events of TRestructure Lite/Pro
Properties:
DatabaseName
|
The database name. It can be existing alias,
or a directory.
|
||
+Field
|
|||
FieldType | Field type. For Paradox tables, use the types with prefix 'px', and for dBase tables prefix 'db'. | ||
Length | Specifies the field length (if applicable). | ||
Name | Field name. | ||
Precision | Field precision - only for dBase tables - specifies number of digits in the fractal part of the field. | ||
PackTable
|
A
Boolean value specifying whether to pack the table when applying changes.
If there are no pending changes, and this property is TRUE, the table
is packed.
|
||
TableName
|
The
table name. Must exist in the database specified in DatabaseName.
|
||
+ValCheck
|
|||
DefaultValue | Specifies default value for the field. | ||
LookupAccess | Two values can be entered: laFillNoHelp and laHelpAndFill. Ignored if LookupTableName is empty string. | ||
LookupDatabaseName | The database name of the lookup table. It can be existing alias, or a directory. | ||
LookupTableName | The lookup table name. Must exist in the database specified in LookupDatabaseName. | ||
LookupType | Two values can be entered: ltCurrentField and ltCorresponding. Ignored if LookupTableName is empty string. | ||
MaximumValue | Specifies maximum value for the field. | ||
MinimumValue | Specifies minimum value for the field. | ||
Picture | Specifies picture string for field input. | ||
Required | Specifies whether the field is required. |
TRestructure Pro includes all of the above properties as well as the following:
PrimaryIndexFieldCount | Simply change this property to change the primary index | ||
+RefInt | |||
DeleteOperation | Two values can be entered: urRestrict or urCascade. | ||
MasterTableName | Specifies the master table's name. | ||
ModifyOperation | Two values can be entered: urRestrict or urCascade. |
Methods:
procedure GetFieldDesc(Position: Integer) | Fills all the field and validity check properties with the values from the actual table. Look at the DEMO source. | |
function FieldByName(FldName: String): Integer | Returns the field number, based on field name. | |
procedure AddField(lAddValChecks: Boolean) | Adds a field to the end of field order and adds validity check for that field (if lAddValChecks is TRUE). | |
procedure InsertField(Position: Integer; lAddValChecks: Boolean) | Inserts a field at a specified Position, and optionally adds a validity check for that field. | |
procedure MoveField(OldPos, NewPos: Integer) | Moves a field from OldPos to NewPos position. | |
procedure DropField(Position: Integer) | Deletes (removes) a field. | |
procedure ChangeField(Position: Integer; lChangeValChecks: Boolean) | Changes any (or all) field properties, and/or validity checks. | |
function HasValChecks(FldName: String) | Checks whether a field has any validity checks associated. | |
procedure AddValCheck(FldName: String) | Adds a validity check (specified in ValCheck property) to a field. | |
procedure ChangeValCheck(FldName: String) | Changes validity check. | |
procedure DropValCheck(FldName: String) | Removes validity check from a field. | |
procedure Apply | Applies all pending changes to table structure. | |
procedure Cancel | Cancels all pending changes to table structure. |
TRestructure Pro includes all of the above methods as well as the following:
function HasRefInts: Boolean; | Returns True if the table has any referential integrity constraints. | |
procedure AddRefInt(RIName, DetIdx: String); | Adds a referential integrity constraint to the table. | |
procedure DropRefInt(RIName: String); | Removes specified referential integrity constraint. | |
procedure AddMasterPassword(Password: String); | Protects the table by adding a master password. | |
procedure ChangeMasterPassword(Password: String); | Changes existing master password. | |
procedure DropMasterPassword; | Removes master password. Any auxiliary passwords are removed also. | |
procedure AddAuxPassword(AuxPassword: String; TableRights: TTableRights); | Adds an auxiliary password and specifies user's rights on the table. | |
procedure ChangeAuxPassword(OldAuxPassword, NewAuxPassword: String; TableRights: TTableRights); | Changes an auxiliary password or user rights (or both). | |
procedure DropAuxPassword(AuxPassword: String); | Removes specified auxiliary password. | |
procedure ChangeFieldRights(AuxPassword, FieldName: String; Rights: TFieldRights); | Changes the rights user has on a field level, depending on that user's table rights. When you add an auxiliary password to the table, all field rights are set to frReadWrite. Other possible values are: frReadOnly and frNone. |
Events:
OnFieldInappropriate | This event triggers each time you try to add or change field type that is not appropriate for the used table level. |
Delphi, all versions:
Start Delphi, open RestructurePack.dpk, compile and close it. Open DclRestructurePack.dpk, compile, install and close it.
If Delphi complains about not being able to find any .dcu, .dpl, or .bpl, simply copy the file that Delphi is looking for to "C:\Windows\System".
C++ Builder 3:
Start C++ Builder, open RestructurePack.bpk, compile and close it. Open DclRestructurePack.bpk, compile and close it.
Select Install Packages... option in menu Component and click on the Add... button. Now select DclRestructurePack.bpl file and click on the Open button.
C++ Builder 4 and 5:
Start C++ Builder, open RestructurePack.bpk, compile and close it. Open DclRestructurePack.bpk, compile, install and close it.
July 12, 2000. | 1.20 | First public release. |
August 29, 2000. | 1.24 |
Bugs corrected:
All these bugs were discovered by Mr. Fabio Lindner. Many thanks. |
February 15, 2001. | 2.10 | Two versions available: TRestructure Lite and TRestructure Pro. The Pro version includes all the functionality of the Lite version, plus: setting and changing both master and auxiliary passwords, table and field rights for any user, changing the primary index (adding, deleting or changing) and referential integrity constraints (adding or deleting). |
February 20, 2001. | 2.11 | Bug squashed - adding an auxiliary password to a table that doesn't already have one resulted in error. Thanks to Ove Bjerregaard. |
June 25, 2001. | 2.12 | Added
support for Borland C++ Builder versions 3, 4 and 5 in TRestructure
Pro. Added support for Delphi 6 in TRestructure Pro. |
June 21, 2002. | 2.13 | Added support for Borland C++ Builder version 6 in TRestructure Pro. |
September 23, 2002. | 2.14 | Added support for Delphi 7 in TRestructure Pro. TRestructure Pro now works with national character sets (field names, validity checks etc. can contain language-specific characters). |
Help file is being prepared as well as a new demo program that shows how to do all the stuff this component has to offer. At the moment, we are considering whether to develop a library of functions/procedures related to table restructuring/maintenance.
There are no known bugs at this time. If you find some bugs, please report to support@sedlan.com, and we will send you source code for free, once the bug is corrected. Please remember to include your email address, otherwise we will not be able to send you the source.
Email address support@sedlan.com is available for all your comments, questions and ideas. If you'd like to see some additional functionality in this component, please contact us.
By registering one or more licenses, you have the right to incorporate this component into as many as you like applications royalty-free.
If you decide to purchase the license for this, or any other #7 Component, you will get one year upgrades free of charge. New versions of components will be available to you at significantly lower price after the period of one year (during which you get all new versions for free). You will also receive a phone number for technical support.
Visit http://www.sedlan.com/redirect.php?gobuy7rest and register online. All major credit cards apply through secure Internet protocol. You can also register via fax, international mail order, bank wire, Postcheque, UK Cheque or US Check.
Please read carefully License.txt file before using this software.