Solved

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

Posted on 2009-04-14
6
1,165 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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 how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

943 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now