Scalable Database Server, HiRDB Version 8 UAP Development Guide

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

12.2 Preparations for executing commands from a UAP

Organization of this section
(1) HiRDB/Single Server
(2) HiRDB/Parallel Server

(1) HiRDB/Single Server

This section uses a sample UAP that executes data loading (database load utility). Figure 12-2 shows a sample server-client configuration for a HiRDB/Single Server.

Figure 12-2 Sample server-client configuration for a HiRDB/Single Server

[Figure]

To execute a data-loading UAP with the server-client configuration shown in Figure 12-2, you need to define the following information beforehand:

  1. Specify the following client environment definitions:
    PDSYSTEMID
    Specifies the HiRDB server's HiRDB identifier (HRD1).
    PDASTHOST
    Specifies the HiRDB Control Manager - Agent's host name (HOST1).
    PDASTPORT
    Specifies the HiRDB Control Manager - Agent's port number (22201).
  2. Prepare the control information file and input data file needed for loading data at the HiRDB server.
  3. Suppose that the HiRDB administrator's user name is USERA (password: USERA) and the owner of the table subject to data loading is USERB (password: USERB). In this case, specify the following client environment definitions:
    PDASTUSER=USERA/USERA
    PDUSER=USERB/USERB

You can now execute the data-loading UAP. For details about each client environment definition, see 6.6.4 Environment definition information.

The following shows a sample UAP for loading data:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
EXEC SQL BEGIN DECLARE SECTION;
char CmdLine[30000];                   /* CmdLine variable */
long ReturnCode;                       /* variable receiving return
                                          code */
long OutBufLen;                        /* size of area for receiving
                                          execution result */
long CmdRetCode;                       /* variable for receiving
                                          executed command's return
                                          code */
long OutDataLen;                       /* variable for receiving the
                                          length of execution result */
PDOUTBUF OutBuf;                       /* area for receiving execution
                                          result */
char EnvGroup[256];                    /* environment variable group
                                          name variable */
EXEC SQL END DECLARE SECTION;
 
void main()
{
strcpy(CmdLine,"pdhold -r RDDATA10");  /* specifying execution command
                                          line command line (RDAREA
                                          shutdown) */
OutBuf = malloc(30000);                /* allocating the execution
                                          result receiving area */
if (OutBuf == NULL){                   /* memory allocation error */
printf("Memory allocation error\n");
return ;
}
OutBufLen = 30000 ;                    /* specifying the size of
                                          execution result
                                          receiving area */
EnvGroup[0] = '\0' ;                   /* specifying no environment
                                          variable group */
 
/* Command execution */
EXEC  SQL  COMMAND  EXECUTE  :CmdLine, :ReturnCode, :OutBufLen,
:OutDataLen, :OutBuf, :CmdRetCode, :EnvGroup ;
if (ReturnCode == p_rdb_RC_NORM) {
                                       /* if COMMAND EXECUTE
                                          terminates normally */
if (CmdRetCode==0) {                   /* if command execution is
                                          normal */
 
/* Specifying execution command line (to execute dataloading) */
strcpy(CmdLine,"pdload  -i c  -be STOCK c:\HiRDB_S\conf\LOAD");
EXEC  SQL  COMMAND  EXECUTE  :CmdLine, :ReturnCode, :OutBufLen,
:OutDataLen, :OutBuf, :CmdRetCode, :EnvGroup ;
if (ReturnCode == p_rdb_RC_NORM) {
                                       /* if COMMAND EXECUTE terminates
                                          normally */
if (CmdRetCode==0) {                   /* if command execution is
                                          normal */
printf("pdload command successfully\n");
printf("%s\n", OutBuf);
} else {                               /* execution command error */
printf("pdload command Error,Code = %d\n", CmdRetCode);
printf("%s\n", OutBuf);
}
} else {                               /* COMMAND EXECUTE error */
printf("COMMAND EXECUTE Error,Code = %d\n", ReturnCode);
printf("%s\n", OutBuf);
}
} else {                               /* execution command error */
printf("pdhold command Error,Code = %d\n", CmdRetCode);
printf("%s\n", OutBuf);
}
strcpy(CmdLine,"pdrels -r RDDATA10");
                                       /* specifying execution command
                                          line (RDAREA shutdown
                                          release) */
EXEC  SQL  COMMAND  EXECUTE  :CmdLine, :ReturnCode, :OutBufLen,
:OutDataLen, :OutBuf, :CmdRetCode, :EnvGroup ;
if (ReturnCode == p_rdb_RC_NORM) {
                                       /* if COMMAND EXECUTE
                                          terminates normally */
if (CmdRetCode!=0) {                   /* execution command error */
printf("pdrels command Error,Code = %d\n", CmdRetCode);
printf("%s\n", OutBuf);
}
} else {                               /* COMMAND EXECUTE error */
printf("COMMAND EXECUTE Error,Code = %d\n", ReturnCode);
printf("%s\n", OutBuf);
}
} else {                               /* COMMAND EXECUTE error */
printf("COMMAND EXECUTE Error,Code = %d\n", ReturnCode);
printf("%s\n", OutBuf);
}
return ;
}

(2) HiRDB/Parallel Server

This section uses a sample UAP that executes data loading (database load utility). Figure 12-3 shows a sample server-client configuration for a HiRDB/Parallel Server.

Figure 12-3 Sample server-client configuration for a HiRDB/Parallel Server

[Figure]

To execute a data-loading UAP with the server-client configuration shown in Figure 12-3, you need to define the following information beforehand:

  1. Specify the following client environment definitions:
    PDSYSTEMID
    Specifies the HiRDB server's HiRDB identifier (HRD1).
    PDASTHOST
    Specifies the HiRDB Control Manager - Agent's host name (HOST1). For a HiRDB/Parallel Server, specify the host name of the server machine where the system manager is located.
    PDASTPORT
    Specifies the HiRDB Control Manager - Agent's port number (22201).
  2. Prepare the control information file and input data file needed for loading data at the HiRDB server.
  3. Suppose that the HiRDB administrator's user name is USERA (password: USERA) and the owner of the table subject to data loading is USERB (password: USERB). In this case, specify the following client environment definitions:
    PDASTUSER=USERA/USERA
    PDUSER=USERB/USERB

You can now execute the data-loading UAP. For details about each client environment definition, see 6.6.4 Environment definition information.

The following shows a sample UAP for loading data:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
EXEC SQL BEGIN DECLARE SECTION;
char CmdLine[30000];                   /* CmdLine variable */
long ReturnCode;                       /* variable receiving return
                                          code */
long OutBufLen;                        /* size of area for receiving
                                           execution result */
long CmdRetCode;                       /* variable for receiving
                                          executed command's return
                                          code */
long OutDataLen;                       /* variable for receiving the
                                          length of execution result */
PDOUTBUF OutBuf;                       /* area for receiving execution
                                           result */
char EnvGroup[256];                    /* environment variable group
                                          name variable */
EXEC SQL END DECLARE SECTION;
 
void main()
{
strcpy(CmdLine,"pdhold -r RDDATA10");  /* specifying execution command
                                          line (RDAREA shutdown) */
OutBuf = malloc(30000);                /* allocating the execution
                                          result receiving area */
if (OutBuf == NULL){                   /* memory allocation error */
printf("Memory allocation error\n");
return ;
}
OutBufLen = 30000 ;                    /* specifying the size of
                                          execution result receiving
                                          area */
EnvGroup[0] = '\0' ;                   /* specifying no environment
                                          variable group */
 
/* Command execution */
EXEC  SQL  COMMAND  EXECUTE  :CmdLine, :ReturnCode, :OutBufLen,
:OutDataLen, :OutBuf, :CmdRetCode, :EnvGroup ;
if (ReturnCode == p_rdb_RC_NORM) {     /* if COMMAND EXECUTE
                                          terminates normally */
if (CmdRetCode==0) {                   /* if command execution is
                                          normal */
 
/* Specifying execution command line (to execute dataloading) */
strcpy(CmdLine,"pdload  -i c  -be STOCK c:\HiRDB_P\conf\LOAD");
EXEC  SQL  COMMAND  EXECUTE  :CmdLine, :ReturnCode, :OutBufLen,
:OutDataLen, :OutBuf, :CmdRetCode, :EnvGroup ;
if (ReturnCode == p_rdb_RC_NORM) {     /* if COMMAND EXECUTE
                                          terminates normally */
if (CmdRetCode==0) {                   /* if command execution is
                                          normal */
printf("pdload command successfully\n");
printf("%s\n", OutBuf);
} else {                               /* execution command error */
printf("pdload command Error,Code = %d\n", CmdRetCode);
printf("%s\n", OutBuf);
}
} else {                               /* COMMAND EXECUTE error */
printf("COMMAND EXECUTE Error,Code = %d\n", ReturnCode);
printf("%s\n", OutBuf);
}
} else {                               /* execution command error */
printf("pdhold command Error,Code = %d\n", CmdRetCode);
printf("%s\n", OutBuf);
}
strcpy(CmdLine,"pdrels -r RDDATA10");  /* specifying execution command
                                          line (RDAREA shutdown
                                          release) */
EXEC  SQL  COMMAND  EXECUTE  :CmdLine, :ReturnCode, :OutBufLen,
:OutDataLen, :OutBuf, :CmdRetCode, :EnvGroup ;
if (ReturnCode == p_rdb_RC_NORM) {     /* if COMMAND EXECUTE
                                          terminates normally */
if (CmdRetCode!=0) {                   /* execution command error */
printf("pdrels command Error,Code = %d\n", CmdRetCode);
printf("%s\n", OutBuf);
}
} else{                                /* COMMAND EXECUTE error */
printf("COMMAND EXECUTE Error,Code = %d\n", ReturnCode);
printf("%s\n", OutBuf);
}
} else {                               /* COMMAND EXECUTE error */
printf("COMMAND EXECUTE Error,Code = %d\n", ReturnCode);
printf("%s\n", OutBuf);
}
return ;
}