Switch to: V10V9V8V7V6V5

VDatabase Class: Disk Methods

VDatabase.Close()

Declaration:

Close()

Description:

Closes the database.

Example:

db.Open()
....
db.Close()

VDatabase.Clone()

Declaration:

Clone( 
	inTargetDb as FolderItem, 
	inLoadRecords as Boolean = true )

Parameters:

  • inTargetDb - The Path for a new database.
  • inLoadRecords - If TRUE then records are copied into the cloned database.

Description:

This function creates a new database, which is a logical clone of the cloned database. We say logical because physically it is not identical. For example the space used with deleted records will not be copied. This means that the cloned database can be smaller than the original one. Be aware that as a result of the cloning process record id's (RecID field information) will change (reassigned to previously deleted space) as will the object pointers (but ONLY the object pointers) pointing at this reassigned record. This is the main reason to NEVER store RecID information in other fields than object pointers.

On default records also are copied into the cloned database. You can specify inLoadRecords to be FALSE to clone only the Database Structure. See the details in the ValentinaKernel.pdf.

NOTE: The Valentina engine may show some information (e.g. about corrupted fields/records if any) into a WarningLog if this functionality was enabled.

Example:

newDbLocation = GetOpenFolderItem()
db.Clone( newDbLocation )

VDatabase.Clone()

Declaration:

Clone( 
	inTargetDb as VDatabase, 
	inLoadRecords as Boolean = true )

Description:

The same as above except the fact that the first parameter is not a disk location, but an already existing VDatabase object.

This form allows you to create a new empty VDatabase and specify some parameters of VDatabase, e.g. Mode, SegmentSize. Later the Clone() method will copy the rest of the structure and records into this database.

Example:

newDbLocation = GetOpenFolderItem()
 
dbCloned = new VDatabase
dbCloned.Create( newDbLocation, kDscDatBlb_Ind, 8 * 1024 )
 
db.Clone( dbCloned )

VDatabase.Create()

Declaration:

Create(	
    inLocation as Path, 
    inMode as EVDbMode =  kDsc_Dat_Blb_Ind,  
    inSegmentSize as Integer = 32768,
    inNativeOS as EVOs = kOsDefault )

Parameters:

  • inLocation - The path to the database on the disk.
  • inMode - How many files for databases will be used, range 1-8; default 4.
  • inSegmentSize - The size of one cluster in the database file; default 32KB.
  • inNativeOS - The byte order for the database.

Description:

Creates a new, empty database on the disk.

Note: After creation, the database becomes open.

As the Mode parameter you can specify one of the following:

kDscDatBlbInd	  // (description,data,BLOB,indexes)
kDsc_DatBlbInd    // description + (data,BLOB,indexes)
kDsc_DatBlb_Ind   // description + (data,BLOB) + indexes
kDsc_Dat_Blb_Ind  // description + data + BLOB + indexes
kDscDatBlb_Ind    // (description,data,BLOB) + indexes
kDscDat_Blb_Ind   // (description,data) + BLOB + indexes
kDscDatInd_Blb    // (description,data,indexes) + BLOB 
kDsc_DatInd_Blb   // description + (data,indexes) + BLOB

Example:

db.Create( file, kDscDatBlb_Ind, 32 * 1024 )

Example:

' For a remote database, you should specify only 
' the name of the database that is registered with Valentina Server.
'
remote_db.Create( "My Database1", kDscDatBlb_Ind, 32 * 1024 )

VDatabase.Flush()

Declaration:

Flush()

Description:

Flushes all unsaved information of this database from cache to the disk.

Example:

db.Flush()

VDatabase.SetMacTypes()

Declaration:

SetMacTypes(
    inDescType as String, 
    inDatType as String, 
    inBlbType as String, 
    inIndType as String )

Parameters:

  • inDescType - Mac Type of the ”.vdb” file of the database.
  • inDatType - Mac Type of the ”.dat” file of the database.
  • inBlbType - Mac Type of the ”.blb” file of the database.
  • inIndType - Mac Type of the ”.ind” file of the database.

Description:

This function allows you to assign own file types for the database files. This is required on MacOS to show custom icons correctly.

Example:

db.SetMacTypes( "Mdsc",  "Mdat", "Mblb", "Mind" )

See also: VDatabase Custom Extensions

VDatabase.Open()

Declaration:

Open( inLocation as Path )

Parameters:

  • inLocation - The path to the database on the disk OR the name of a database under VServer

Description:

Opens a database from the disk or from VServer.

Example:

local_db.Open( "file_path_on_disk" )

Example:

remote_db.Create( "db_name_on_vserver" )

VDatabase.ThrowOut()

Declaration:

ThrowOut()

Description:

Deletes all database files from disk. This database should be closed.

Example:

db.Close()
db.ThrowOut()