Solved

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

Posted on 2009-04-14
6
1,172 Views
Last Modified: 2013-12-26
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

0
Comment
Question by:jainulap
  • 2
  • 2
6 Comments
 
LVL 20

Expert Comment

by:gatorvip
ID: 24147387
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?
0
 

Author Comment

by:jainulap
ID: 24178415
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.
0
 
LVL 20

Expert Comment

by:gatorvip
ID: 24184287
>>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
0
 

Author Comment

by:jainulap
ID: 24219432
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.
0
 

Accepted Solution

by:
ee_auto earned 0 total points
ID: 24457150
Question PAQ'd, 50 points refunded, and stored in the solution database.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
selective queries 7 38
Problem with duplicate records in Oracle query 16 40
error in my cursor 5 41
minium over 4 numeric columns for each row in oracle 2 29
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question