Unit AutoInc

Classes

Functions

DemoRestructure - After importing existing data into a table with a unique integer first field I wanted to restructure it to have an ftAutoInc primary key.

Types

Constants

Variables


Functions


procedure DemoRestructure(const DatabaseName:TFileName; const TableName:TFileName);

After importing existing data into a table with a unique integer first field I wanted to restructure it to have an ftAutoInc primary key. This code achieves that using BDE calls. The main trick is that you must import the values into an unkeyed table with ftInteger field, restructure first to establish a primary key, then restructure a second time to convert the field into ftAutoInc. It only works if you restructure in separate steps. By request I've added code to show how you'd add extra fields to the table, should you need to. What's more, at no extra cost, it will even spit out a key violation table if your imported key data happens not to be unique. This procedure assumes you've already imported data into a source table which is Paradox Level 5 or above and has at least three fields, the first being ftInteger. The table must have no key or secondary indexes and it must be closed when you call. Here's what it does: • Adds a primary index • Converts first table field from ftInteger to ftAutoInc. • Between the 2nd and 3rd fields it inserts the following new fields: Dish A 60 (string) Serves S (shortint/Word) Recipe M 1 (memo) • Assigns a default value Serves=6, applied to new and existing data. Sorry I haven't time to write a full-blown demo project, but this code *does* work. Mail me if you find it useful... Delphi 2.0 freeware by G.Walker, December 1996 gw@enternet.com.au

-----------------------------------------------------------------------


Types


Constants


Variables