Home » Developer & Programmer » Precompilers, OCI & OCCI » OCI, DPL & Flat files
icon5.gif  OCI, DPL & Flat files [message #149224] Wed, 30 November 2005 11:51
Messages: 1
Registered: November 2005
Location: New York, NY
Junior Member
I'm new to Oracle and OCI. I've been trying to figure out a simple way to load data from a flat file to a database table using OCI & the Direct Path Loading Functions. I've been able to successfully load the file into memory (column arrays) and use DPL to load the table. However, since the number of records in the flat file could be large, I'd rather read each row and "send" the data. My code looks something like this :

// Initialize direct path context & direct path column array
// not shown

// Open & read data file
FILE *inpFil = fopen("SomeDataFile.dat", "r");
char colDelim = '\t';
int rowNum = 0;

fgets(inLine, 1000, inpFil);
while ( ! feof(inpFil) ) {
/* parse line read into an array of strings
using colDelim as the delimiters */
parseLine(inLine, colDelim, &pL);

/* Set entries in the column array to point to
the input data value for each column */
for ( colNum = 0; colNum < pL.size(); colNum++) {
retcode = OCIDirPathColArrayEntrySet(
dpca, errhp, rowNum, colNum,
(unsigned char *)&pL[colNum].data,

/* convert column array to direct path stream */
retcode = OCIDirPathColArrayToStream( dpca,
dpctx, dpstr, errhp, 1, 0);

fgets(inLine, 1000, inpFil);

/* Load the direct path stream */
retcode = OCIDirPathLoadStream( dpctx, dpstr, errhp );

/* Invoke the direct path finishing function */
retcode = OCIDirPathDataSave( dpctx, errhp,

// free up server data structures for the load.
retcode = OCIDirPathFinish( dpctx, errhp );

However, when I run this, it appears that all the elements in the table have a max size of the first element sent, which means most things are truncated. I've tried adding a OCIDirPathColArrayReset, but that did nothing.

What am I doing wrong ?

Previous Topic: Delay in Pro-C
Next Topic: can any body help me
Goto Forum:

Current Time: Sun Jul 12 02:50:40 CDT 2020