Board index » delphi » Database desktop will not create PAradox 7.0 table

Database desktop will not create PAradox 7.0 table

Hi,

I'm having difficulty in creating a Paradox 7.0 table in DD.  I select P7.0
in the combo when creating a new table but when I save and re-open it, DD
says it's a P4.0 table.

The only way around this problem was to create a table and to "Borrow..."
the fields from a different P7.0 table (which wasn't created w/ DD).

How can I circumvent this problem?

Joubert Nel

 

Re:Database desktop will not create PAradox 7.0 table


Joubert wrote in article <01bc57a1$9b0553a0$173f0bc4@katmai>...

Quote
>Hi,

>I'm having difficulty in creating a Paradox 7.0 table in DD.  I select
P7.0
>in the combo when creating a new table but when I save and re-open it, DD
>says it's a P4.0 table.

>The only way around this problem was to create a table and to "Borrow..."
>the fields from a different P7.0 table (which wasn't created w/ DD).

>How can I circumvent this problem?

>Joubert Nel

Use a Paradox 7 specific feature, like a descending index, in your table.
Then, remove it if you like. Your table will remain version 7.

Likewise, adding a LongInt or Logical field will force a table to become
level 5 that would have otherwise been a 4.

I thought there was a setting in BDECFG, but the "Level" setting only
refers to temporary tables, according to the help for BDECFG in BDE 3.5.

What does the 7.0 table do for you if one of these features is not
included?

Re:Database desktop will not create PAradox 7.0 table


The BDE will create a table based on the types of fields in the table. If
your table uses only simpler types, stings, dates, integers, etc. then
your table level will most likely be 4. If you add the newer field types,
(autoincrement, BCD, Formatted memo), then the table level jumps to 5. If
you add a descending secondary index, (I think that's what it is), then
the table level will jump to 7.
     The table level is really irrelevant to the BDE, so it shouldn't
matter.

hope this helps...

Brad Miller
Timeoil...@aol.com

Re:Database desktop will not create PAradox 7.0 table


Quote
"Joubert" <joub...@pixie.co.za> wrote:
>Hi,
>I'm having difficulty in creating a Paradox 7.0 table in DD.  I select P7.0
>in the combo when creating a new table but when I save and re-open it, DD
>says it's a P4.0 table.
>The only way around this problem was to create a table and to "Borrow..."
>the fields from a different P7.0 table (which wasn't created w/ DD).
>How can I circumvent this problem?
>Joubert Nel

Paradox will create the lowest level table possible to maintain the
most backward compatability. If you only use field type that were
available in v4.0 then thats what you'll get.  To create a Paradox 7.0
table you need to use at least one of the new paradox 7 fields.

Re:Database desktop will not create PAradox 7.0 table


I thought this was done in with the BDE configuration utility-

Start the BDE utility
Set the LEVEL field to 7

Also, if you intend using very large tables (100000 records +) I suggest
you increase the block size to 4096.

Pierre

rosulli...@monmouth.com wrote in article <5lb6fv$...@news.monmouth.com>...

Quote
> "Joubert" <joub...@pixie.co.za> wrote:

> >Hi,

> >I'm having difficulty in creating a Paradox 7.0 table in DD.  I select
P7.0
> >in the combo when creating a new table but when I save and re-open it,
DD
> >says it's a P4.0 table.

> >The only way around this problem was to create a table and to
"Borrow..."
> >the fields from a different P7.0 table (which wasn't created w/ DD).

> >How can I circumvent this problem?

> >Joubert Nel

Re:Database desktop will not create PAradox 7.0 table


Or alternatively you can fire up to the BDE config' program and go to the
driver page where you will find an entry called 'Level'. Here you can
specify the minimum level of table to create in Paradox. By default it is
level 4. Change it to level 7

Stephen

rosulli...@monmouth.com wrote in article <5lb6fv$...@news.monmouth.com>...

Quote
> "Joubert" <joub...@pixie.co.za> wrote:

> >Hi,

> >I'm having difficulty in creating a Paradox 7.0 table in DD.  I select
P7.0
> >in the combo when creating a new table but when I save and re-open it,
DD
> >says it's a P4.0 table.

> >The only way around this problem was to create a table and to
"Borrow..."
> >the fields from a different P7.0 table (which wasn't created w/ DD).

> >How can I circumvent this problem?

> >Joubert Nel

> Paradox will create the lowest level table possible to maintain the
> most backward compatability. If you only use field type that were
> available in v4.0 then thats what you'll get.  To create a Paradox 7.0
> table you need to use at least one of the new paradox 7 fields.

Re:Database desktop will not create PAradox 7.0 table


Quote
Stephen Novotny <dis-peo...@intercoast.com.au> wrote:
> Or alternatively you can fire up to the BDE config' program and go to the
> driver page where you will find an entry called 'Level'. Here you can
> specify the minimum level of table to create in Paradox. By default it is
> level 4. Change it to level 7

Like you said, that setting controls the minimum level of tables when
they are *created*.  The reason Paradox 5 or 7 only create level 4 by
default is to help compatibility when sharing tables with older versions
on others' machines.  It automatically upgrades the tables to a higher
version if required by the data types or secondary indexes etc which
you specify.  It's quite true that you gain nothing by enforcing a higher
table level than you require - there is no performance gain.

However, if you really want to force the table level, the following
contains code which does it.  I grabbed this from one of my old
projects in a hurry - sorry, but I haven't time to explain it in detail.

procedure TMyForm.Restructure(Autoinc:boolean);
var
  hDB:           hDbiDb;
  hTableCursor:  hDbiCur;
  Properties:    CURProps;
  FieldDescs:    PFLDDescs;
  FieldOps:      PCROpTypes;
  TableDesc:     CRTblDesc;
  NewFieldCount: integer;
  i:             integer;
  OptionalParam: FLDDesc;
  OptionValue:   string;
  DirName:       string;
begin
  if not Assigned(Table) then Exit;  // user is handling tables manually
  // If the table is not opened, raise an error.  Need the table open to get
  //   the table directory.
  if Table.Active <> True then raise EDatabaseError.Create(sNotOpenError);
  // If the table is not opened exclusively, raise an error.  DbiDoRestructure
  //   will need exclusive access to the table.
  if Table.Exclusive <> True then
    raise EDatabaseError.Create(sNotExclusiveError);

  Check(DbiGetCursorProps(Table.Handle, Properties));
  // If the table is not a Paradox type, raise an error.
  // These restructuring operations only work with Paradox tables.
  if StrComp(Properties.szTableType, szPARADOX) <> 0 then
    raise EDatabaseError.Create(sMustBeParadoxTable);

  // Get the directory of the opened table.
  SetLength(DirName, DBIMAXTBLNAMELEN);
  Check(DbiGetDirectory(Table.DBHandle, False, PChar(DirName)));
  SetLength(DirName, StrLen(PChar(DirName)));

  // Close the table so we can open a new database for it.
  Table.Close;

  // Open a database session with exclusive read/write access.
  Check(DbiOpenDatabase(PChar(Table.DatabaseName), // alias
                         nil,           // database type (Standard)
                         dbiReadWrite,  // open mode (versus read-only)
                         dbiOpenExcl,   // exclusive (versus shared)
                         nil,           // database login password
                         0,nil,nil,
                         hDB));

  // Set the database's working directory to the table directory.
  Check(DbiSetDirectory(hDB, PChar(DirName)));
  //Check(DbiGetDirectory(hDatabase,False,WorkingDir)); (WorkingDir:DbiPath)

  try
    Check(DbiOpenTable(hDB,PChar(TableName),szParadox,
                       nil,nil,0,dbiReadOnly,dbiOpenExcl,xltField,False,nil,
                     hTableCursor));
    Check(DbiGetCursorProps(hTableCursor,Properties));
    // To fetch the field information we must first have somewhere to put it.
    NewFieldCount := Properties.iFields;  // we're not adding any new fields
    GetMem(FieldDescs,NewFieldCount*sizeof(FLDDesc));  // descriptors
    GetMem(FieldOps,NewFieldCount*sizeof(CROpType));   // operators
    try
      // Fetch the existing field definitions.
      Check(DbiGetFieldDescs(hTableCursor,@FieldDescs[1]));
      if Autoinc then
        begin
          // Modify the first field definition to be autoincrement.
          FieldOps^[1] := crMODIFY;         // the first is modified
          with FieldDescs^[1] do
            begin
              iFldType := fldINT32;
              iSubType := fldstAUTOINC;
              // Had we nominated xltNone (physical) field types then we would
              // probably replace the above with:  iFldType := fldPDXAUTOINC;
            end;
          // Other fields are unchanged.
          for i := 2 to NewFieldCount do
            FieldOps^[i] := crNOOP;
        end;    
      // To force the table level to 7 we pass an "optional parameter"
      // through a separate FLDDesc structure.
      with OptionalParam do
        begin
          StrPCopy(szName,'LEVEL');
          OptionValue := '7';
          iOffset := 0;
          iLen := length(OptionValue)+1;
        end;  
      // Fill out a table descriptor, referring to the structures we've made.
      FillChar(TableDesc,sizeof(CRTblDesc),#0);
      with TableDesc do
        begin
          StrCopy(szTblName,PChar(Table.TableName));
          StrCopy(szTblType,szParadox);
          if Autoinc then
            begin   // column definitions for new table
              iFldCount := NewFieldCount;
              pecrFldOp := @FieldOps^[1];
              pfldDesc := @FieldDescs^[1];
            end;
          // optional parameters
          iOptParams := 1;
          pFldOptParams := @OptionalParam;
          pOptData := @OptionValue[1];  // contiguous memory if > 1 param
        end;
      Check(DbiCloseCursor(hTableCursor));
      Check(DbiDoRestructure(hDB,1,@TableDesc,nil,nil,
                             nil,      // << add Problem table here if required
                             False));
    finally
      FreeMem(FieldOps);
      FreeMem(FieldDescs);
    end;
  finally
    Check(DbiCloseDatabase(hDB));  // closes associated cursors too
  end;
end;

________________________________________________________________
Design Engineer            Hobart, Tasmania     Ph +613 62313083
Otago Technologies P/L     Australia            Fx +613 62313086

Other Threads