Creating functions within PgAccess is also fairly simple. First click on the Functions tab, then
click New. You should now be presented with the Function window. Here, you may enter the name of
your new function, the parameters it takes (comma-separated), the language it is written in (e.g.,
SQL
,
C
,
plpgsql
, etc.), and the type of data it returns (if
the function returns a value). Once you have defined those options, enter the body of the function in the white box that
takes up most of the screen (or the location in the filesystem of the shared object file, if it is a
C
function). Once
finished, click Save.
Note: You may view existing function definitions by selecting one from the function list, and clicking
Open.
Figure 6-5 illustrates a simple example function, which selects the name of an author
based on the id value in the authors table.
We will continue the discussion about creating functions in the next chapter.