Skip to main content

DROP METHOD

Deletes a method.

Synopsis

DROP METHOD name [ FROM className ]

Arguments

Argument Description
name The name of the method to be deleted. The name is an identifier. Do not specify the method’s parameter parentheses. A name can be qualified (schema.name), or unqualified (name). An unqualified method name takes the system-wide default schema name, unless the FROM className clause is specified.
FROM className Optional — If specified, the FROM className clause deletes the method from the given class. If this clause is not specified, Caché searches all classes of the schema for the method, and deletes it. However, if no method of this name is found, or more than one method of this name is found, an error code is returned. If the deletion of the method results in an empty class, DROP METHOD deletes the class as well.

Description

The DROP METHOD command deletes a method. When you delete a method, Caché revokes it from all users and roles to whom it has been granted and removes it from the database.

In order to delete a method, you must have %DROP_METHOD administrative privilege, as specified by the GRANT command. If you are attempting to delete a method for a class with a defined owner, you must be logged in as the owner of the class. Otherwise, the system generates an SQLCODE -99 error (Privilege Violation).

The following combinations of name and FROM className are supported. Note that the FROM clause specifies the class package name and method name, not the SQL names. In these examples, the system-wide default schema name is SQLUser, which corresponds to the User class package:

  • DROP METHOD BonusCalc FROM methBonusCalc: drops the method SQLUser.BonusCalc().

  • DROP METHOD BonusCalc FROM User.methBonusCalc: drops the method SQLUser.BonusCalc().

  • DROP METHOD Test.BonusCalc FROM methBonusCalc: drops the method SQLUser.BonusCalc().

  • DROP METHOD BonusCalc FROM Employees.methBonusCalc: drops the method Employees.BonusCalc().

  • DROP METHOD Test.BonusCalc FROM Employees.methBonusCalc: drops the method Employees.BonusCalc().

If the specified method does not exist, DROP METHOD generates an SQLCODE -362 error. If the specified className does not exist, DROP METHOD generates an SQLCODE -360 error. If the specified method could refer to two or more methods, DROP METHOD generates an SQLCODE -361 error; you must specify a className to resolve this ambiguity.

If a method has been defined with the PROCEDURE characteristic keyword, you can determine if it exists in the current namespace by invoking the $SYSTEM.SQL.ProcedureExists()Opens in a new tab method. A method defined with the PROCEDURE keyword can be deleted either by DROP METHOD or DROP PROCEDURE.

Examples

The following embedded SQL example attempts to delete mymeth from the class User.Employee. (Refer to CREATE TABLE for an example that creates class User.Employee.)

   &sql(DROP METHOD mymeth FROM User.Employee)
  IF SQLCODE=0 {
    WRITE !,"Method deleted" }
  ELSEIF SQLCODE=-360 {
    WRITE !,"Nonexistent class: ",%msg }
  ELSEIF SQLCODE=-362 {
    WRITE !,"Nonexistent method: ",%msg }
  ELSE {WRITE !,"Unexpected Error code: ",SQLCODE}

See Also

FeedbackOpens in a new tab