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__
38static const char_t __THIS_FILE__[] = __T("dcl/sql/OciModuleMain.cpp");
39#endif
40
41/*
42#ifdef _WINDOWS
43BOOL 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
63static const wchar_t* _serverTitle = __T("Oracle");
64
66{
67 return (new OciConnection(_serverTitle));
68}
69
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
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
111extern "C"
112{
115{
116 // DCL common members
117 sizeof(SQL::DRIVER_MODULE), // structure size
121 DCL_SQL_DRIVER_MODULE, // module type
122 __T("DCL SQL Adapter for Oracle Database Server"),
123
124 // private members
126 _serverTitle,
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
#define __THIS_FILE__
Definition _trace.h:14
#define NULL
Definition Config.h:312
#define DCL_DSO_ENTRY_POINT
Definition Config.h:356
#define DCL_BUILD_FLAG
Definition Config.h:362
#define DCL_SQL_DRIVER_MODULE
Definition Config.h:353
wchar_t char_t
Definition Config.h:247
#define DCL_DSO_EXPORT
Definition Config.h:99
bool ModuleInitialize()
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()
#define __T(str)
Definition Object.h:60
bool ModuleInitialize()
#define __DCL_TRACE1_N(fmt, arg)
bool ModuleCleanup()
SQL::Connection * CreateConnectionInstance()
#define DCL_SQL_VERSION
#define __BUILD_TIMESTAMP__
#define DCL_VERSION
#define DCL_SQL_VERSION_STRING