23.7.2 Creating a UAP to retrieve from manual's SGML documents

Organization of this subsection
(1) Creating a UAP
(2) Executing pre-processing
(3) Compiling and linking
(4) Executing the UAP

(1) Creating a UAP

This section describes creation of a UAP for the purpose of making retrievals from manual's SGML documents.

Shown as follows is the coding of a UAP that checks the section headings in the SGML documents in order to obtain the number of instances of the keyword plug-in; a file containing this coding is created under the name sample.ec:

#include <stdio.h>
main()
{
 EXEC SQL BEGIN DECLARE SECTION;
  char xuserid[31];
  char xpasswd[31];
  int total;
 EXEC SQL END DECLARE SECTION;
 printf("userid ?\n");
 scanf("%30s",xuserid);
 printf("passwd ?\n");
 scanf("%30s",xpasswd);
 printf("connect start,\n");
 EXEC SQL CONNECT USER: xuserid USING: xpasswd;
 printf("connected,\n")
 EXEC SQL
 SELECT COUNT(*) INTO: total
    FROM manual WHERE contains(doc,'MAN[*[H2{"plug-in"}]]') IS TRUE;
 printf("total --->%2d\n",total);
 EXEC SQL DISCONNECT;
}

(2) Executing pre-processing

This section describes the preprocessing.

The SQL-embedded UAP source file cannot be compiled directly. The SQL preprocessor must be started in order to convert to a post source file.

Enter the following command, then press the Enter key:

pdcpp sample.ec

A post source file named sample.ec is created.

(3) Compiling and linking

The sample.ec file created during preprocessing is used to compile and link the UAP. Enter the following command, then press the Enter key:

cc -o sample -I /opt/HiRDB_P/include sample.c -L /opt/HiRDB_P/client/lib -lzclt

A file named sample.out is created.

(4) Executing the UAP

To execute UAP:

  1. Execute sample.out, which is the execute-form file obtained after compilation and linkage.
    A message is displayed requesting entry of a user ID.
  2. Enter manager, then press the Enter key.
    A message is displayed requesting entry of a password.
  3. Enter manager, then press the Enter key.
    Connection is established with the HiRDB system, the SQL is executed, and the retrieval result is displayed.

Simple installation is now complete.