Caché SQL Reference
DROP QUERY
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Deletes a query.
Synopsis
DROP QUERY name [ FROM className ]
Arguments
name The name of the query to be deleted. The name is an identifier. For further details see the “Identifiers” chapter of Using Caché SQL.
FROM className Optional — If specified, the FROM className clause deletes the query from the given class. If this clause is not specified, Caché searches all classes of the schema for the query, and deletes it. However, if no query of this name is found, or more than one query of this name is found, an error code is returned. If the deletion of the query results in an empty class, DROP QUERY deletes the class as well.
Description
The DROP QUERY command deletes a query. When you drop a query, Caché revokes it from all users and roles to whom it has been granted and removes it from the database.
In order to drop a query, you must have %DROP_QUERY administrative privilege, as specified by the GRANT command. If you are attempting to delete a query for a class with a defined owner, you must be logged in as the owner of the class. Otherwise, Caché generates an SQLCODE -99 error (Privilege Violation).
If the specified query does not exist, DROP QUERY generates an SQLCODE -362 error. If the specified class does not exist, DROP QUERY generates an SQLCODE -360 error. If the specified query could refer to two or more queries, DROP QUERY generates an SQLCODE -361 error; you must specify a className to resolve this ambiguity.
Examples
The following embedded SQL example attempts to delete myq from the class User.Employee. (Refer to CREATE TABLE for an example that creates class User.Employee.)
   &sql(DROP QUERY myq FROM User.Employee)
  IF SQLCODE=0 {
    WRITE !,"Query deleted" }
  ELSEIF SQLCODE=-360 {
    WRITE !,"Nonexistent class: ",%msg }
  ELSEIF SQLCODE=-362 {
    WRITE !,"Nonexistent query: ",%msg }
  ELSE {WRITE !,"Unexpected Error code: ",SQLCODE}
 
See Also