Home | Previous Page | Next Page   Access Methods > Access Method Flow >

Locating Purpose Functions

The SQL statements that register a purpose function and an access method create records in the system catalog, which the database server consults to locate a purpose function.

As the access-method developer, you write the purpose functions and register them with the CREATE FUNCTION statement. When you register a purpose function, the database server puts a description of it in the sysprocedures system catalog table.

For example, assume you write a get_next_record() function that performs the tasks of the am_getnext purpose function. Assume that as user informix, you register the get_next_record() function. Depending on the operating system, you use one of the following statements to register the function:

UNIX Only
CREATE FUNCTION get_next_record(pointer,pointer,pointer)
RETURNS int
WITH (NOT VARIANT)
EXTERNAL NAME "$INFORMIXDIR/extend/am_lib.bld(get_next_record)"
LANGUAGE C
End of UNIX Only
Windows Only
CREATE FUNCTION get_next_record (pointer,pointer,pointer)
RETURNS int
WITH (NOT VARIANT)
EXTERNAL NAME "%INFORMIXDIR%\extend\am_lib.bld(get_next_record)"
LANGUAGE C
End of Windows Only

The get_next_record() declaration has three generic pointer arguments to conform with the prototype of the am_getnext purpose function. For a detailed explanation of the arguments and return value, refer to the description of am_getnext on page am_getnext.

As a result of the CREATE FUNCTION statement, the sysprocedures system catalog table includes an entry with values that are similar to the example in Table 5.

Table 5. Partial sysprocedures Entry
Column Name Value
procname
get_next_record 
owner
informix 
procid
163 
numargs
3 
externalname $INFORMIXDIR/extend/am_lib.bld(get_next_record) (on UNIX)
langid 1 (Identifies C in the syslanguages system catalog table)
paramtypes
pointer,pointer,pointer 
variant f (Indicates false or nonvariant)

You then register the access method with a CREATE PRIMARY ACCESS_METHOD statement to inform the database server what function from sysprocedures to execute for each purpose.

The following example registers the super_access access method and identifies get_next_record() as the am_getnext purpose function.

CREATE PRIMARY ACCESS_METHOD super_access
(AM_GETNEXT = get_next_record) 

The super_access access method provides only one purpose function. If user informix executes the CREATE PRIMARY ACCESS_METHOD, the sysams system catalog table has an entry similar to Table 6.

Table 6. Partial sysams Entry
Column Name Value
am_name
super_access 
am_owner
informix 
am_id 100 (Unique identifier that the database server assigns)
am_type
P
am_sptype
A 
am_getnext 163 (Matches the procid value in the sysprocedures system catalog table entry for get_next_record())
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]