Definition: | integer i = db_create(string st, integer locktype) |
Description: | Create a new database. A new database will be created in the file with path given by st. locktype indicates the type of lock that will be applied to the file as it is created. i is an error code that indicates success or failure. The values for locktype can be either DB_LOCK_NO (no lock) or DB_LOCK_EXCLUSIVE (exclusive lock). i is DB_OK if the new database is successfully created. This database becomes the current database to which all other database operations will apply. |
Comments: | If the path, s, does not end in .edb, it will be added automatically.
A version number is stored in the database file so future versions of the database software can recognize the format, and possibly read it and deal with it in some way. The return codes are: DB_OK(0) - success, DB_OPEN_FAIL(-1) - could not open the file, DB_EXISTS_ALREADY(-2) -- file already exists, and theoretically DB_LOCK_FAIL(-3). |
Example: |
if db_create("mydata", DB_LOCK_NO)!=DB_OK then puts(2, "Couldn't create the database!\n") abort(1) end if |
See Also: | db_open, db_close |