Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a .MKD file

Status
Not open for further replies.

sadhramani

Programmer
Jun 8, 2010
19
CA
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?
 
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
 
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?

 
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?
 
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.
 
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:
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
 
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?
 
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
 
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top