Nonstop Database, HiRDB Version 9 Description

[Contents][Glossary][Index][Back][Next]

5.5.2 External C stored routine creation and execution procedure

The following is the general procedure for creating and executing an external C stored routine:

General procedure
  1. Create an external C stored routine.
  2. Register a new C library file.
  3. Define the external C stored routine.
  4. Execute the external C stored routine.

For details about executing external C stored routines, see the HiRDB Version 9 UAP Development Guide.

The following figure shows the flow of events from creation of an external C stored routine to its execution.

Figure 5-6 Flow from creation to execution of an external C stored routine

[Figure]

Note
The extension of the C library file varies according to the OS.
Organization of this subsection
(1) Coding an external C stored routine
(2) Registering a new C library file
(3) Defining the external C stored routine
(4) Executing the external C stored routine

(1) Coding an external C stored routine

In this step, you code either a procedure or a function in C, and then you compile the resulting C program. Compilation produces an object file. You then link multiple object files to create a C library file.

(2) Registering a new C library file

In this step, you register the new C library file in HiRDB.

Registration by a HiRDB administrator:
The HiRDB administrator uses the pdclibsync command.

Registration by the UAP developer:
The programmer codes the INSTALL CLIB or REPLACE CLIB statement of the SQL in the UAP, and then executes it.

(3) Defining the external C stored routine

You use the CREATE PROCEDURE or CREATE FUNCTION statement to define an external C stored routine.

(4) Executing the external C stored routine

As in the case of executing a stored procedure or a stored function, you execute the SQL by specifying either a CALL statement or a function call. The CALL statement causes a C function to be executed as a C stored procedure. The function call causes a C function to be executed as a C stored function.