Name

CREATE/ALTER METHOD Statement

The CREATE/ALTER METHOD statements allow the creation of a new database method or the alteration of an already existing database method. An easy (but loose) way to think of a method is that it is a user-defined function associated with a user-defined type. For example, a method called Office, of type Address, can accept a VARCHAR input parameter and passes out a result Address.

An implicitly defined method is created every time a structured type is created. Using a combination of the CREATE TYPE statement and the CREATE METHOD statement creates user-defined methods.

Platform

Command

MySQL

Not supported

Oracle

Not supported

PostgreSQL

Not supported

SQL Server

Not supported

SQL2003 Syntax

{CREATE | ALTER} [INSTANT | STATIC] METHOD method_name
   ( [{IN | OUT | INOUT}] param datatype [AS LOCATOR] [RESULT][, ...] )
RETURNS datatype
FOR udt_name
[SPECIFIC specific_name] code_body

Keywords

{CREATE | ALTER} [INSTANT | STATIC] method_name

Creates a new method or alters an existing method and, optionally, specifies it as an INSTANT or STATIC method.

([{IN | OUT | INOUT}] param datatype[, . . . ])

Declares one or more parameters to be passed into the method in a comma-delimited list enclosed in parentheses. Parameters used with a method may pass a value IN, OUT, or both in and out via INOUT. The syntax for the parameter declaration is:

[{IN | OUT | INOUT}] parameter_name1 datatype,
[{IN | OUT | INOUT}] parameter_name2 datatype,[...]

Make sure the name is unique within the method. ...

Get SQL in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.