Locate 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 that 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.
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
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
The get_next_record() declaration has three generic pointer arguments to conform with the prototype of the am_getnext purpose function.
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.
CREATE PRIMARY ACCESS_METHOD super_access
(AM_GETNEXT = get_next_record)
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()) |