I'm running SQL Developer 3.0.04 for Linux (on Ubuntu 10.10) on my desktop. I have also got a Windows 7 guest on the same PC with SQL Developer 3.0.04
The database is Oracle EE 11.2.0.3 running on RHEL5.7 64-bit.
My problem (which I get in both Linux and Windows SQL Developer) is that I get an error when querying the external table. However, the query works fine from SQLPlus (run locally on the server).
To start, I created a directory and external table, of which the oracle user has read/write access at the Unix level to the directory. I have also granted read/write on the directory to the schema owner (AKLREG).
For example:
PREDICT: AKLREG > select * from all_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
------------------------------ ------------------------------ --------------------------------------------------
SYS PREDICT_ORACLE_DATA_DIR /predict_oracle/data
1 row selected.
# directory and file permissions okay as 'oracle' user
$ ls -l /predict_oracle/data/stuart_mis1541.tab
-rw-rw-r-- 1 testuser orasource 13555 Dec 2 15:18 /predict_oracle/data/stuart_mis1541.tab
$ id
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba),1070(orasource) context=user_u:system_r:unconfined_t
$ touch /predict_oracle/data/stuart_mis1541.tab
$
create table x__mis1541
( enhi varchar2(66),
gend char,
ethnicg1 number,
ethnicg2 number,
ethnicg3 number,
dom varchar2(4),
mesh varchar2(8),
bthdate date,
dthdate date,
last_updated date,
ethnicgp number,
dep01 number
)
ORGANIZATION EXTERNAL
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY predict_oracle_data_dir
ACCESS PARAMETERS
(
records delimited by newline
nologfile
nobadfile
skip 1
fields terminated by 0x'09' optionally enclosed by '"'
missing field values are null
)
LOCATION ('stuart_mis1541.tab')
)
REJECT LIMIT UNLIMITED;
{code}
From SQL Developer logged in as the schema user AKLREG:
{code}
select count(*) from x__mis1541;
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file stuart_mis1541.tab in PREDICT_ORACLE_DATA_DIR not found
29913. 00000 - "error in executing %s callout"
*Cause: The execution of the specified callout caused an error.
*Action: Examine the error messages take appropriate action.
{code}
From SQLPlus as the schema owner:
{code}
PREDICT: AKLREG > select count(*) from x__mis1541;
COUNT(*)
----------
99
1 row selected.
{code}
Looking through this forum, I found this post: https://forums.oracle.com/forums/thread.jspa?threadID=1074582&start=0&tstart=0
So,... I run this in SQLPlus with the details applicable to my directory and file:
{code}
SQL > !cat x.sql
declare
l_file utl_file.file_type;
l_file_name varchar2(20) := 'stuart_mis1541.tab';
l_exists boolean;
l_length number;
l_blksize number;
begin
utl_file.fgetattr('PREDICT_ORACLE_DATA_DIR', l_file_name, l_exists, l_length, l_blksize);
if (l_exists) then
dbms_output.put_line('File '||l_file_name||' exists');
else
dbms_output.put_line('File '||l_file_name||' does not exist');
end if;
end;
/
SQL> set serveroutput on
SQL> @x
File stuart_mis1541.tab exists
PL/SQL procedure successfully completed.
PREDICT: SURE006 >
{code}
When I run this from SQL Developer, I get:
{code}
anonymous block completed
File stuart_mis1541.tab does not exist
{code}
This should work according to http://sueharper.blogspot.com/2006/08/i-didnt-know-you-could-do-that.html
I would try and create an external table manually, but when go: Create table, Advanced, select External Table radio button, then DDL, I can not paste my code in (does this under Win 7 and Linux SQL for Developer 3.0).
Is querying external tables within SQL Developer broken, or am I doing something wrong?