Thanks for the question, Ravinder.
Asked: June 21, 2000 - 7:29 am UTC
Last updated: May 27, 2008 - 7:44 am UTC
Version: 8.1.5
Viewed 1000+ times
You Asked
Hi Tom,
Sometime, I face the following error while loading data using
SQL*Loader
SQL*Loader-524 Partial Record found at end of datafile
I have seen the reply you have given for this. But the problem is I am working on Win NT 4.0 and my file size is normally between 500MB - 950MB. And I cant open the file. The problem which I have faced is that sometime the file has a end of file marker and it is treating this as a record.
Is there any way to remove this in Win NT or how can I ignore this using SQL*Loader. I will be upgrading 8.1.6 shortly.
Thanks
Ravi
and Tom said...
I wrote a tiny C program (will email you the binary as an attachment in another email). It simply opens the file for APPEND in binary mode and a mode that allows reading as well as writing. I goto the end of the file, read the last character. If that is NOT '\n', I put a '\n' at the end of the file. If it is a '\n', I do nothing at that point (file is unchanged).
The source code is:
#include "stdio.h"
void main(int argc, char * argv[])
{
FILE * input;
if ( argc < 2 )
{
printf( "usage: addnl FILENAME\n" );
exit(1);
}
/* Append in binary mode, allow for reading */
input = fopen( argv[1], "a+b" );
if ( input == NULL )
{
printf( "Error opening file %s\n", argv[1] );
perror( "fopen()" );
exit(1);
}
/* goto last character */
fseek( input, -1, SEEK_END );
if ( fgetc( input ) != '\n' )
{
printf( "Adding newline, was not there\n" );
fseek( input, 0, SEEK_END );
fputc( '\n', input );
}
else
{
printf( "Newline detected at EOF, not added\n" );
}
fclose( input );
}
and it should be relatively fast as it does not rewrite the entire file, just fixes it up in place. I'll send you the full source, binary and makefile.
Rating
(2 ratings)
Is this answer out of date? If it is, please let us know via a Comment