INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Create a .MKD file

Create a .MKD file

(OP)
BUTIL -CREATE glddbf.mkd C:\BM_TW_BLR\bmpc\bmbatch\describe\glddbf.des

By issuing the above command in command prompt, GLDDBF.MKD file is created using the structure of GLDDBF.DES

But to my surprise, the GLDDBF.MKD file is not visible in Pervasive Control Center.  But GLDDBF.MKD is available in the Pervasive SQL directory (C:\Documents and Settings\All Users\Application Data\Pervasive Software\PSQL\Demodata), where Demodata is the database name.

I know the files FIELD.DDF, FILE.DDF, and INDEX.DDF are required to make this .MKD available in the Control Center.  I am also aware that we can directly create a .MKD file in the Control Center.  But I had to create the .MKD file by only using the structure of GLDDBF.DES

How to create entries in the above .DDF files while creating a .MKD file?

RE: Create a .MKD file

BUTIL only creates files through the Btrieve interface.  To create an entry in the DDFs, you'll need to either issue a CREATE TABLE statement using a relational interface (ODBC, OLEDB, Managed ADO.NET Provider, JDBC) or use the DTI/DTO interface to create the table.  
 

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Create a .MKD file

(OP)
The problem with using CREATE TABLE statment is that you should be aware of the table structure.

But our requirement is the table structure should be taken from .DBF file.  Using .NET as the front end, I was able to create the table using .DBF file, but all the Datatypes are referring to "VARCHAR".

How do I extract the exact datatype from .DBF files?

 

RE: Create a .MKD file

To extract the data types from a DBF file, you'll need to find out if the provider you are using supports methods like the GetSchemaTable method.  Here's a link on MSDN on Retrieving Database Schema Information that should help.   

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Create a .MKD file

(OP)
Yes, the provider supports the method GetSchemaTable().  Thank you so much for this help.
Now it looks like I am almost going to conclude the Proof Of Concept (POC).

Now I am able to create a .BTR file using the below syntax.
CREATE TABLE GLDDBF USING 'GLDDBF.BTR' (Acc_Nbr varchar(13),Acc_desc varchar(30))

Then I had inserted the record using the below syntax.
INSERT INTO GLDDBF(Acc_Nbr,Acc_desc) values('1111111111111','Account Description')

GLDDBF.BTR is the new file created with some records.  Now I am trying to create a TXT file out of this BTR file.

C:\Documents and Settings\All Users\Application Data\Pervasive Software\PSQL\Demodata>
BUTIL -SAVE GLDDBF.BTR GLDDBF.SAV

Btrieve Maintenance Utility 10.30.017.000
Copyright (C) Pervasive Software Inc. 2009
All Rights Reserved.

BUTIL-93: BUTIL has saved 0 records so far.

BUTIL-93: BUTIL has saved 0 records so far.

BUTIL-14: The file that caused the error is GLDDBF.BTR.
BUTIL-100: MicroKernel error = 6. The key number parameter is invalid.

BUTIL-9: The command did not complete due to an unrecoverable error.

I am not able to create the .SAV file?

RE: Create a .MKD file

(OP)
I just posted a STAT about the .BTR file created....

C:\Documents and Settings\All Users\Application Data\Pervasive Software\PSQL\Dem
odata>butil -stat glddbf.btr

Btrieve Maintenance Utility 10.30.017.000
Copyright (C) Pervasive Software Inc. 2009
All Rights Reserved.

File Statistics for glddbf.btr

File Version = 9.50
Page Size = 4096
Page Preallocation = No
Key Only = No
Extended = No

Total Number of Records = 11212
Record Length = 1667
Record Compression = No
Page Compression = No
Variable Records = No

Available Linked Duplicate Keys = 0
Balanced Key = No
Log Key = SYSKEY
System Data = Yes
   SYSKEY Status = Present
Total Number of Keys = 0
Total Number of Segments = 0

The command completed successfully.

RE: Create a .MKD file

BUTIL -SAVE uses an index to read records.  Since your table has no indexes, you should use BUTIL -RECOVER.  

That being said, BUTIL will only save data as a record image.  It does not save field information or save the record delimited in any way.  For example, here is part of a BUTIL -SAVE/RECOVER file:

Quote:

66,   ACC 101001 # Ë     2
Bhargava Building        e   Ž5    
66,   ACC 101002 # Ë     2Bhargava Building        f   Ž5    
66,   ACC 101003 ! Ë     2Bhargava Building        É   Ž5    

While some fields are recognizable, others are not.  

What are you trying to do with this TXT file?   

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Create a .MKD file

(OP)
The purpose of converting .BTR file to .TXT file is to check the validity of the .BTR file.

This is being the usual practice to check whether the .BTR file is valid or not.

When I tried to use the .BTR file in another program, I got the below error:

Fatal Btrieve Error in dbOpen
File = C:\GLDDBF.BTR, Error # 30

Pls tell me how do I make this .BTR file a valid one?
It looks like i have to create a Index for this .BTR file.  So this Index has to be created along with "CREATE TABLE" syntax or how?

RE: Create a .MKD file

If you can issue a BUTIL -STAT on the file, it is valid.  If you can Open, Insert, and Read data from a Btrieve file, it is a valid file.  

If an application is getting a status 30 with your new file, my guess is that it is using an older version of PSQL/Btrieve.  You're file is v9.50 format.  If PSQL V8 or earlier(PSQL 2000, Btrieve 6.x,etc.) tries to open the file, a status 30 is returned.   

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Create a .MKD file

(OP)
With your help, I was able to create a EXE generated through C#.NET 2.0 and Pervasive SQL v10.10 as the backend.  The EXE will read .DBF file, create a .MKD file, dump the records from .DBF file to that .MKD file.

This EXE will be running on a daily basis.  So supposing this EXE runs on the 2nd day will it throws a error saying "This table exists".

So I wanted to delete the existing table only if it exists?  Will the DROP TABLE command deletes all the entries like <TABLE NAME>.MKD, entries from DDF files?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close