DCL
3.7.4
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>
// setlocale
10
#include <
dcl/_stdlib.h
>
// setenv
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/SQLCore.h
>
19
#include "
OciConnection.h
"
20
21
#define __TRACE_THIS 0
22
#if __TRACE_THIS
23
#define __DCL_TRACE0_N __DCL_TRACE0
24
#define __DCL_TRACE1_N __DCL_TRACE1
25
#define __DCL_TRACE2_N __DCL_TRACE2
26
#define __DCL_TRACE3_N __DCL_TRACE3
27
#define __DCL_TRACE4_N __DCL_TRACE4
28
#else
29
#define __DCL_TRACE0_N(fmt)
30
#define __DCL_TRACE1_N(fmt, arg)
31
#define __DCL_TRACE2_N(fmt, arg1, arg2)
32
#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
33
#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
34
#endif
35
36
#if __DCL_HAVE_THIS_FILE__
37
#undef __THIS_FILE__
38
static
const
char_t
__THIS_FILE__
[] =
__T
(
"dcl/sql/OciModuleMain.cpp"
);
39
#endif
40
41
/*
42
#ifdef _WINDOWS
43
BOOL APIENTRY DllMain( HANDLE hModule,
44
DWORD ul_reason_for_call,
45
LPVOID lpReserved
46
)
47
{
48
switch (ul_reason_for_call) {
49
case DLL_PROCESS_ATTACH:
50
case DLL_PROCESS_DETACH:
51
return TRUE;
52
case DLL_THREAD_ATTACH:
53
case DLL_THREAD_DETACH:
54
break;
55
}
56
return FALSE;
57
}
58
#endif
59
*/
60
61
__DCL_BEGIN_NAMESPACE
62
63
static
const
wchar_t
* _serverTitle =
__T
(
"Oracle"
);
64
65
SQL::Connection
*
CreateConnectionInstance
()
66
{
67
return
(
new
OciConnection
(_serverTitle));
68
}
69
70
bool
ModuleInitialize
()
71
{
72
// https://docs.oracle.com/cd/B13789_01/server.101/b10749/ch7progr.htm#1006615
73
// When the NLS_LANG Character Set is UTF8 or AL32UTF8 in OCI
74
75
const
char
* langUTF8 =
"AMERICAN_AMERICA.UTF8"
;
76
char
* lang = getenv(
"LANG"
);
77
if
(!lang) {
78
// current locale
79
lang = setlocale(LC_CTYPE,
NULL
);
80
}
81
#if 0
82
// 2025-12-03 instantclient-basiclite- 기준, 항상 영문 메시지만 표시한다.
83
if
(lang) {
84
ByteString lang_ = ByteString(lang);
85
ByteString lower = lang_.toLowerCase();
86
if
(lower.contains(
"ko"
) || lower.contains(
"kr"
)) {
87
langUTF8 =
"KOREAN_KOREA.UTF8"
;
88
}
89
}
90
#endif
91
__DCL_TRACE1_N
(L
"setenv NLS_LANG=[%hs]\n"
, langUTF8);
92
return
setenv(
"NLS_LANG"
, langUTF8, 1) == 0;
93
}
94
95
bool
ModuleCleanup
()
96
{
97
sword status = ::OCITerminate(OCI_DEFAULT);
98
/*
99
if (status != OCI_SUCCESS)
100
{
101
setErrorMessage(status, NULL, __LINE__);
102
return false;
103
}
104
*/
105
if
(status != OCI_SUCCESS)
106
return
false
;
107
108
return
true
;
109
}
110
111
extern
"C"
112
{
113
DCL_DSO_EXPORT
114
SQL::DRIVER_MODULE
DCL_DSO_ENTRY_POINT
=
115
{
116
// DCL common members
117
sizeof
(
SQL::DRIVER_MODULE
),
// structure size
118
DCL_VERSION
,
119
__T
(
__BUILD_TIMESTAMP__
),
120
DCL_BUILD_FLAG
,
121
DCL_SQL_DRIVER_MODULE
,
// module type
122
__T
(
"DCL SQL Adapter for Oracle Database Server"
),
123
124
// private members
125
DCL_SQL_VERSION
,
126
_serverTitle,
127
__T
(
DCL_SQL_VERSION_STRING
),
128
ModuleInitialize
,
129
ModuleCleanup
,
130
CreateConnectionInstance
131
};
132
133
}
134
135
__DCL_END_NAMESPACE
136
137
#ifdef __WINNT_NEW_DELETE_OVERRIDE
138
#undef new
139
__WINNT_NEW_DELETE_OVERRIDE
140
#endif
_stdlib.h
__THIS_FILE__
#define __THIS_FILE__
Definition
_trace.h:14
Config.h
NULL
#define NULL
Definition
Config.h:312
DCL_DSO_ENTRY_POINT
#define DCL_DSO_ENTRY_POINT
Definition
Config.h:356
DCL_BUILD_FLAG
#define DCL_BUILD_FLAG
Definition
Config.h:362
DCL_SQL_DRIVER_MODULE
#define DCL_SQL_DRIVER_MODULE
Definition
Config.h:353
char_t
wchar_t char_t
Definition
Config.h:247
DCL_DSO_EXPORT
#define DCL_DSO_EXPORT
Definition
Config.h:99
ModuleInitialize
bool ModuleInitialize()
Definition
IFXModuleMain.cpp:99
ModuleCleanup
bool ModuleCleanup()
Definition
IFXModuleMain.cpp:137
CreateConnectionInstance
SQL::Connection * CreateConnectionInstance()
Definition
IFXModuleMain.cpp:94
Object.h
__T
#define __T(str)
Definition
Object.h:60
OciConnection.h
ModuleInitialize
bool ModuleInitialize()
Definition
OciModuleMain.cpp:70
__DCL_TRACE1_N
#define __DCL_TRACE1_N(fmt, arg)
Definition
OciModuleMain.cpp:30
ModuleCleanup
bool ModuleCleanup()
Definition
OciModuleMain.cpp:95
CreateConnectionInstance
SQL::Connection * CreateConnectionInstance()
Definition
OciModuleMain.cpp:65
SQLCore.h
OciConnection
Definition
OciConnection.h:12
SQL::Connection
Definition
SQLCore.h:327
DCL_SQL_VERSION
#define DCL_SQL_VERSION
Definition
include/dcl/Version.h:26
__BUILD_TIMESTAMP__
#define __BUILD_TIMESTAMP__
Definition
include/dcl/Version.h:5
DCL_VERSION
#define DCL_VERSION
Definition
include/dcl/Version.h:14
DCL_SQL_VERSION_STRING
#define DCL_SQL_VERSION_STRING
Definition
include/dcl/Version.h:27
SQL::DRIVER_MODULE
Definition
SQLCore.h:460
src
SQLOracle
OciModuleMain.cpp
Generated by
1.14.0