EPLAN.EPLAN21.DATABASE.CREATE_SLAVE

Contents

Description

Command for creating EPLAN 21 subdatabases and for connecting subdatabases with working sets.

The EPLAN.EPLAN21.DATABASE.CREATE_SLAVE command is called up via the API functions as specified in the EPLAN 21 API.

Parameters

All parameters have the prefix "EPL_PARAM_DATABASE_CREATE_SLAVE".

ParameterID Type Description
DBNAME [IN]
String

Name of the subdatabase to be created.

USERNAME [IN, OPTIONAL]
String

User name for the subdatabase.

PASSWORD [IN]
String

Password for the subdatabase.

MASTERDBHANDLE [IN]
EplHandle

Handle to the main database to which the generated subdatabase is to be connected.

Error Messages

The eplExecuteCommand function returns EPL_OK if the subdatabase was generated correctly and could be connected to the working set.

If the command fails, eplExecuteCommand returns the value EPL_ERROR. In this case, the error log can contain the following errors:

ErrorID Description
EPL_ERR_NO_RIGHT The current user group does not allow the user to create a database.
EPL_ERR_DATABASE_CREATE_SLAVE_FILE_EXISTS The selected file name cannot be used since there is already a file of this name.
EPL_ERR_DATABASE_CREATE_SLAVE_INVALID_MASTER The transferred handle is invalid for the main database. No open working set could be found for this name.
EPL_ERR_DATABASE_CREATE_SLAVE_NO_MASTER_LOCK

The main database is not locked for exclusive editing Since a connection must be made between the main database and the newly created subdatabase, the command is not executed.

EPL_ERR_DATABASE_CREATE_SLAVE_DB_NOT_CREATABLE The subdatabase could not be created. EPLAN 21 expects that the directory in which a database is to be created already exists. Therefore please check, whether the specified directory already exists and if you have the necessary access rights.

Example

The following example shows a function that creates a subdatabase and connects it to a working set.

EplHandle
createSlaveDbTestFunc(EplSession s, EplHandle masterDbHandle)
{
        EplHandle ret = EPL_ERROR;

        // Create command:
        EplHandle cmd =
                eplCreateCommand(s, L"EPLAN.EPLAN21.DATABASE.CREATE_SLAVE");

        // Could the command be created?
        if(cmd != EPL_ERROR)
        {
                // Set database name:
                eplSetParam(
                        s,
                        cmd,
                        EPL_PARAM_DATABASE_CREATE_SLAVE_DBNAME,
                        L"c:\\tmp\\test.db"
                        0);
                // Set password:
                eplSetParam(
                        s,
                        cmd,
                        EPL_PARAM_DATABASE_CREATE_SLAVE_PASSWORD,
                        L"eplan",
                        0);

		// Set handle to main database
		eplSetParamHandle(
			s,
			cmd,
			EPL_PARAM_DATABASE_CREATE_SLAVE_MASTERDBHANDLE,
			masterDbHandle
			0);

                // Create database:
                ret = eplExecuteCommand(s, cmd);

                /* Error treatment
                   ...
                 */
        } else {
                /* Error treatment
                   ...
                 */
                ret = EPL_ERROR;
        }

        eplCloseObject(s, cmd);

        return ret;
}

Reference