O'Reilly logo

SQL in a Nutshell by Kevin Kline

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

CREATE/ALTER METHOD Statement

Synopsis

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 of Address.

An implicitly defined method is created every time a structured type is created (see CREATE/ALTER TYPE Statement " for more details). Using a combination of the CREATE TYPE statement and the CREATE METHOD statement creates user-defined methods.

Platform

Command

DB2

Supported, with variations

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required