:: com :: sun :: star :: sdb :: tools ::

interface XObjectNames

Methods' Summary
suggestName suggests a (unique) table or query name  
convertToSQLName converts the given object name to a name which is valid in the database.  
isNameUsed checks whether a given name is used as table respectively query name in the database.  
isNameValid checks whether a given name is valid as table or query name  
checkNameForCreate checks whether a given name is allowed for a to-be-created table or query in the database.  
Methods' Details
suggestName
string
suggestName( [in] long  CommandType,
[in] string  BaseName )
raises( ::com::sun::star::lang::IllegalArgumentException );

Description
suggests a (unique) table or query name

If in the database, tables and queries share a common namespace, this will be respected by this function.

Note that in an multi-threaded environment, the name you obtain here is not absolutely guaranteed to be unique. It is unique at the very moment the function returns to you. But already when you evaluate the returned value, it might not be unique anymore, if another process or thread created a query or table with this name.

This implies that you cannot rely on the name's uniqueness, but you can use it as first guess to present to the user. In most cases, it will still be sufficient when you are actually creating the table respectively query.

Parameter CommandType
specifies the ::com::sun::star::sdb::CommandType of the object for which a unique name is to be generated. Must be either ::com::sun::star::sdb::CommandType::TABLE or ::com::sun::star::sdb::CommandType::QUERY.
Parameter BaseName
specifies the base of the to-be-created object name. If empty, a default base name will be used.
Throws
com::sun::star::lang::IllegalArgumentException if CommandType specifies an invalid command type.
convertToSQLName
string
convertToSQLName( [in] string  Name );

Description
converts the given object name to a name which is valid in the database.

The conversion takes place by converting every character which is neither allowed by the SQL-92 standard, nor part of the special characters supported by the database, with an underscore character (_).

See also
::com::sun::star::sdbc::XDatabaseMetaData::getExtraNameCharacters
isNameUsed
boolean
isNameUsed( [in] long  CommandType,
[in] string  Name )
raises( ::com::sun::star::lang::IllegalArgumentException );

Description
checks whether a given name is used as table respectively query name in the database.

If in the database, tables and queries share a common namespace, this will be respected by this function.

As before, the information you obtain by calling this method might be obsolete in the very moment you evaluate this, in case another process or thread interferes. However, it's usually sufficiently up-to-date for purpose of using it in a database application driven by user interactions.

Parameter CommandType
specifies the ::com::sun::star::sdb::CommandType of the object whose name should be checked. Must be either ::com::sun::star::sdb::CommandType::TABLE or ::com::sun::star::sdb::CommandType::QUERY.
Parameter Name
specifies the to-be-checked name of the object.
Returns
true if and only if the given name is legitimate as table respectively query name to be used in the database.
Throws
com::sun::star::lang::IllegalArgumentException if CommandType specifies an invalid command type.
See also
checkNameIsUsed
isNameValid
boolean
isNameValid( [in] long  CommandType,
[in] string  Name )
raises( ::com::sun::star::lang::IllegalArgumentException );

Description
checks whether a given name is valid as table or query name

For tables, the name must consist of characters allowed by the SQL-92 standard, plus characters allowed by the connection as extra name characters.

For queries, names are nearly arbitrary, except that usual quoting characters must not be part of the name.

See also
::com::sun::star::sdbc::XDatabaseMetaData::getExtraNameCharacters
checkNameForCreate
void
checkNameForCreate( [in] long  CommandType,
[in] string  Name )
raises( ::com::sun::star::sdbc::SQLException );

Description
checks whether a given name is allowed for a to-be-created table or query in the database.

This method basically does the same checks as isNameUsed and isNameValid. In case the given name is not allowed, it throws an exception. This error can be presented to the user, to give it a common experience in all cases where he's required to enter an object name.

See also
isNameUsed, isNameValid, ::com::sun::star::sdb::ErrorMessageDialog, ::com::sun::star::sdb::InteractionHandler
Top of Page