Load external table data in Oracle 11g

0

I would like to know if you can help me with a process that I am trying to adapt to get some interesting data from the trace files.

I have an external table called "cursor", which performs the loading of data through a program in Perl "cursor.pl"; load works with all those fields but something happens in the program that the lineno field that keeps the number of lines seems to intersect with string data.

What I did was try putting the lineno field in varchar 100 to see what happened, and load this:

And if I want to omit the sql_text field, it falls down when recreating the table and doing a select.

External Table

create table  
cursor (
          lineno number,
          crsr number,
          crsr_length number,
          call_depth number,
          parsing_user_id number,
          command_type number,
          parsing_schema_id number,
          tim number,
          hash_value number,
          address varchar2(50),
          sqlid varchar2(20),
          sql_text varchar2(4000)
          )
          organization external
            (
            type oracle_loader
            default directory "TRACE_DIR"
            access parameters
              (
                records delimited by newline
                preprocessor exe_trc_dir:'cursor.pl'
                logfile trace_dir:'cursor.log'
                badfile trace_dir:'cursor.bad'
                fields terminated by '!' optionally enclosed by "'"
                MISSING FIELD VALUES ARE NULL
                (
                  lineno char,          
                  crsr char,
                  crsr_length char,
                  call_depth char,
                  parsing_user_id char,
                  command_type char,
                  parsing_schema_id char,
                  tim char,
                  hash_value char,
                  address char,
                  sqlid char,
                  sql_text char(4000)
                )
              )
            location ('bdutec01_ora_15431.trc')
          );  

Perl file

#!/usr/bin/perl
use strict;
use warnings;
while (<>) {
  if (/^PARSING IN CURSOR/../END OF STMT/) {
    if (/^PARSING IN CURSOR/) {
      s/^PARSING IN CURSOR \#//;
      s/ [a-z]+=/!/g;
      s/\n$/!/;
      $_="$.!$_";
    }
    unless (/^END OF STMT/) {
      print;
    }
  }
}
    
asked by Eddie Yair Purisaca Rivera 10.08.2018 в 00:44
source

0 answers