Skip to Main Content

Breadcrumb

XMAS_TREE

The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments, but we might still sneak in a few Office Hours sessions! Thanks for being a member of the AskTOM community.

Question and Answer

Chris Saxon

Thanks for the question, Arnaud.

Asked: October 29, 2024 - 8:51 am UTC

Last updated: October 29, 2024 - 1:48 pm UTC

Version: 19

Viewed 1000+ times

You Asked

hi,

i have a question regarding external table and macro's
we have an external table and and there are a couple of complex sql functions case, regexp, subst.. that i would 'hide' in a view, so we can reuse those expression in PLSQL.
With a view a cannot pass the location, so i thought a macro can help me out, but till now, no luck


select banner_full from v$version;
BANNER_FULL
--------------------------------------------------------------------------------
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.24.0.0.0

create table test_table (
    a       varchar2(10),
    b       varchar2(10),
    c       varchar2(10),
)
 organization external ( 
  type oracle_loader
  default directory dir_temp 
  access parameters ( 
    fields csv without embedded 
    missing field values are null
    reject rows with all null fields
  )  
  location ( 'test.csv' )
);

-- this works
select *  
  from test_table
 external modify (
  location('test.csv')
);


create or replace function external_table_macro_test
(
  p_tab       in dbms_tf.table_t
 ,p_filename in varchar2
) return clob sql_macro is
begin
  return q'{select a, case a when 'test' then b end as just_an_example from p_tab external modify(location('p_filename'))}';
end external_table_macro_test;
/


-- this returns an error, ORA-30663: An EXTERNAL MODIFY clause can only be specified for an external or hybrid-partitioned table.
select * from external_table_macro_test(p_tab => test_table, p_filename => 'test.csv' );


even without the filename parameter it fails, is this combination even possible?

thx


and Chris said...

It's a current limitation - I'll raise this with the dev team.

We're not taking comments currently, so please try again later if you want to add a comment.

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here