OCILIB (C and C++ Driver for Oracle)  4.7.3
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
DirectPath.hpp
1 /*
2  * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI)
3  *
4  * Website: http://www.ocilib.net
5  *
6  * Copyright (c) 2007-2021 Vincent ROGIER <vince.rogier@ocilib.net>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #pragma once
22 
23 #include "ocilibcpp/types.hpp"
24 
25 namespace ocilib
26 {
27 
28 inline DirectPath::DirectPath(const TypeInfo &typeInfo, unsigned int nbCols, unsigned int nbRows, const ostring& partition)
29 {
30  Acquire(core::Check(OCI_DirPathCreate(typeInfo, partition.c_str(), nbCols, nbRows)), reinterpret_cast<HandleFreeFunc>(OCI_DirPathFree), nullptr, nullptr);
31 }
32 
33 inline void DirectPath::SetColumn(unsigned int colIndex, const ostring& name, unsigned int maxSize, const ostring& format)
34 {
35  core::Check(OCI_DirPathSetColumn(*this, colIndex, name.c_str(), maxSize, format.c_str()));
36 }
37 
38 template<class T>
39 inline void DirectPath::SetEntry(unsigned int rowIndex, unsigned int colIndex, const T &value, bool complete)
40 {
41  core::Check(OCI_DirPathSetEntry(*this, rowIndex, colIndex, static_cast<const AnyPointer>(const_cast<typename T::value_type *>(value.c_str())), static_cast<unsigned int>(value.size()), complete));
42 }
43 
44 inline void DirectPath::Reset()
45 {
47 }
48 
49 inline void DirectPath::Prepare()
50 {
52 }
53 
55 {
56  return Result(static_cast<Result::Type>(core::Check(OCI_DirPathConvert(*this))));
57 }
58 
60 {
61  return Result(static_cast<Result::Type>(core::Check(OCI_DirPathLoad(*this))));
62 }
63 
64 inline void DirectPath::Finish()
65 {
67 }
68 
69 inline void DirectPath::Abort()
70 {
72 }
73 
74 inline void DirectPath::Save()
75 {
77 }
78 
79 inline void DirectPath::FlushRow()
80 {
82 }
83 
84 inline void DirectPath::SetCurrentRows(unsigned int value)
85 {
87 }
88 
89 inline unsigned int DirectPath::GetCurrentRows() const
90 {
92 }
93 
94 inline unsigned int DirectPath::GetMaxRows() const
95 {
96  return core::Check(OCI_DirPathGetMaxRows(*this));
97 }
98 
99 inline unsigned int DirectPath::GetRowCount() const
100 {
101  return core::Check(OCI_DirPathGetRowCount(*this));
102 }
103 
104 inline unsigned int DirectPath::GetAffectedRows() const
105 {
107 }
108 
109 inline void DirectPath::SetDateFormat(const ostring& format)
110 {
111  core::Check(OCI_DirPathSetDateFormat(*this, format.c_str()));
112 }
113 
114 inline void DirectPath::SetParallel(bool value)
115 {
116  core::Check(OCI_DirPathSetParallel(*this, value));
117 }
118 
119 inline void DirectPath::SetNoLog(bool value)
120 {
121  core::Check(OCI_DirPathSetNoLog(*this, value));
122 }
123 
124 inline void DirectPath::SetCacheSize(unsigned int value)
125 {
126  core::Check(OCI_DirPathSetCacheSize(*this, value));
127 }
128 
129 inline void DirectPath::SetBufferSize(unsigned int value)
130 {
131  core::Check(OCI_DirPathSetBufferSize(*this, value));
132 }
133 
135 {
136  core::Check(OCI_DirPathSetConvertMode(*this, value));
137 }
138 
139 inline unsigned int DirectPath::GetErrorColumn()
140 {
141  return core::Check(OCI_DirPathGetErrorColumn(*this));
142 }
143 
144 inline unsigned int DirectPath::GetErrorRow()
145 {
146  return core::Check(OCI_DirPathGetErrorRow(*this));
147 }
148 
149 }
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathReset(OCI_DirPath *dp)
Reset internal arrays and streams to prepare another load.
unsigned int GetErrorRow()
Return the index of a row which caused an error during data conversion.
Definition: DirectPath.hpp:144
void SetCacheSize(unsigned int value)
Set number of elements in the date cache.
Definition: DirectPath.hpp:124
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetCacheSize(OCI_DirPath *dp, unsigned int size)
Set number of elements in the date cache.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathGetRowCount(OCI_DirPath *dp)
Return the number of rows successfully loaded into the database so far.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetEntry(OCI_DirPath *dp, unsigned int row, unsigned int index, void *value, unsigned size, boolean complete)
Set the value of the given row/column array entry.
void SetNoLog(bool value)
Set the logging mode for the loading operation.
Definition: DirectPath.hpp:119
OCILIB ++ Namespace.
unsigned int GetRowCount() const
Return the number of rows successfully loaded into the database so far.
Definition: DirectPath.hpp:99
core::Enum< ResultValues > Result
Direct Operation Result.
Definition: types.hpp:8646
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so, it raises a C++ exception using the retrieved error handle.
Definition: Utils.hpp:53
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathGetErrorColumn(OCI_DirPath *dp)
Return the index of a column which caused an error during data conversion.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetCurrentRows(OCI_DirPath *dp, unsigned int nb_rows)
Set the current number of rows to convert and load.
void SetEntry(unsigned int rowIndex, unsigned int colIndex, const T &value, bool complete=true)
Set the value of the given row/column array entry from the given string.
Definition: DirectPath.hpp:39
void Reset()
Reset internal arrays and streams to prepare another load.
Definition: DirectPath.hpp:44
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathGetAffectedRows(OCI_DirPath *dp)
return the number of rows successfully processed during in the last conversion or loading call ...
void SetBufferSize(unsigned int value)
Set the size of the internal stream transfer buffer.
Definition: DirectPath.hpp:129
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathGetMaxRows(OCI_DirPath *dp)
Return the maximum number of rows allocated in the OCI and OCILIB internal arrays of rows...
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathGetCurrentRows(OCI_DirPath *dp)
Return the current number of rows used in the OCILIB internal arrays of rows.
unsigned int GetMaxRows() const
Return the maximum number of rows allocated in the OCI and OCILIB internal arrays of rows...
Definition: DirectPath.hpp:94
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetDateFormat(OCI_DirPath *dp, const otext *format)
Set the default date format string for input conversion.
void SetConversionMode(ConversionMode value)
Set the direct path conversion mode.
Definition: DirectPath.hpp:134
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathFlushRow(OCI_DirPath *dp)
Flushes a partially loaded row from server.
unsigned int GetCurrentRows() const
Return the current number of rows used in the OCILIB internal arrays of rows.
Definition: DirectPath.hpp:89
unsigned int GetErrorColumn()
Return the index of a column which caused an error during data conversion.
Definition: DirectPath.hpp:139
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathPrepare(OCI_DirPath *dp)
Prepares the OCI direct path load interface before any rows can be converted or loaded.
unsigned int GetAffectedRows() const
return the number of rows successfully processed during in the last conversion or loading call ...
Definition: DirectPath.hpp:104
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathLoad(OCI_DirPath *dp)
Loads the data converted to direct path stream format.
Template Enumeration template class providing some type safety to some extends for manipulating enume...
Definition: core.hpp:117
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathFree(OCI_DirPath *dp)
Free an OCI_DirPath handle.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathFinish(OCI_DirPath *dp)
Terminate a direct path operation and commit changes into the database.
void SetColumn(unsigned int colIndex, const ostring &name, unsigned int maxSize, const ostring &format=OTEXT(""))
Describe a column to load into the given table.
Definition: DirectPath.hpp:33
void Finish()
Terminate a direct path operation and commit changes into the database.
Definition: DirectPath.hpp:64
DirectPath::Result Convert()
Convert provided user data to the direct path stream format.
Definition: DirectPath.hpp:54
void Prepare()
Prepares the OCI direct path load interface before any rows can be converted or loaded.
Definition: DirectPath.hpp:49
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetConvertMode(OCI_DirPath *dp, unsigned int mode)
Set the direct path conversion mode.
OCI_SYM_PUBLIC OCI_DirPath *OCI_API OCI_DirPathCreate(OCI_TypeInfo *typinf, const otext *partition, unsigned int nb_cols, unsigned int nb_rows)
Create a direct path object.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetColumn(OCI_DirPath *dp, unsigned int index, const otext *name, unsigned int maxsize, const otext *format)
Describe a column to load into the given table.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetParallel(OCI_DirPath *dp, boolean value)
Set the parallel loading mode.
Provides type information on Oracle Database objects.
Definition: types.hpp:4508
void SetCurrentRows(unsigned int value)
Set the current number of rows to convert and load.
Definition: DirectPath.hpp:84
DirectPath::Result Load()
Loads the data converted to direct path stream format.
Definition: DirectPath.hpp:59
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathGetErrorRow(OCI_DirPath *dp)
Return the index of a row which caused an error during data conversion.
void Abort()
Terminate a direct path operation without committing changes.
Definition: DirectPath.hpp:69
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetBufferSize(OCI_DirPath *dp, unsigned int size)
Set the size of the internal stream transfer buffer.
void SetParallel(bool value)
Set the parallel loading mode.
Definition: DirectPath.hpp:114
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathAbort(OCI_DirPath *dp)
Terminate a direct path operation without committing changes.
DirectPath(const TypeInfo &typeInfo, unsigned int nbCols, unsigned int nbRows, const ostring &partition=OTEXT(""))
Constructor.
Definition: DirectPath.hpp:28
void SetDateFormat(const ostring &format)
Set the default date format string for input conversion.
Definition: DirectPath.hpp:109
std::basic_string< otext, std::char_traits< otext >, std::allocator< otext > > ostring
string class wrapping the OCILIB otext * type and OTEXT() macros ( see Character sets ) ...
Definition: config.hpp:120
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetNoLog(OCI_DirPath *dp, boolean value)
Set the logging mode for the loading operation.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathConvert(OCI_DirPath *dp)
Convert provided user data to the direct path stream format.
void FlushRow()
Flushes a partially loaded row from server.
Definition: DirectPath.hpp:79
void Save()
Execute a data save-point (server side)
Definition: DirectPath.hpp:74
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSave(OCI_DirPath *dp)
Execute a data save-point (server side)