Link to home
Start Free TrialLog in
Avatar of jainulap
jainulap

asked on

KUP-04002 when first time access of Oracle Extenal table from Unix

Hi,

I am having a strange problem accessing a file in Oracle through an external table. It fails the first time I access it, but works for subsequent attempts. During first time read, the error is

ERROR at line 1:
ORA-20000: -29913: ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04002: error getting file size for file

The file works fine as is, but I needed to do some modifications to the file before loading, and the problems are for the modified file. Modifications include a bit of Unix shell scripting, so I am not sure if this caused any file corruption. I did not see anything in plain sight though.

Are there any common reasons why an external table can throw this error just once and then start working?
I am not sure which piece of code would be relevant. Posting the offending Unix script piece for starters. Please let me know if you need anything else.
#New variables for massage
Year3=`date +%Y`
Year2=`expr $Year3 - 1`
Year1=`expr $Year2 - 1`
YearMinus1=`expr $Year1 - 1`
YearMinus2=`expr $YearMinus1 - 1`
Year1String=${Year1}000000000000000000000000000000
Year2String=${Year2}000000000000000000000000000000
Year3String=${Year3}000000000000000000000000000000
 
#Massage file. Divide the file into 5 tokens. File record adjustments are made based on the year field present on the second token.
 
sed -e "s|^\(.\{31,31\}\)\($YearMinus1.\{26,26\}\)\($Year1.\{26,26\}\)\($Year2.\{26,26\}\)\(.*$\)|\1\3\4$Year3String\5|g" 
-e "s|^\(.\{31,31\}\)\($YearMinus2.\{26,26\}\)\($YearMinus1.\{26,26\}\)\($Year1.\{26,26\}\)\(.*$\)|\1\4$Year2String$Year3String\5|g" < $file > ${file}_temp
 
#Move all massaged records back to original file. Note that records not massaged will be removed. 
grep "^.\{31,31\}$Year1" ${file}_temp> $file

Open in new window

Avatar of gatorvip
gatorvip
Flag of United States of America image

I'm a little bit unclear as to what happens here, so let me attempt to figure out the process:
- you have a file, let's call it fileA
- you run the code above in order to create fileA_temp and then you dump the contents of fileA_temp back into fileA
- finally, you get an error when trying to access the external table linked to fileA

Is this correct?

A few questions:
1. Are you getting any other error following KUP-04002?
2. How are you reading from the external table?
3. Is fileA also from a Unix system or is it coming from a different OS?
Avatar of jainulap
jainulap

ASKER

Resolved.

gatorvip - First of all, thanks for looking. To your questions, what I do is almost exactly as you mentioned. Only difference is that when I move from fileA_temp back to fileA, I drop some of the records in fileA_temp.

There is no other error following KUP-04002. The stack trace is exactly as I provided.
I am reading from the external table by calling a stored procedure using sqlplus from Unix. I also tried a direct select from sqlplus.
fileA is an ascii file coming from a Windows system.


How did it get resolved?
I honestly don't know. This was showing up consistently for one whole day, and resolved itself the next day. I did try doing the same thing in a couple of slightly different ways and finally came back to the original code. I could have accidentally corrected some mistake in the original script. I have not been able to reproduce the problem yet. I will post a solution when/if I find why this happened.
>>Resolved
Good to know! Sometimes it's very nice when issues just seem to work themselves out!

>>fileA is an ascii file coming from a Windows system.

It is possible there could be an initial error due to newline characters
Possible.
For a file that is coming from a windows system unaltered, the carriage return characters are just ignored by Oracle in Unix servers, because the external table definition does not include that last character.

My manipulation could have misplaced these ^M characters somewhere else, causing a problem. I did notice that the ^Ms disappeared once I tried the little manipulation using sed, so I guessed we were good to go.
ASKER CERTIFIED SOLUTION
Avatar of ee_auto
ee_auto

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial