OCILIB (C and C++ Driver for Oracle)  4.7.6
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-2023 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  Connection connection = typeInfo.GetConnection();
31 
32  AcquireAllocated
33  (
34  core::Check(OCI_DirPathCreate(typeInfo, partition.c_str(), nbCols, nbRows)),
35  connection.GetHandle()
36  );
37 }
38 
39 inline void DirectPath::SetColumn(unsigned int colIndex, const ostring& name, unsigned int maxSize, const ostring& format)
40 {
41  core::Check(OCI_DirPathSetColumn(*this, colIndex, name.c_str(), maxSize, format.c_str()));
42 }
43 
44 template<class T>
45 inline void DirectPath::SetEntry(unsigned int rowIndex, unsigned int colIndex, const T &value, bool complete)
46 {
47  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));
48 }
49 
50 inline void DirectPath::Reset()
51 {
53 }
54 
55 inline void DirectPath::Prepare()
56 {
58 }
59 
61 {
62  return Result(static_cast<Result::Type>(core::Check(OCI_DirPathConvert(*this))));
63 }
64 
66 {
67  return Result(static_cast<Result::Type>(core::Check(OCI_DirPathLoad(*this))));
68 }
69 
70 inline void DirectPath::Finish()
71 {
73 }
74 
75 inline void DirectPath::Abort()
76 {
78 }
79 
80 inline void DirectPath::Save()
81 {
83 }
84 
85 inline void DirectPath::FlushRow()
86 {
88 }
89 
90 inline void DirectPath::SetCurrentRows(unsigned int value)
91 {
93 }
94 
95 inline unsigned int DirectPath::GetCurrentRows() const
96 {
98 }
99 
100 inline unsigned int DirectPath::GetMaxRows() const
101 {
102  return core::Check(OCI_DirPathGetMaxRows(*this));
103 }
104 
105 inline unsigned int DirectPath::GetRowCount() const
106 {
107  return core::Check(OCI_DirPathGetRowCount(*this));
108 }
109 
110 inline unsigned int DirectPath::GetAffectedRows() const
111 {
113 }
114 
115 inline void DirectPath::SetDateFormat(const ostring& format)
116 {
117  core::Check(OCI_DirPathSetDateFormat(*this, format.c_str()));
118 }
119 
120 inline void DirectPath::SetParallel(bool value)
121 {
122  core::Check(OCI_DirPathSetParallel(*this, value));
123 }
124 
125 inline void DirectPath::SetNoLog(bool value)
126 {
127  core::Check(OCI_DirPathSetNoLog(*this, value));
128 }
129 
130 inline void DirectPath::SetCacheSize(unsigned int value)
131 {
132  core::Check(OCI_DirPathSetCacheSize(*this, value));
133 }
134 
135 inline void DirectPath::SetBufferSize(unsigned int value)
136 {
137  core::Check(OCI_DirPathSetBufferSize(*this, value));
138 }
139 
141 {
142  core::Check(OCI_DirPathSetConvertMode(*this, value));
143 }
144 
145 inline unsigned int DirectPath::GetErrorColumn()
146 {
147  return core::Check(OCI_DirPathGetErrorColumn(*this));
148 }
149 
150 inline unsigned int DirectPath::GetErrorRow()
151 {
152  return core::Check(OCI_DirPathGetErrorRow(*this));
153 }
154 
155 }
A connection or session with a specific database.
Definition: types.hpp:1580
void Save()
Execute a data save-point (server side)
Definition: DirectPath.hpp:80
void SetCurrentRows(unsigned int value)
Set the current number of rows to convert and load.
Definition: DirectPath.hpp:90
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:39
void Abort()
Terminate a direct path operation without committing changes.
Definition: DirectPath.hpp:75
unsigned int GetCurrentRows() const
Return the current number of rows used in the OCILIB internal arrays of rows.
Definition: DirectPath.hpp:95
unsigned int GetMaxRows() const
Return the maximum number of rows allocated in the OCI and OCILIB internal arrays of rows.
Definition: DirectPath.hpp:100
void FlushRow()
Flushes a partially loaded row from server.
Definition: DirectPath.hpp:85
unsigned int GetRowCount() const
Return the number of rows successfully loaded into the database so far.
Definition: DirectPath.hpp:105
unsigned int GetErrorRow()
Return the index of a row which caused an error during data conversion.
Definition: DirectPath.hpp:150
DirectPath::Result Load()
Loads the data converted to direct path stream format.
Definition: DirectPath.hpp:65
void Reset()
Reset internal arrays and streams to prepare another load.
Definition: DirectPath.hpp:50
void SetConversionMode(ConversionMode value)
Set the direct path conversion mode.
Definition: DirectPath.hpp:140
core::Enum< ResultValues > Result
Direct Operation Result.
Definition: types.hpp:8668
DirectPath::Result Convert()
Convert provided user data to the direct path stream format.
Definition: DirectPath.hpp:60
void SetCacheSize(unsigned int value)
Set number of elements in the date cache.
Definition: DirectPath.hpp:130
void SetParallel(bool value)
Set the parallel loading mode.
Definition: DirectPath.hpp:120
unsigned int GetErrorColumn()
Return the index of a column which caused an error during data conversion.
Definition: DirectPath.hpp:145
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:45
void SetDateFormat(const ostring &format)
Set the default date format string for input conversion.
Definition: DirectPath.hpp:115
void SetBufferSize(unsigned int value)
Set the size of the internal stream transfer buffer.
Definition: DirectPath.hpp:135
void Prepare()
Prepares the OCI direct path load interface before any rows can be converted or loaded.
Definition: DirectPath.hpp:55
DirectPath(const TypeInfo &typeInfo, unsigned int nbCols, unsigned int nbRows, const ostring &partition=OTEXT(""))
Constructor.
Definition: DirectPath.hpp:28
void SetNoLog(bool value)
Set the logging mode for the loading operation.
Definition: DirectPath.hpp:125
unsigned int GetAffectedRows() const
return the number of rows successfully processed during in the last conversion or loading call
Definition: DirectPath.hpp:110
void Finish()
Terminate a direct path operation and commit changes into the database.
Definition: DirectPath.hpp:70
Provides type information on Oracle Database objects.
Definition: types.hpp:4531
Connection GetConnection() const
Return the connection associated with a statement.
Definition: TypeInfo.hpp:52
Template Enumeration template class providing some type safety to some extends for manipulating enume...
Definition: core.hpp:118
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSave(OCI_DirPath *dp)
Execute a data save-point (server side)
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetParallel(OCI_DirPath *dp, boolean value)
Set the parallel loading mode.
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_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 unsigned int OCI_API OCI_DirPathGetCurrentRows(OCI_DirPath *dp)
Return the current number of rows used in the OCILIB internal arrays of rows.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetDateFormat(OCI_DirPath *dp, const otext *format)
Set the default date format string for input conversion.
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_DirPathFinish(OCI_DirPath *dp)
Terminate a direct path operation and commit changes into the database.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetConvertMode(OCI_DirPath *dp, unsigned int mode)
Set the direct path conversion mode.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathConvert(OCI_DirPath *dp)
Convert provided user data to the direct path stream format.
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.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathAbort(OCI_DirPath *dp)
Terminate a direct path operation without committing changes.
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 boolean OCI_API OCI_DirPathSetBufferSize(OCI_DirPath *dp, unsigned int size)
Set the size of the internal stream transfer buffer.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathSetNoLog(OCI_DirPath *dp, boolean value)
Set the logging mode for the loading operation.
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.
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathFlushRow(OCI_DirPath *dp)
Flushes a partially loaded row from server.
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.
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.
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 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_DirPathGetAffectedRows(OCI_DirPath *dp)
return the number of rows successfully processed during in the last conversion or loading call
OCI_SYM_PUBLIC boolean OCI_API OCI_DirPathReset(OCI_DirPath *dp)
Reset internal arrays and streams to prepare another load.
OCI_SYM_PUBLIC unsigned int OCI_API OCI_DirPathLoad(OCI_DirPath *dp)
Loads the data converted to direct path stream format.
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so,...
Definition: Utils.hpp:53
OCILIB ++ Namespace.
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
void * AnyPointer
Alias for the generic void pointer.
Definition: config.hpp:129