PvGetDbName()
Gets the name of a database on a connected server using a sequence number. You can obtain the number of database names by calling the
PvGetDbNamesData()
function. The sequence number is 1 based.
Header File: catalog.h (See also
Header Files
)
Function First Available In Library: w3dbav75.dll (Windows), libpsqldti.so (Linux), libpsqldti.dylib (OS X) (See also
Link Libraries
)
Syntax
BTI_API PvGetDbName(
BTI_LONG
hConnection,
BTI_ULONG
sequence,
BTI_ULONG_PTR
pBufSize,
BTI_CHAR_PTR
dbName
);
Arguments
In
hConnection
Connection handle that identifies the server. Connection handles are obtained with the
PvConnectServer()
function.
In
sequence
The sequence number (1 based) of the database name. Must be within a valid range with upper limit defined by
PvGetDbNamesData()
.
In/Out
pBufSize
Address of an unsigned long containing size of buffer allocated to receive the database name. Receives actual size of chars copied. The size should include the null terminator.
Out
dbName
String value returned.
Return Values
P_OK
The operation was successful.
P_E_INVALID_HANDLE
Invalid connection handle.
P_E_DATA_UNAVAILABLE
Data related to database names not available.
P_E_NULL_PTR
Call with NULL pointer
P_E_BUFFER_TOO_SMALL
Allocated buffer is too small for the string.
P_E_INVALID_SEQUENCE
Sequence number is not valid.
P_E_FAIL
Failed for other reasons.
Example
BTI_ULONG i;
BTI_ULONG count = 0;
BTI_CHAR dbName[BDB_SIZE_DBNAME+1];
BTI_SINT status = PvGetDbNamesData(connection, &count);
for (i=1; i<= count; i++)
{
BTI_ULONG dbNameSize = sizeof(dbName);
status = PvGetDbName(connection, i, &dbNameSize, dbName);
}
status = PvFreeDbNamesData(connection);
Remarks
The following preconditions must be met:
•
DTI session started by calling
PvStart()
.
•
Connection established by
PvConnectServer()
or if you are performing the operation on a local machine, P_LOCAL_DB_CONNECTION may be used as the connection handle.
•
Database names data retrieved by calling
PvGetDbNamesData()
•
Caller has a valid database name sequence number.
See Also
PvStart()
PvConnectServer()
PvGetDbNamesData()
PvFreeDbNamesData()
PvDisconnect()
PvStop()