%SYS
Databases Class Reference

This class allows you to modify and view the [Databases] section of the CPF file through programatic APIs. More...

Inheritance diagram for Databases:
Collaboration diagram for Databases:

Public Member Functions

_.Library.Status OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount)
 Called from Save(). More...
 
_.Library.Status OnOpen ()
 This callback method is invoked by the <METHOD>Open</METHOD> method to. More...
 

Static Public Member Functions

_.Library.String DatabaseByName (_.Library.String Name)
 Return the ^system^directory where the database is located. More...
 
_.Library.Status DatabasesByDirectory (_.Library.String Server, _.Library.String Directory, _.Library.String DBList, _.Library.String CPFFile)
 Returns a list of databases that share the same given server/directory pair.
 
_.Library.Status DatabasesByServer (_.Library.String Server, _.Library.String DatabaseList, _.Library.String CPFFile)
 Returns a list of databases that reference a given server. More...
 
_.Library.String GetNextDatabaseByUCI (_.Library.String UCI)
 Return the Next UCI after the passed one, or null if at end. More...
 
_.Library.String KillDatabaseByUCI (_.Library.String UCI)
 Kill the ^SYS("UCI",UCI) node. More...
 
_.Library.Status Modify (_.Library.String Name, _.Library.String Properties, _.Library.String CPFFile, _.Library.Integer Flags)
 Modify Dataset section instance in CPF file. More...
 
_.Library.Status Rename (_.Library.String OldName, _.Library.String NewName, _.Library.String CPFFile)
 Rename the database name in the CPF file. More...
 
- Static Public Member Functions inherited from CommonMultipleMethods
_.Library.Status Create (_.Library.String Name, _.Library.String Properties, _.Library.String CPFFile, _.Library.Integer Flags)
 Create a section instance in a CPF file. More...
 
_.Library.Status Delete (_.Library.String Name, _.Library.String CPFFile, _.Library.Integer Flags)
 Delete a section instance from a CPF file. More...
 
_.Library.Boolean Exists (_.Library.String Name, _.Library.ObjectHandle Obj, _.Library.Status Status, _.Library.String CPFFile, _.Library.Integer Flags)
 Database exists. More...
 
_.Library.Status Get (_.Library.String Name, _.Library.String Properties, _.Library.String CPFFile, _.Library.Integer Flags)
 Get a section instances properties from a CPF file. More...
 
_.Library.Status GetList (_.Library.String Name, _.Library.String CPFFile, _.Library.Integer Flags)
 Returns the properties from a section instance in a CPF file by value in $list format
More...
 
_.Library.ObjectHandle Open (_.Library.String Name, _.Library.String CPFFile, _.Library.Integer concurrency, _.Library.Status Status, _.Library.Integer Flags)
 Open a section instance object in a CPF file. More...
 

Public Attributes

 ClusterMountMode
 Specifies whether the database should be mounted privately or clustered. More...
 
 Directory
 Directory where the database resides. More...
 
 MountAtStartup
 On a clustered system, specifies whether the database should be mounted at startup. More...
 
 MountRequired
 Specifies that the database MUST be successfully mounted at startup. More...
 
 Server
 Name of the remote server where the DB resides. More...
 
 StreamLocation
 Directory where the streams associated with this database go. More...
 
- Public Attributes inherited from CommonProperties
 CPFFile
 CPF file which the object maps to. More...
 
 Comments
 Embedded comments in the CPF file. More...
 
 Flags
 Flags governing how the object is processed when Save() is called. More...
 
 Name
 Name of the object instance. More...
 

Static Public Attributes

 CAPITALNAME = None
 This class allows you to modify and view the [Databases] section of the CPF file through programatic APIs. More...
 
- Static Public Attributes inherited from CommonMultipleMethods
 CAPITALNAME = None
 Determines if the Name specified in the index should be capitalized. More...
 
 SECTIONTYPE = None
 This parameter governs how the class creates audit records. More...
 
- Static Public Attributes inherited from CommonProperties
 DOMAIN = None
 This class contains properties which are included by classes which manipulate sections in the CPF file. More...
 

Detailed Description

This class allows you to modify and view the [Databases] section of the CPF file through programatic APIs.

While properties are usually modified through the System Management portal, there may be some occasion where modifying them through the APIs is best for your system. In all the Config methods, if you do not specify the CPFFile parameter, the currently active CPF file is used. If you wish to modify a CPF file which is not the currently active one, then specify the CPFFile you wish to modify in the method call.
The Flags parameter does not normally need to be specified; the defaults are usually sufficient for most cases.
You can use either the provided APIs (Create/Get/Modify/Delete) to modify the properties by passing in the correct parameters, or use Object syntax to open and directly manipulate the config objects (Open() and Exists()). Most objects created here need only to specify the Name of the object, and 1 or 2 properties since the the defaults are what are commonly used for most cases.

EXAMPLE:

     ; Use class methods to create an instance
     SYS>set Name="ABC"
     SYS>set Properties("Directory")="c:\abc\"
     SYS>set Status=##Class(Config.Databases).Create(Name,.Properties)
     SYS>if '$$$ISOK(Status) write !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     ; Use class methods to modify properties
     SYS>set Status=##Class(Config.Databases).Get(Name,.Properties)
     SYS>if '$$$ISOK(Status) write !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     SYS>zwrite Properties
     Properties("ClusterMountMode")=0
     Properties("Directory")="c:\abc\"
     Properties("MountAtStartup")=0
     Properties("MountRequired")=0
     Properties("Server")=""
     SYS>set Properties("MountRequired")=1
     SYS>set Status=##Class(Config.Databases).Modify(Name,.Properties)
     SYS>if '$$$ISOK(Status) w !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     ; Now use Objects to modify properties
     SYS>set Obj=##Class(Config.Databases).Open(Name)
     ; We could have used if ##Class(Config.Databases).Exists(Name,.Obj) instead of Open()
     SYS>write Obj.MountRequired
     1
     SYS>set Obj.MountRequired=0
     SYS>set Status=Obj.Save()
     SYS>if '$$$ISOK(Status) write !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     ; Now delete the object we just created
     SYS>set Status=##Class(Config.Databases).Delete(Name)
     SYS>if '$$$ISOK(Status) write !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     

Member Function Documentation

◆ OnAddToSaveSet()

_.Library.Status OnAddToSaveSet ( _.Library.Integer  depth,
_.Library.Integer  insert,
_.Library.Integer  callcount 
)

Called from Save().


Validate the database info here, and possibly change it.

◆ OnOpen()

_.Library.Status OnOpen ( )

This callback method is invoked by the <METHOD>Open</METHOD> method to.

provide notification that the object specified by oid is being opened.

If this method returns an error then the object will not be opened.

◆ DatabaseByName()

_.Library.String DatabaseByName ( _.Library.String  Name)
static

Return the ^system^directory where the database is located.


◆ DatabasesByServer()

_.Library.Status DatabasesByServer ( _.Library.String  Server,
_.Library.String  DatabaseList,
_.Library.String  CPFFile 
)
static

Returns a list of databases that reference a given server.


◆ GetNextDatabaseByUCI()

_.Library.String GetNextDatabaseByUCI ( _.Library.String  UCI)
static

Return the Next UCI after the passed one, or null if at end.


◆ KillDatabaseByUCI()

_.Library.String KillDatabaseByUCI ( _.Library.String  UCI)
static

Kill the ^SYS("UCI",UCI) node.


◆ Modify()

_.Library.Status Modify ( _.Library.String  Name,
_.Library.String  Properties,
_.Library.String  CPFFile,
_.Library.Integer  Flags 
)
static

Modify Dataset section instance in CPF file.

If the Server or Directory path is changed, it will be reflected on all Namespaces referring this DB.


Parameters:
Name - Name of the Dataset to modify.
Properties (byref) - List of the properties to modify in Properties(Name)=Value format. See the subclass for a list of valid properties. If a specific property is not passed in the properties array, the value is not modified.
CPFFile (byref) - Name of the CPF file to use, Default=current active CPF file.
Flags - Bit string of options to perform. For values, see the Create method, inherited from <class>Config.CommonMultipleMethods</class>.

Return values:
CPFFile (byref) - Name of the CPF file the modification was made in.

Reimplemented from CommonMultipleMethods.

◆ Rename()

_.Library.Status Rename ( _.Library.String  OldName,
_.Library.String  NewName,
_.Library.String  CPFFile 
)
static

Rename the database name in the CPF file.



Parameters:
OldName - Name of the database to rename.
NewName (byref) - New name of the database.
CPFFile (byref) - Name of the CPF file to use, Default=current active CPF file.

Return values:
CPFFile (byref) - Name of the CPF file the modification was made in.

Member Data Documentation

◆ CAPITALNAME

CAPITALNAME = None
static

This class allows you to modify and view the [Databases] section of the CPF file through programatic APIs.

While properties are usually modified through the System Management portal, there may be some occasion where modifying them through the APIs is best for your system. In all the Config methods, if you do not specify the CPFFile parameter, the currently active CPF file is used. If you wish to modify a CPF file which is not the currently active one, then specify the CPFFile you wish to modify in the method call.
The Flags parameter does not normally need to be specified; the defaults are usually sufficient for most cases.
You can use either the provided APIs (Create/Get/Modify/Delete) to modify the properties by passing in the correct parameters, or use Object syntax to open and directly manipulate the config objects (Open() and Exists()). Most objects created here need only to specify the Name of the object, and 1 or 2 properties since the the defaults are what are commonly used for most cases.

EXAMPLE:

     ; Use class methods to create an instance
     SYS>set Name="ABC"
     SYS>set Properties("Directory")="c:\abc\"
     SYS>set Status=##Class(Config.Databases).Create(Name,.Properties)
     SYS>if '$$$ISOK(Status) write !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     ; Use class methods to modify properties
     SYS>set Status=##Class(Config.Databases).Get(Name,.Properties)
     SYS>if '$$$ISOK(Status) write !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     SYS>zwrite Properties
     Properties("ClusterMountMode")=0
     Properties("Directory")="c:\abc\"
     Properties("MountAtStartup")=0
     Properties("MountRequired")=0
     Properties("Server")=""
     SYS>set Properties("MountRequired")=1
     SYS>set Status=##Class(Config.Databases).Modify(Name,.Properties)
     SYS>if '$$$ISOK(Status) w !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     ; Now use Objects to modify properties
     SYS>set Obj=##Class(Config.Databases).Open(Name)
     ; We could have used if ##Class(Config.Databases).Exists(Name,.Obj) instead of Open()
     SYS>write Obj.MountRequired
     1
     SYS>set Obj.MountRequired=0
     SYS>set Status=Obj.Save()
     SYS>if '$$$ISOK(Status) write !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     ; Now delete the object we just created
     SYS>set Status=##Class(Config.Databases).Delete(Name)
     SYS>if '$$$ISOK(Status) write !,"Error="_$SYSTEM.Status.GetErrorText(Status)
     

Database name is always capitalized.

◆ ClusterMountMode

ClusterMountMode

Specifies whether the database should be mounted privately or clustered.


0 - Mount private
1 - Mount clustered
 

◆ Directory

Directory

Directory where the database resides.



On ECP Clients of a mirror this contains logical references to the databases on the failover mirror members as the path may be different on the various nodes.
This has two forms:
&nbsp&nbsp&nbsp&nbsp&nbsp:mirror:&ltmirror name&gt:&ltmirror database name&gt
&nbsp&nbsp&nbsp&nbsp&nbsp:ds:&ltconfig database name&gt

The 1st form, :mirror:&ltmirror name&gt:&ltmirror database name&gt, refers to a mirrored database. The mirror database name is the internal mirror name assigned to the database when it was added to the mirror. This is generally the same as the database name in the configuration.

The 2nd form, :ds:&ltconfig database name&gt, refers to a non-mirrored database on the server. The config database name is the name of the database in the configuration and this database name is expected to exist on all of the failover members. This form is only used in special circumstances as normally non-mirrored databases are hosted on the ECP Client, not the ECP Server. This is used in cases where scratch data (eg. the data will be lost during a mirror failover) needs to be hosted on the server for some reason.  

◆ MountAtStartup

MountAtStartup

On a clustered system, specifies whether the database should be mounted at startup.


This property is valid for cluster systems only, and is ignored for non-cluster systems.
0 - Don't mount at startup
1 - Mount at startup
 

◆ MountRequired

MountRequired

Specifies that the database MUST be successfully mounted at startup.


0 - Successful mount not required for startup to succeed.
1 - Successful mount required for startup to succeed.
 

◆ Server

Server

Name of the remote server where the DB resides.


If empty, the database is local.
Remote server must already be configured to be entered here.
 

◆ StreamLocation

StreamLocation

Directory where the streams associated with this database go.


By default (value=""), the location is in the subdirectory "stream", underneath the database directory, e.g. for a database located in c:\abc, the default would be c:\abc\stream. InterSystems recommends leaving this parameter as "".