Actual implementation of direct path API does not support the following elements :
All scalar datatypes (numerics, characters and date/time), including LOBs and LONG types are supported
#include "ocilib.h" #define SIZE_ARRAY 1000 #define SIZE_COL1 20 #define SIZE_COL2 30 #define SIZE_COL3 8 #define NUM_COLS 3 int main(void) { OCI_Connection *cn; OCI_DirPath *dp; OCI_TypeInfo *tbl; dtext val1[SIZE_COL1+1]; dtext val2[SIZE_COL2+1]; dtext val3[SIZE_COL3+1]; int i = 0, nb_rows = SIZE_ARRAY; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); tbl = OCI_TypeInfoGet(cn, "test_directpath", OCI_TIF_TABLE); dp = OCI_DirPathCreate(tbl, NULL, NUM_COLS, nb_rows); /* optional attributes to set */ OCI_DirPathSetBufferSize(dp, 64000); OCI_DirPathSetNoLog(dp, TRUE); OCI_DirPathSetParallel(dp, TRUE); /* describe the target table */ OCI_DirPathSetColumn(dp, 1, "VAL_INT", SIZE_COL1, NULL); OCI_DirPathSetColumn(dp, 2, "VAL_STR", SIZE_COL2, NULL); OCI_DirPathSetColumn(dp, 3, "VAL_DATE", SIZE_COL3, "YYYYMMDD"); /* prepare the load */ OCI_DirPathPrepare(dp); nb_rows = OCI_DirPathGetMaxRows(dp); for (i = 1; i <= nb_rows; i++) { /* fill test values */ ocisprintf(val1, SIZE_COL1+1, "%04d", i); ocisprintf(val2, SIZE_COL2+1, "value %05d", i); ocisprintf(val3, SIZE_COL3+1, "%04d%02d%02d", (i%23)+1 + 2000, (i%11)+1, (i%23)+1); OCI_DirPathSetEntry(dp, i, 1, val1, (unsigned int) dtslen(val1), TRUE); OCI_DirPathSetEntry(dp, i, 2, val2, (unsigned int) dtslen(val2), TRUE); OCI_DirPathSetEntry(dp, i, 3, val3, (unsigned int) dtslen(val3), TRUE); } /* load data to the server */ OCI_DirPathConvert(dp); OCI_DirPathLoad(dp); /* commits changes */ OCI_DirPathFinish(dp); printf("%04d row(s) processed\n", OCI_DirPathGetAffectedRows(dp)); printf("%04d row(s) loaded\n", OCI_DirPathGetRowCount(dp)); /* free direct path object */ OCI_DirPathFree(dp); OCI_Cleanup(); return EXIT_SUCCESS; }
Functions | |
OCI_EXPORT OCI_DirPath *OCI_API | OCI_DirPathCreate (OCI_TypeInfo *typinf, const mtext *partition, unsigned int nb_cols, unsigned int nb_rows) |
Create a direct path object. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathFree (OCI_DirPath *dp) |
Free an OCI_DirPath handle. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathSetColumn (OCI_DirPath *dp, unsigned int index, const mtext *name, unsigned int maxsize, const mtext *format) |
Describe a column to load into the given table. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathPrepare (OCI_DirPath *dp) |
Prepares the OCI direct path load interface before any rows can be converted or loaded. | |
OCI_EXPORT 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_EXPORT unsigned int OCI_API | OCI_DirPathConvert (OCI_DirPath *dp) |
Convert user provided data to a direct path stream format. | |
OCI_EXPORT unsigned int OCI_API | OCI_DirPathLoad (OCI_DirPath *dp) |
Loads the data converted to direct path stream format. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathReset (OCI_DirPath *dp) |
Reset internal arrays and streams to prepare another load. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathFinish (OCI_DirPath *dp) |
Terminate a direct path operation and commit changes into the database. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathAbort (OCI_DirPath *dp) |
Terminate a direct path operation without committing changes. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathSave (OCI_DirPath *dp) |
Execute a data savepoint (server side). | |
OCI_EXPORT boolean OCI_API | OCI_DirPathFlushRow (OCI_DirPath *dp) |
Flushes a partially loaded row from server. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathSetCurrentRows (OCI_DirPath *dp, unsigned int nb_rows) |
Set the current number of rows to convert and load. | |
OCI_EXPORT unsigned int OCI_API | OCI_DirPathGetCurrentRows (OCI_DirPath *dp) |
Return the current number of rows used in the OCILIB internal arrays of rows. | |
OCI_EXPORT 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_EXPORT boolean OCI_API | OCI_DirPathSetDateFormat (OCI_DirPath *dp, const mtext *format) |
Set the default date format string for input conversion. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathSetParallel (OCI_DirPath *dp, boolean value) |
Set the parallel loading mode. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathSetNoLog (OCI_DirPath *dp, boolean value) |
Set the logging mode for the loading operation. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathSetCacheSize (OCI_DirPath *dp, unsigned int size) |
Set number of elements in the date cache. | |
OCI_EXPORT boolean OCI_API | OCI_DirPathSetBufferSize (OCI_DirPath *dp, unsigned int size) |
Set the size of the internal stream transfer buffer. | |
OCI_EXPORT unsigned int OCI_API | OCI_DirPathGetRowCount (OCI_DirPath *dp) |
Return the number of rows successfully loaded into the database so far. | |
OCI_EXPORT 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_EXPORT unsigned int OCI_API | OCI_DirPathGetErrorColumn (OCI_DirPath *dp) |
Return the column index which caused an error during data conversion. | |
OCI_EXPORT unsigned int OCI_API | OCI_DirPathGetErrorRow (OCI_DirPath *dp) |
Return the row index which caused an error during data conversion. |
OCI_EXPORT boolean OCI_API OCI_DirPathAbort | ( | OCI_DirPath * | dp | ) |
Terminate a direct path operation without committing changes.
dp | - Direct path Handle |
Definition at line 1004 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, OCI_Connection::err, and OCI_DirPath::status.
OCI_EXPORT unsigned int OCI_API OCI_DirPathConvert | ( | OCI_DirPath * | dp | ) |
Convert user provided data to a direct path stream format.
dp | - Direct path Handle |
OCI_DirPathGetAffectedRows() returns the number of rows processed in the last call.
Definition at line 782 of file dirpath.c.
References OCI_DirPath::arr, OCI_DirPath::cols, OCI_DirPath::con, OCI_DirPath::ctx, OCI_Connection::err, OCI_DirPath::err_col, OCI_DirPath::err_row, OCI_DirPath::nb_cols, OCI_DirPath::nb_cur, OCI_DirPath::nb_prcsd, OCI_DirPath::status, and OCI_DirPath::strm.
OCI_EXPORT OCI_DirPath* OCI_API OCI_DirPathCreate | ( | OCI_TypeInfo * | typinf, | |
const mtext * | partition, | |||
unsigned int | nb_cols, | |||
unsigned int | nb_rows | |||
) |
Create a direct path object.
typinf | - Table type info handle | |
partition | - Partition name | |
nb_cols | - Number of columns to load | |
nb_rows | - Maximum of rows to handle per load operation |
Parameter 'nb_rows' is ignored for Oracle 8i. Prior to Oracle 9i, it's the OCI client that decides of the number of rows to process per convert/load calls. From Oracle 9i, OCI allows application to specify this value. Note that, the OCI client might not accept the input value. After OCI_DirPathPrepare() has been successfully called, OCI_DirPathGetMaxRows() returns the final number of rows used for the given direct path operation.
Definition at line 45 of file dirpath.c.
References OCI_DirPath::cols, OCI_DirPath::con, OCI_TypeInfo::con, OCI_DirPath::ctx, OCI_Connection::err, OCI_DirPath::err_col, OCI_DirPath::err_row, OCI_TypeInfo::name, OCI_DirPath::nb_cols, OCI_TypeInfo::nb_cols, OCI_DirPath::nb_cur, OCI_DirPath::nb_prcsd, OCI_DirPath::nb_rows, OCI_DirPathFree(), OCI_TypeInfo::schema, OCI_DirPath::status, OCI_TypeInfo::type, and OCI_DirPath::typinf.
OCI_EXPORT boolean OCI_API OCI_DirPathFinish | ( | OCI_DirPath * | dp | ) |
Terminate a direct path operation and commit changes into the database.
dp | - Direct path Handle |
Definition at line 975 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, OCI_Connection::err, OCI_DirPathReset(), and OCI_DirPath::status.
OCI_EXPORT boolean OCI_API OCI_DirPathFlushRow | ( | OCI_DirPath * | dp | ) |
Flushes a partially loaded row from server.
dp | - Direct path Handle |
Definition at line 1057 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, and OCI_Connection::err.
OCI_EXPORT boolean OCI_API OCI_DirPathFree | ( | OCI_DirPath * | dp | ) |
Free an OCI_DirPath handle.
dp | - Direct path Handle |
Definition at line 201 of file dirpath.c.
References OCI_DirPath::arr, OCI_DirPath::cols, OCI_DirPath::ctx, OCI_DirPath::nb_cols, and OCI_DirPath::strm.
Referenced by OCI_DirPathCreate().
OCI_EXPORT unsigned int OCI_API OCI_DirPathGetAffectedRows | ( | OCI_DirPath * | dp | ) |
return the number of rows successfully processed during in the last conversion or loading call
dp | - Direct path Handle |
Definition at line 1301 of file dirpath.c.
References OCI_DirPath::nb_prcsd.
OCI_EXPORT unsigned int OCI_API OCI_DirPathGetCurrentRows | ( | OCI_DirPath * | dp | ) |
Return the current number of rows used in the OCILIB internal arrays of rows.
dp | - Direct path Handle |
Definition at line 1102 of file dirpath.c.
References OCI_DirPath::nb_cur.
OCI_EXPORT unsigned int OCI_API OCI_DirPathGetErrorColumn | ( | OCI_DirPath * | dp | ) |
Return the column index which caused an error during data conversion.
dp | - Direct path Handle |
Definition at line 1314 of file dirpath.c.
References OCI_DirPath::err_col.
OCI_EXPORT unsigned int OCI_API OCI_DirPathGetErrorRow | ( | OCI_DirPath * | dp | ) |
Return the row index which caused an error during data conversion.
dp | - Direct path Handle |
Definition at line 1327 of file dirpath.c.
References OCI_DirPath::err_row.
OCI_EXPORT 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.
dp | - Direct path Handle |
Definition at line 1115 of file dirpath.c.
References OCI_DirPath::nb_rows.
OCI_EXPORT unsigned int OCI_API OCI_DirPathGetRowCount | ( | OCI_DirPath * | dp | ) |
Return the number of rows successfully loaded into the database so far.
dp | - Direct path Handle |
Definition at line 1288 of file dirpath.c.
References OCI_DirPath::nb_loaded.
OCI_EXPORT unsigned int OCI_API OCI_DirPathLoad | ( | OCI_DirPath * | dp | ) |
Loads the data converted to direct path stream format.
dp | - Direct path Handle |
Definition at line 910 of file dirpath.c.
References OCI_DirPath::arr, OCI_DirPath::con, OCI_DirPath::ctx, OCI_Connection::err, OCI_DirPath::err_col, OCI_DirPath::nb_cur, OCI_DirPath::nb_loaded, OCI_DirPath::nb_prcsd, OCI_DirPath::status, and OCI_DirPath::strm.
OCI_EXPORT boolean OCI_API OCI_DirPathPrepare | ( | OCI_DirPath * | dp | ) |
Prepares the OCI direct path load interface before any rows can be converted or loaded.
dp | - Direct path Handle |
Definition at line 512 of file dirpath.c.
References OCI_DirPath::arr, OCI_DirPath::cols, OCI_DirPath::con, OCI_DirPath::ctx, OCI_Connection::cxt, OCI_Connection::err, OCI_DirPath::nb_cols, OCI_DirPath::nb_cur, OCI_DirPath::nb_rows, OCI_DirPath::status, and OCI_DirPath::strm.
OCI_EXPORT boolean OCI_API OCI_DirPathReset | ( | OCI_DirPath * | dp | ) |
Reset internal arrays and streams to prepare another load.
dp | - Direct path Handle |
Definition at line 749 of file dirpath.c.
References OCI_DirPath::arr, OCI_DirPath::con, OCI_Connection::err, and OCI_DirPath::strm.
Referenced by OCI_DirPathFinish(), and OCI_DirPathSave().
OCI_EXPORT boolean OCI_API OCI_DirPathSave | ( | OCI_DirPath * | dp | ) |
Execute a data savepoint (server side).
dp | - Direct path Handle |
Definition at line 1031 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, OCI_Connection::err, and OCI_DirPathReset().
OCI_EXPORT boolean OCI_API OCI_DirPathSetBufferSize | ( | OCI_DirPath * | dp, | |
unsigned int | size | |||
) |
Set the size of the internal stream transfer buffer.
dp | - Direct path Handle | |
size | - Buffer size |
Definition at line 1261 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, and OCI_Connection::err.
OCI_EXPORT boolean OCI_API OCI_DirPathSetCacheSize | ( | OCI_DirPath * | dp, | |
unsigned int | size | |||
) |
Set number of elements in the date cache.
dp | - Direct path Handle | |
size | - Buffer size |
Setting the value to 0 disables the cache
Definition at line 1213 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, and OCI_Connection::err.
OCI_EXPORT boolean OCI_API OCI_DirPathSetColumn | ( | OCI_DirPath * | dp, | |
unsigned int | index, | |||
const mtext * | name, | |||
unsigned int | maxsize, | |||
const mtext * | format | |||
) |
Describe a column to load into the given table.
dp | - Direct path Handle | |
index | - Column index | |
name | - Column name | |
maxsize | - Maximum input value size for a column entry | |
format | - Date or numeric format to use |
Definition at line 232 of file dirpath.c.
References OCI_DirPath::cols, OCI_TypeInfo::cols, OCI_DirPath::con, OCI_DirPath::ctx, OCI_Connection::err, OCI_TypeInfo::name, OCI_Column::name, OCI_TypeInfo::nb_cols, OCI_DirPath::nb_cols, OCI_Column::ocode, OCI_Column::prec, OCI_Column::scale, OCI_Column::subtype, OCI_Column::type, and OCI_DirPath::typinf.
OCI_EXPORT boolean OCI_API OCI_DirPathSetCurrentRows | ( | OCI_DirPath * | dp, | |
unsigned int | nb_rows | |||
) |
Set the current number of rows to convert and load.
dp | - Direct path Handle | |
nb_rows | - Number of row to process |
Definition at line 1081 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::nb_cur, and OCI_DirPath::nb_rows.
OCI_EXPORT boolean OCI_API OCI_DirPathSetDateFormat | ( | OCI_DirPath * | dp, | |
const mtext * | format | |||
) |
Set the default date format string for input conversion.
dp | - Direct path Handle | |
format | - date format |
Definition at line 1127 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, and OCI_Connection::err.
OCI_EXPORT 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.
dp | - Direct path Handle | |
row | - Row index | |
index | - Column index | |
value | - Value to set | |
size | - Size of the input value | |
complete | - Is the entry content fully provided ? |
The 'size' parameter is expressed in number of :
Direct path support piece loading for LONGs and LOBs columns. When filling these columns, it's possible to provide input buffer piece by piece. In order to do so :
OCI_EXPORT boolean OCI_API OCI_DirPathSetNoLog | ( | OCI_DirPath * | dp, | |
boolean | value | |||
) |
Set the logging mode for the loading operation.
dp | - Direct path Handle | |
value | - enable/disable logging |
Definition at line 1186 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, and OCI_Connection::err.
OCI_EXPORT boolean OCI_API OCI_DirPathSetParallel | ( | OCI_DirPath * | dp, | |
boolean | value | |||
) |
Set the parallel loading mode.
dp | - Direct path Handle | |
value | - enable/disable parallel mode |
Setting the value to TRUE allows multiple load sessions to load the same segment concurrently
Definition at line 1160 of file dirpath.c.
References OCI_DirPath::con, OCI_DirPath::ctx, and OCI_Connection::err.