Example: lrd_init
In the following example, lrd_init sets up the environment in the vuser_init section. Static variables InitInfo
and DBTypeVersion
are used as arguments.
#include "lrd.h" /* This declaration should appear on your site exactly as it appears here. Do not change any of the fields of the structure. */ static LRD_INIT_INFO InitInfo = {LRD_INIT_INFO_EYECAT}; /* This declaration should be recorded at your site. Do not edit it. * static LRD_DEFAULT_DB_VERSION DBTypeVersion[] = { {LRD_DBTYPE_NONE, LRD_DBVERSION_NONE} };
static void FAR * OraEnv1; static void FAR * OraSvc1; static void FAR * OraSrv1; static void FAR * OraSes1;
vuser_init() { lrd_init(&InitInfo, DBTypeVersion); /* The second argument (2) initializes Oracle in object-relational mode*/ lrd_initialize_db(LRD_DBTYPE_ORACLE, 2, 0); lrd_env_init(LRD_DBTYPE_ORACLE, &OraEnv1, 0, 0);
// Allocate server, service context, and session handles
lrd_ora8_handle_alloc(OraEnv1, SERVER, &OraSrv1, 0); lrd_ora8_handle_alloc(OraEnv1, SVCCTX, &OraSvc1, 0); lrd_ora8_handle_alloc(OraEnv1, SESSION, &OraSes1, 0);
// The second argument is the name of the server being used.
lrd_server_attach(OraSrv1, "db_server_1", -1, 0, 0); lrd_ora8_attr_set_from_handle(OraSvc1, SERVER, OraSrv1, 0, 0);
// The third argument is the name of the user.
lrd_ora8_attr_set(OraSes1, USERNAME, "henry", -1, 0);
// The third argument is the password of the user.
lrd_ora8_attr_set(OraSes1, PASSWORD, "tilden", -1, 0); lrd_ora8_attr_set_from_handle(OraSvc1, SESSION, OraSes1, 0, 0); lrd_session_begin(OraSvc1, OraSes1, 1, 0, 0); }