DCL 4.0
Loading...
Searching...
No Matches
OciModuleMain.cpp
Go to the documentation of this file.
1#include <dcl/Config.h>
2
3#ifdef _MSC_VER
4 #pragma comment(lib, "oci.lib")
5#endif
6
7#include <oci.h>
8
9#include <locale.h>
10#include <dcl/_stdlib.h>
11
12#include <dcl/Object.h>
13#if __DCL_HAVE_ALLOC_DEBUG
14#undef __DCL_ALLOC_LEVEL
15#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
16#endif
17
18#include <dcl/String.h>
19#include <dcl/SQLCore.h>
20
21#include "OciConnection.h"
22
23#if __DCL_HAVE_THIS_FILE__
24#undef __THIS_FILE__
25static const wchar_t __THIS_FILE__[] = __T("dcl/sql/OciModuleMain.cpp");
26#endif
27
28/*
29#ifdef _WINDOWS
30BOOL APIENTRY DllMain( HANDLE hModule,
31 DWORD ul_reason_for_call,
32 LPVOID lpReserved
33 )
34{
35 switch (ul_reason_for_call)
36 {
37 case DLL_PROCESS_ATTACH:
38 case DLL_PROCESS_DETACH:
39 return TRUE;
40 case DLL_THREAD_ATTACH:
41 case DLL_THREAD_DETACH:
42 break;
43 }
44 return FALSE;
45}
46#endif
47*/
48
49__DCL_BEGIN_NAMESPACE
50
51static const wchar_t* _serverTitle = __T("OracleDb");
52
54{
55// cerr << "createDatabaseObject IB\n";
56 return (new OciConnection(_serverTitle));
57}
58
60{
61 // https://docs.oracle.com/cd/B13789_01/server.101/b10749/ch7progr.htm#1006615
62 // When the NLS_LANG Character Set is UTF8 or AL32UTF8 in OCI
63
64 const char* envUTF8 = "AMERICAN_AMERICA.UTF8";
65 char* lang = getenv("LANG");
66 if (!lang) {
67 lang = setlocale(LC_ALL, "");
68 }
69 if (lang) {
70 ByteString s = ByteString(lang).toLowerCase();
71 if (s.contains("ko") || s.contains("kr")) {
72 envUTF8 = "KOREAN_KOREA.UTF8";
73 }
74 }
75
76 return setenv("NLS_LANG", envUTF8, true) == 0;
77}
78
80{
81 sword status = ::OCITerminate(OCI_DEFAULT);
82/*
83 if (status != OCI_SUCCESS)
84 {
85 setErrorMessage(status, NULL, __LINE__);
86 return false;
87 }
88*/
89 if (status != OCI_SUCCESS)
90 return false;
91
92 return true;
93}
94
95extern "C"
96{
99{
100 // DCL common members
101 sizeof(SQL::DRIVER_MODULE), // structure size
105 DCL_SQL_DRIVER_MODULE, // module type
106 __T("DCL SQL Driver for Oracle Database Server"),
107
108 // private members
110 _serverTitle,
111 __T("4.0.0.0"),
115};
116
117}
118
119__DCL_END_NAMESPACE
#define __THIS_FILE__
Definition _trace.h:14
#define __TIMESTAMP__
Definition Config.h:215
#define DCL_DSO_ENTRY_POINT
Definition Config.h:393
#define DCL_BUILD_FLAG
Definition Config.h:399
#define DCL_SQL_DRIVER_MODULE
Definition Config.h:390
#define DCL_SQL_VERSION
Definition Config.h:381
#define DCL_VERSION
Definition Config.h:376
#define DCL_DSO_EXPORT
Definition Config.h:111
bool ModuleInitialize()
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()
#define __T(str)
Definition Object.h:44
bool ModuleInitialize()
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()