sp_RenameDDObject

Advantage SQL Engine

  Previous topic Next topic  

Rename a data dictionary object.

Syntax

sp_RenameDDObject(

ObjectName, CHARACTER,200,

NewObjectName, CHARACTER, 200,

ObjectType, INTEGER,

Options, INTEGER )

Parameters

ObjectName (I)

Name of object to rename.

NewObjectName (I)

New name for the object.

ObjectType (I)

Database object type.

Can be:

1 (ADS_DD_TABLE_OBJECT)

2 (ADS_DD_RELATION_OBJECT)

6 (ADS_DD_VIEW_OBJECT)

8 (ADS_DD_USER_OBJECT)

9 (ADS_DD_USER_GROUP_OBJECT)

10 (ADS_DD_PROCEDURE_OBJECT)

12 (ADS_DD_LINK_OBJECT,)

14 (ADS_DD_TRIGGER_OBJECT)

15 (ADS_DD_PUBLICATION_OBJECT)

17 (ADS_DD_SUBSCRIPTION_OBJECT)

18 (ADS_DD_FUNCTION_OBJECT)

19 (ADS_DD_PACKAGE_OBJECT)

Options (I)

Renaming options. Specifying 1 (ADS_KEEP_TABLE_FILE_NAME) when renaming table objects will not rename the physical table file. Specifying 0 (zero) will rename the table’s physical file.

Special Return Codes

AE_INVALID_OBJECT_NAME

The given new object name cannot be already in use by another dictionary object.

AE_TABLE_NOT_EXCLUSIVE

When renaming tables, the table must not be open by any user.

Remarks

sp_RenameDDObject can be used to rename an existing data dictionary object. Renaming tables requires that the table not be open by any user. By default, Advantage Database Server will rename the physical file to match the new table's object name. Specifying 1 (ADS_KEEP_TABLE_FILE_NAME) will cause Advantage Database Server to not rename the physical file.

If the ObjectType parameter specifies a trigger object, the ObjectName and NewObjectName parameters should be qualified with the table name the trigger belongs to followed by two colon characters ( :: ). For example, "Customers::AfterInsertTrig" would specify you want to rename the trigger called "AfterInsertTrig" that belongs to the "Customers" table.

If the ObjectType parameter specifies a function object that belongs to a package, the ObjectName parameter should be qualified with the package name with a leading colon and two colons between the function and package names.  For example, ":Common::StringPad" would specify you want to rename the function called "StringPad" that belongs to the "Common" package.  Functions that do not belong to a package must not provide a package name or any colon characters in the name.  Whether or not the function belongs to a package, the NewObjectName parameter should simply be the new function name without any package name or colon characters.

Note Renaming a user while that user is connected is not recommended. The renamed user's permissions will not be affected in any way, but some places where the user name is logged may not reflect the user's new name.

 

Note Scripts, views, etc which contain references to renamed objects will not be automatically modified to reflect name changes.

Example

EXECUTE PROCEDURE sp_RenameDDObject( 'oldtable', 'newtable', 1 /* ADS_DD_TABLE_OBJECT */, 1 /* ADS_KEEP_TABLE_FILE_NAME */ )

See Also

AdsDDRenameObject