title: PLS-00103 creating an external table with dynamic SQL
body: <p>I'm trying to dynamically create an external table but I'm getting error message <code>PLS-00103: Encountered the symbol "EXTERNAL"</code>. I'm also using <code>ora_hash</code> in the external table definition; please let me know it is the right way to get the <code>ora_hash</code> value. </p>
  
  <pre><code>create or replace procedure CHECKTABLEEXIST1 (p_tab_name in varchar2,DATAFILE in varchar2) --user_tables.table_name%type)                                    
  is                                     
  tab_name varchar2(100) := p_tab_name;                                    
  n Number(3);                                    
  ext_table varchar(100) := tab_name|| ' as select * from xyz WHERE 1=0';                                    
  begin                                    
  select  count(*) into n from tab where TName=upper(tab_name);                                    
  
  --dbms_output.put_line(n);                                    
  
  if n=0 then                                    
  execute immediate 'create table ' || ext_table ;                                    
  else                                    
  execute immediate 'drop table ' || tab_name;                                    
  execute immediate 'create table ' || ext_table;                                    
  ORGANIZATION EXTERNAL 
  (
  TYPE ORACLE_LOADER
  DEFAULT DIRECTORY DE_DUBFILE
  ACCESS PARAMETER 
      (
      RECORDS DELIMITED BY NEWLINE
      CHARACTERSET US7ASCII
      BADFILE     'UPLOAD':'p_tab_name.bad'
      DISCARDFILE 'UPLOAD':'p_tab_name.dis'
      LOGFILE     'UPLOAD':'p_tab_name.log'
      FILEDS TERMINATED BY ',' 
      optionally enclosed by '"'
      TRAILING NULLCOLS 
      MISSING FIELD VALUES ARE NULL
      (
      t1 ,t2,t3,t4,t5 date "YYYYMMDD" ,t6,t7,
      t8 ,t9 ,
      DETL_CLMNS_HASH "ORA_HASH( :t4||:t7 )",
      KEY_CLMNS_HASH "ORA_HASH(:t1||:t2||:t5)", t10,t11)
      )
  
  LOCATION (DATAFILE)    
  
  );
  end if;
  
  end;                                    
  </code></pre>
  
  <p>I'm getting error message :</p>
  
  <pre><code>LINE/COL ERROR                                                            
  -------- -----------------------------------------------------------------
  16/14    PLS-00103: Encountered the symbol "EXTERNAL" when expecting one o
           f the following:
  
     := . ( @ % ;
  </code></pre>