Optimize Clob concatenation

Hi, I have a stored proc that return a string containing a concatenation of the result of a select on a unique column.
The code is about the following :
CREATE OR REPLACE PROCEDURE pGetAllProductSpec (ProdId in Varchar2 , CaracLob out clob) IS
len BINARY_INTEGER := 32767;
CURSOR c1 (prod_id varchar2) IS
     SELECT PRODUCT_SPEC FROM PRODUCT_SPECIFICATION
     WHERE PRODUCT_ID = prod_id ;
BEGIN
DBMS_LOB.CREATETEMPORARY(Caraclob, TRUE);
FOR product_carac IN c1( ProdId) LOOP
len:=length(product_carac.PRODUCT_SPEC);
dbms_lob.WRITEAPPEND(CaracLob, len, product_carac.PRODUCT_SPEC);
END LOOP;
END;
It works quite well, but I find that the loop to concatenate the result take too much time.
I need a Clob because, I don't know exactly the length of the result
I would like to optimize it. Has anyone a suggest ?

Also, benchmark the use of bulk operations to see if you can benefit.
SQL> DECLARE
  2      vclob        CLOB;
  3      vchar_buffer VARCHAR2(32767);
  4  BEGIN
  5      dbms_lob.createtemporary(vclob,
  6                               cache => TRUE);
  7      vchar_buffer := NULL;
  8
  9      FOR rec IN (SELECT text FROM all_source)
10      LOOP
11          IF length(vchar_buffer) + length(rec.text) > 32767
12          THEN
13              dbms_lob.writeappend(vclob,
14                                   length(vchar_buffer),
15                                   vchar_buffer);
16              vchar_buffer := NULL;
17          END IF;
18          vchar_buffer := vchar_buffer || rec.text;
19      END LOOP;
20      dbms_lob.writeappend(vclob,
21                           length(vchar_buffer),
22                           vchar_buffer);
23  END;
24  /
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.13
SQL> DECLARE
  2      vclob        CLOB;
  3      vchar_buffer VARCHAR2(32767);
  4      CURSOR cur IS
  5          SELECT text FROM all_source;
  6      TYPE rec_table IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
  7      rec_tab rec_table;
  8  BEGIN
  9      dbms_lob.createtemporary(vclob,
10                               cache => TRUE);
11      vchar_buffer := NULL;
12
13      OPEN cur;
14      LOOP
15          rec_tab.DELETE;
16          FETCH cur BULK COLLECT
17              INTO rec_tab LIMIT 100;
18          FOR idx IN 1 .. rec_tab.COUNT
19          LOOP
20              IF length(vchar_buffer) + length(rec_tab(idx)) > 32767
21              THEN
22                  dbms_lob.writeappend(vclob,
23                                       length(vchar_buffer),
24                                       vchar_buffer);
25                  vchar_buffer := NULL;
26              END IF;
27              vchar_buffer := vchar_buffer || rec_tab(idx);
28          END LOOP;
29          EXIT WHEN cur%NOTFOUND ;
30      END LOOP;
31      CLOSE cur;
32      dbms_lob.writeappend(vclob,
33                           length(vchar_buffer),
34                           vchar_buffer);
35  END;
36  /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.70
SQL>

Similar Messages

  • Error raised when concatenating to CLOB using implicit to_char conversion

    Hi there,
    Please consider the code below (Oracle 11.1.0.7.0):
    DECLARE
      c CLOB;
    BEGIN
      FOR i IN 1..10
      LOOP
        -- Please uncomment ONE of the lines below
        c := c ||  LPAD('x', 8000, 'z') || i; -- raises error ora-06502
        --c := c || (LPAD('x', 8000, 'z') || i);  -- works
        --c := c ||  LPAD('x', 8000, 'z') || to_char(i);  -- works
      END LOOP;
    END;Ok, maybe making use of implicit type conversion is not the best thing to do, but just out of curiosity is there any explanation for this error to happen?
    It seems that, when implicit conversion is involved without the aid of brackets, Oracle tries to convert the whole thing to varchar2 before concatenating it to the clob, raising the error.
    Thanks
    Luis

    Hi,
    Accordingly link below, I think this behavior can be explained
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/datatypes.htm#CIHGBADF
    Case 1
    c := c ||  LPAD('x', 8000, 'z') || i
    How it going
    1. Evaluate expression  res1 = LPAD('x', 8000, 'z')
    2. Next oracle must to evaluate  c||res1 where c is clob and res1 is varchar2
    3. Oracle can and choose implicit conversation res1 to clob
    4. Evaluate expression  res2 = c||to_clob(res1);  where res2 now is clob
    5. Next oracle must to evaluate  res2||i where res2 is clob and i is number
    6. Oracle can implicitly convert number only to varchar2 not to clob so he choose implicit conversation i to varchar2
    6.1 Oracle implicitly try convert res2 to varchar2 and when res2 size more then 32627 then he raise error ORA-06502Case 2
    c := c || (LPAD('x', 8000, 'z') || i)
    How it going
    1. Evaluate expression  res1 = LPAD('x', 8000, 'z')
    2. Next oracle must to evaluate  res1||i where res1 is varchar2 and i is number
    3. So he convert i to varchar2 and evaluate res2 = res1||to_char(i)
    4. Next oracle must to evaluate  c||res2 where res2 is varchar2 and c is clob
    5. So he convert res2 to clob and evaluate c||to_clob(res2)Case 3
    c := c ||  LPAD('x', 8000, 'z') || to_char(i)
    How it going
    0. Evaluate res0 = to_char(i)
    1. Evaluate expression  res1 = LPAD('x', 8000, 'z')
    2. Next oracle must to evaluate  c||res1 where c is clob and res1 is varchar2
    3. Oracle can and choose implicit conversation res1 to clob
    4. Evaluate expression  res2 = c||to_clob(res1);  where res2 now is clob
    5. Next oracle must to evaluate  res2||res0 where res2 is clob and res0 is varchar2
    6. He evaluate  to_clob(res0)||res2

  • Insert concatenated data from Varchar2 to Clob

    Hi,
    I have a table with the following structure:
    create table logmst (logno varchar2(10), log_detail1 varchar2(4000), log_detail2(4000));
    I would like to concatenate the data from log_detail1 and log_Detail2 into a Clob datatype. So, i have created another table:
    create table test(id varchar2(10), filedesc clob default empty_clob());
    I tried:
    insert into test (id, filedesc) select logno, to_clob(log_Detail1 || log_Detail2) from logmst;
    System shows ORA-01489: result of string concatenation is too long.
    Can somebody help? Thanks in advance.

    You have to write a small procedure. You cannot achieve this using a SQL statment.
    Declare
       myClob CLOB;
       logNo logMst.logNo%type;
       col1 logmst.log_detail1%type;
       col2 logmst.log_detail2%type;
       length_col1 number;
    begin
        For rec in (select logNo, log_Detail1, log_Detail2 from logMst)
        loop
                  logNo := rec.LogNo;
                  col1 := rec.Log_Detail1;
                  col2 := rec.Log_Detail2;
                     myClob := empty_clob();
                    dbms_lob.createtemporary(myClob, TRUE);
                    length_col1 := length(col1);
                    dbms_lob.write(myClob , length_col1,1,col1);
                    dbms_lob.write(myClob , length(col2), length_col1+1,col1);
                   -- Write here SQL statemnt to write this CLOB to your table...
        end loop;
    end;Thanks,
    Dharmesh Patel

  • Optimize a data parser that converts CLOB into table

    I am importing complex array data from Cold Fusion into ORACLE using a stored procedure. What I've done is convert the data into a CLOB, pass it into ORACLE, then parse it into a temporary table using a pipelined function. Unfortunately the array is large (16k rows) and it's taking a while to run.
    What I'm looking is a better optimization for the data conversion. I've tried XML and the dbms_xmlstore but it was too slow. I am on 10g and don't have access to the log files or even the ability to trace anything. All I can do is look for better ways to do things and then try them.
    Any suggestions or help to improve things would be welcome.
    Warren Koch
    The function converts the array of object into a custom delimited CLOB ( ; betwen values, | between rows) that looks like this:
    prop1;prop2;prop3|prop1;prop2;prop3|prop1;prop2;prop3|prop1;prop2;prop3|
    Here is the code I created.
    CREATE OR REPLACE TYPE THE_IMAGE_TYPE AS OBJECT
    IMAGE_NAME VARCHAR2(100),
    IMAGE_SIZE INTEGER,
    IMAGE_LOC INTEGER
    CREATE OR REPLACE TYPE THE_IMAGE_TABLE AS TABLE OF THE_IMAGE_TYPE
    CREATE GLOBAL TEMPORARY TABLE IMAGE_IMPORT
    image_name VARCHAR2(25 BYTE),
    loc NUMBER(11),
    image_size NUMBER(11)
    ON COMMIT PRESERVE ROWS
    NOCACHE;
    FUNCTION convert_image_data(
         in_image_clob IN CLOB
         RETURN the_image_table PIPELINED
    AS
         image_clob CLOB := in_image_clob;
         image_delim_index PLS_INTEGER;
         image_index PLS_INTEGER := 1;
         row_string VARCHAR2(1000);
         out_rec THE_image_type;
    BEGIN
         out_rec := the_image_type(NULL, NULL, NULL);
         IF SUBSTR(in_image_clob, -1, 1) != '|'
         THEN
              image_clob := image_clob || '|';
         END IF;
         image_delim_index := INSTR(image_clob, '|', image_index);
         WHILE image_delim_index > 0
         LOOP
              row_string := SUBSTR(image_clob, image_index, image_delim_index - image_index);
              row_string := REPLACE(row_string || '::::', ':', ' :');
              out_rec.image_name := SUBSTR(TRIM(REGEXP_SUBSTR(row_string, '[^:]+', 1, 1)), 1, 25);
              out_rec.image_loc := make_number(REGEXP_SUBSTR(row_string, '[^:]+', 1, 2));
              out_rec.image_size := make_number(REGEXP_SUBSTR(row_string, '[^:]+', 1, 3));
              PIPE ROW(out_rec);
              image_index := image_delim_index + 1;
              image_delim_index := INSTR(image_clob, '|', image_index);
         END LOOP;
         RETURN;
    EXCEPTION
         WHEN OTHERS
         THEN
              RAISE;
    END;
    Used in my code like this:
    EXECUTE IMMEDIATE 'TRUNCATE TABLE image_import';
    FOR x IN (SELECT * FROM TABLE(convert_image_data(in_imagelist))
    WHERE image_name IS NOT NULL)
    LOOP
    INSERT INTO image_import (image_name, loc, image_size)
                   VALUES (x.image_name, x.image_loc, x.image_size);
    END LOOP;

    Is there any chance you can just use 1 SQL statement here? I gave it a shot based on the string you posted, not by trying to reverse engineer your code so it's possible i got it entirely wrong :)
    select
        regexp_substr(image_row, '[^;]+', 1, 1) as image_name,
        regexp_substr(image_row, '[^;]+', 1, 2) as image_size,
        regexp_substr(image_row, '[^;]+', 1, 3) as image_loc   
    from
       select
           regexp_substr(the_data, '[^|]+', 1, level) as image_row
       from
          select
             'prop1;prop2;prop3|prop4;prop5;prop6|propa;propb;propc|propd;prope;propf|' as the_data
          from dual
       connect by level <= length (regexp_replace(the_data, '[^|]+'))  + 1
    17  where image_row is not null;
    IMAGE_NAME                     IMAGE_SIZE                     IMAGE_LOC
    prop1                          prop2                          prop3
    prop4                          prop5                          prop6
    propa                          propb                          propc
    propd                          prope                          propf
    4 rows selected.
    Elapsed: 00:00:00.00

  • Concatenating clobs

    Hi
    I have a question on concatenating many small clobs into a large. DB = 11.2.0.1.
    The following is a sample set of data;
    create table t_bi001_payment
    (customer_number number
    ,payment clob
    begin
    for i in 1..1000 loop
    insert into t_bi001_payment (customer_number
                                ,payment)
    values  
    (1
    ,'200003783511655968                   000000000000100000320000000000100
    26Kalles Plåt AB
    27Storgatan 2                        12345
    28Storåker
    29005500001234
    210003783511                    898540000000000000500002200023000011100
    26Kalles Plåt AB
    27Storgatan 2                        12345
    28Storåker
    2900550000' || lpad(i, 4, '0'));
    end loop;
    commit;
    end;
    /There are thousands of such clobs, which have to be concatenated per customer into a single clob.
    Each clob should start on a new line.
    The first technique I used was connect by, which I picked up from; http://www.williamrobertson.net/
    create table abc (c clob)
    insert into abc (c)
    select ltrim(max(sys_connect_by_path(payment,',')) keep (dense_rank last order by curr),',') as clob_val
    from   (select customer_number
                  ,payment
                  ,row_number() over (partition by customer_number order by customer_number) AS curr,
                   row_number() over (partition by customer_number order by customer_number) -1 AS prev
            from   t_bi001_payment)
    group by customer_number
    connect by prev = prior curr and customer_number = prior customer_number
    start with curr = 1
    commit
    /The above statement returns error:
    ORA-01489: result of string concatenation is too long
    The following statement is an alternative method:
    insert into abc (c)
    select to_clob(concatenated)
    from
    select   xmlagg (xmlelement (c, payment || chr(13))).extract ('//text()') as concatenated
    from     t_bi001_payment
    group by customer_number
    commit
    /The above statement returns a similar error, but different message:
    ORA-19011: Character string buffer too small
    I realise that in both cases the SQL 4000 varchar2 limit has been reached.
    The question I have is how can I concatenate hundreds or possibly
    thousands of clobs (all relatively small, mostly around 1 or 2k)
    into a single larger clob using SQL without having to revert to PL/SQL ?
    thx
    Edited by: bluefrog on Mar 8, 2011 10:52 AM

    Oddly, I was just looking at the following example code in relation to another thread.
    This is a user defined aggregate function for concatenating clobs...
    create or replace
      type clobagg_type as object(
                                  text clob,
                                  static function ODCIAggregateInitialize(
                                                                          sctx in out clobagg_type
                                    return number,
                                  member function ODCIAggregateIterate(
                                                                       self  in out clobagg_type,
                                                                       value in     clob
                                    return number,
                                  member function ODCIAggregateTerminate(
                                                                         self        in     clobagg_type,
                                                                         returnvalue    out clob,
                                                                         flags       in     number
                                    return number,
                                  member function ODCIAggregateMerge(
                                                                     self in out clobagg_type,
                                                                     ctx2 in     clobagg_type
                                    return number
    create or replace
      type body clobagg_type
        is
          static function ODCIAggregateInitialize(
                                                  sctx in out clobagg_type
            return number
            is
            begin
                sctx := clobagg_type(null) ;
                return ODCIConst.Success ;
          end;
          member function ODCIAggregateIterate(
                                               self  in out clobagg_type,
                                               value in     clob
            return number
            is
            begin
                self.text := self.text || value ;
                return ODCIConst.Success;
          end;
          member function ODCIAggregateTerminate(
                                                 self        in     clobagg_type,
                                                 returnvalue    out clob,
                                                 flags       in     number
            return number
            is
            begin
                returnValue := self.text;
                return ODCIConst.Success;
            end;
          member function ODCIAggregateMerge(
                                             self in out clobagg_type ,
                                             ctx2 in     clobagg_type
            return number
            is
            begin
                self.text := self.text || ctx2.text;
                return ODCIConst.Success;
            end;
    end;
    create or replace
      function clobagg(
                       input clob
        return clob
        deterministic
        parallel_enable
        aggregate using clobagg_type;
    SQL> select trim(',' from clobagg(ename||',')) as enames from emp;
    ENAMES
    SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MILLER
    SQL>Not my code, just one I've picked up from elsewhere over time.

  • Help to optimize file load (clobs involved) via pl/sql

    Hello.
    I have written a procedure that loads a table from a file, this table has five clob columns and the file has 7024 rows (which means 5*7024 clobs are loaded in the table). Every record in the file ends in "\r\n\r\n" (I mean chr(13)||chr(10)||chr(13)||chr(10))
    The complete load of the file has taken around 5 hours, I wonder if the procedure can be optimized as I am new to the dmbs_lob package.
    The procuedure is called carga_t_pets_respuestas_emisor and belongs to a package called carga_tablas.
    I load the whole file in a temporary clob and then I get every line into another temporary clob (I look for the end of record separator (chr(13)||chr(10)||chr(13)||chr(10)) for each line).
    Here I post the whole body of tha package (the code is long because the table has 25 columns, but the treatement is the same for every column):
    CREATE OR REPLACE PACKAGE BODY MAPV4_MIGRATION.carga_tablas
    AS
       NAME:       CARGA_TABLAS
       PURPOSE:
       REVISIONS:
       Ver        Date        Author           Description
       1.0        07/12/2009             1. Created this package.
       PROCEDURE tratar_linea (
          p_lin     IN       CLOB,
          contlin   IN       INTEGER,
          p_log     IN       UTL_FILE.file_type,
          msg       IN OUT   VARCHAR2
       IS
          v_id_peticion                    t_peticiones_respuestas_emisor.id_peticion%TYPE;
          v_id_transaccion                 t_peticiones_respuestas_emisor.id_transaccion%TYPE;
          v_fecha_recepcion                VARCHAR2 (50);
          v_cod_certificado                t_peticiones_respuestas_emisor.cod_certificado%TYPE;
          v_cif_requirente                 t_peticiones_respuestas_emisor.cif_requirente%TYPE;
          v_num_elementos                  t_peticiones_respuestas_emisor.num_elementos%TYPE;
          v_fichero_peticion               t_peticiones_respuestas_emisor.fichero_peticion%TYPE;
          v_ter                            t_peticiones_respuestas_emisor.ter%TYPE;
          v_fecha_ini_proceso              VARCHAR2 (50);
          v_fecha_fin_proceso              VARCHAR2 (50);
          v_fichero_respuesta              t_peticiones_respuestas_emisor.fichero_respuesta%TYPE;
          v_cn                             t_peticiones_respuestas_emisor.cn%TYPE;
          v_contador_enviados              t_peticiones_respuestas_emisor.contador_enviados%TYPE;
          v_signature                      t_peticiones_respuestas_emisor.signature%TYPE;
          v_caducidad                      VARCHAR2 (50);
          v_descompuesta                   t_peticiones_respuestas_emisor.descompuesta%TYPE;
          v_estado                         t_peticiones_respuestas_emisor.estado%TYPE;
          v_error                          t_peticiones_respuestas_emisor.error%TYPE;
          v_cod_municipio_volante          t_peticiones_respuestas_emisor.cod_municipio_volante%TYPE;
          v_peticion_solicitud_respuesta   t_peticiones_respuestas_emisor.peticion_solicitud_respuesta%TYPE;
          v_id_fabricante_ve               t_peticiones_respuestas_emisor.id_fabricante_ve%TYPE;
          v_fecha_respuesta                VARCHAR2 (50);
          v_codigo_error                   t_peticiones_respuestas_emisor.codigo_error%TYPE;
          v_serial                         t_peticiones_respuestas_emisor.serial%TYPE;
          v_inicio_col                     INTEGER;
          v_fin_col                        INTEGER;
          v_timestamp_format               VARCHAR2 (50)
                                                       := 'yyyy-mm-dd hh24:mi:ss';
       BEGIN
          UTL_FILE.put_line (p_log, 'INICIO tratar_linea');
          -- Columna ID_PETICION
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', 1, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', 1, 1) - 1;
          UTL_FILE.put_line (p_log,
                                'v_inicio_col: '
                             || v_inicio_col
                             || '; v_fin_col: '
                             || v_fin_col
          UTL_FILE.fflush (p_log);
          v_id_peticion :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_id_peticion: ' || v_id_peticion);
          UTL_FILE.fflush (p_log);
          -- Columna ID_TRANSACCION
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_id_transaccion :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_id_transaccion: ' || v_id_transaccion);
          UTL_FILE.fflush (p_log);
          -- Columna FECHA_RECEPCION
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_fecha_recepcion :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_fecha_recepcion: ' || v_fecha_recepcion);
          UTL_FILE.fflush (p_log);
          -- Columna COD_CERTIFICADO
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_cod_certificado :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_cod_certificado: ' || v_cod_certificado);
          UTL_FILE.fflush (p_log);
          -- Columna CIF_REQUIRENTE
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_cif_requirente :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_cif_requirente: ' || v_cif_requirente);
          UTL_FILE.fflush (p_log);
          -- Columna NUM_ELEMENTOS
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_num_elementos :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_num_elementos: ' || v_num_elementos);
          UTL_FILE.fflush (p_log);
          -- Columna FICHERO_PETICION
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_fichero_peticion :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                                'Longitud v_fichero_peticion: '
                             || DBMS_LOB.getlength (v_fichero_peticion)
          UTL_FILE.fflush (p_log);
          --UTL_FILE.put_line (p_log, 'v_fichero_peticion: ' || v_fichero_peticion);
          -- Columna TER
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_ter :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_ter: ' || v_ter);
          UTL_FILE.fflush (p_log);
          -- Columna FECHA_INI_PROCESO
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_fecha_ini_proceso :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                             'v_fecha_ini_proceso: ' || v_fecha_ini_proceso);
          UTL_FILE.fflush (p_log);
          -- Columna FECHA_FIN_PROCESO
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_fecha_fin_proceso :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                             'v_fecha_fin_proceso: ' || v_fecha_fin_proceso);
          UTL_FILE.fflush (p_log);
          -- Columna FICHERO_RESPUESTA
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_fichero_respuesta :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                                'Longitud v_fichero_respuesta: '
                             || DBMS_LOB.getlength (v_fichero_respuesta)
          UTL_FILE.fflush (p_log);
          --UTL_FILE.put_line (p_log,
          --                   'v_fichero_respuesta: ' || v_fichero_respuesta);
          -- Columna CN
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_cn :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_cn: ' || v_cn);
          UTL_FILE.fflush (p_log);
          -- Columna CONTADOR_ENVIADOS
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_contador_enviados :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                             'v_CONTADOR_ENVIADOS: ' || v_contador_enviados);
          UTL_FILE.fflush (p_log);
          -- Columna SIGNATURE
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_signature :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                                'Longitud v_signature: '
                             || DBMS_LOB.getlength (v_signature)
          UTL_FILE.fflush (p_log);
          --UTL_FILE.put_line (p_log, 'v_SIGNATURE: ' || v_signature);
          -- Columna CADUCIDAD
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_caducidad :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_CADUCIDAD: ' || v_caducidad);
          UTL_FILE.fflush (p_log);
          -- Columna DESCOMPUESTA
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_descompuesta :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_DESCOMPUESTA: ' || v_descompuesta);
          UTL_FILE.fflush (p_log);
          -- Columna ESTADO
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_estado :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_ESTADO: ' || v_estado);
          UTL_FILE.fflush (p_log);
          -- Columna ERROR
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_error :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                             'Longitud v_ERROR: ' || DBMS_LOB.getlength (v_error)
          UTL_FILE.fflush (p_log);
          --UTL_FILE.put_line (p_log, 'v_ERROR: ' || v_error);
          -- Columna COD_MUNICIPIO_VOLANTE
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_cod_municipio_volante :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                             'v_COD_MUNICIPIO_VOLANTE: '
                             || v_cod_municipio_volante
          UTL_FILE.fflush (p_log);
          -- Columna PETICION_SOLICITUD_RESPUESTA
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_peticion_solicitud_respuesta :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log,
                                'Longitud v_PETICION_SOLICITUD_RESPUESTA: '
                             || DBMS_LOB.getlength (v_peticion_solicitud_respuesta)
          UTL_FILE.fflush (p_log);
          --UTL_FILE.put_line (p_log,
          --                      'v_PETICION_SOLICITUD_RESPUESTA: '
          --                   || v_peticion_solicitud_respuesta
          -- Columna ID_FABRICANTE_VE
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_id_fabricante_ve :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_ID_FABRICANTE_VE: ' || v_id_fabricante_ve);
          UTL_FILE.fflush (p_log);
          -- Columna FECHA_RESPUESTA
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_fecha_respuesta :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_FECHA_RESPUESTA: ' || v_fecha_respuesta);
          UTL_FILE.fflush (p_log);
          -- Columna CODIGO_ERROR
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_codigo_error :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_CODIGO_ERROR: ' || v_codigo_error);
          -- Columna SERIAL
          UTL_FILE.fflush (p_log);
          v_inicio_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 1) + 1;
          --La ultima columna puede no llevar '",' sino '"'
          --v_fin_col := DBMS_LOB.INSTR (p_lin, '",', v_fin_col + 2, 1) - 1;
          v_fin_col := DBMS_LOB.INSTR (p_lin, '"', v_fin_col + 2, 2) - 1;
          --DBMS_OUTPUT.put_line (   'v_inicio_col: '
          --                      || v_inicio_col
          --                      || '; v_fin_col: '
          --                      || v_fin_col
          v_serial :=
               DBMS_LOB.SUBSTR (p_lin, v_fin_col - v_inicio_col + 1, v_inicio_col);
          UTL_FILE.put_line (p_log, 'v_SERIAL: ' || v_serial);
          UTL_FILE.fflush (p_log);
          -- Insercion en tabla
          INSERT INTO t_histo_ptcions_rspstas_emisor
                      (id_peticion, id_transaccion,
                       fecha_recepcion,
                       cod_certificado, cif_requirente, num_elementos,
                       fichero_peticion, ter,
                       fecha_ini_proceso,
                       fecha_fin_proceso,
                       fichero_respuesta, cn, contador_enviados,
                       signature,
                       caducidad,
                       descompuesta, estado, error,
                       cod_municipio_volante, peticion_solicitud_respuesta,
                       id_fabricante_ve,
                       fecha_respuesta,
                       codigo_error, serial
               VALUES (v_id_peticion, v_id_transaccion,
                       TO_TIMESTAMP (v_fecha_recepcion, v_timestamp_format),
                       v_cod_certificado, v_cif_requirente, v_num_elementos,
                       v_fichero_peticion, v_ter,
                       TO_TIMESTAMP (v_fecha_ini_proceso, v_timestamp_format),
                       TO_TIMESTAMP (v_fecha_fin_proceso, v_timestamp_format),
                       v_fichero_respuesta, v_cn, v_contador_enviados,
                       v_signature,
                       TO_TIMESTAMP (v_caducidad, v_timestamp_format),
                       v_descompuesta, v_estado, v_error,
                       v_cod_municipio_volante, v_peticion_solicitud_respuesta,
                       v_id_fabricante_ve,
                       TO_TIMESTAMP (v_fecha_respuesta, v_timestamp_format),
                       v_codigo_error, v_serial
          -- Se valida la transaccion
          --COMMIT;
          UTL_FILE.put_line (p_log, 'FIN tratar_linea');
       EXCEPTION
          WHEN OTHERS
          THEN
             msg := SQLERRM;
             --ROLLBACK;
             RAISE;
       END;
       PROCEDURE carga_t_pets_respuestas_emisor (
          p_dir        IN       VARCHAR2,
          p_filename   IN       VARCHAR2,
          p_os         IN       VARCHAR2,
          msg          OUT      VARCHAR2
       IS
          no_fin_linea     EXCEPTION;
          v_srcfile        BFILE;
          v_tmpclob        CLOB;
          v_warning        INTEGER;
          v_dest_offset    INTEGER            := 1;
          v_src_offset     INTEGER            := 1;
          v_lang           INTEGER            := 0;
          posfinlinea      NUMBER;
          posiniciolinea   NUMBER;
          cad              VARCHAR2 (30000);
          v_lin            CLOB;
          v_tamfich        NUMBER;
          contlin          INTEGER            := 0;
          v_log            UTL_FILE.file_type;
       BEGIN
          msg := NULL;
          -- abrimos el log
          v_log :=
                UTL_FILE.fopen (p_dir, 'carga_t_pets_respuestas_emisor.log', 'w');
          UTL_FILE.put_line (v_log, 'INICIO carga_t_pets_respuestas_emisor');
          UTL_FILE.fflush (v_log);
          v_srcfile := BFILENAME (p_dir, p_filename);
          DBMS_LOB.createtemporary (v_tmpclob, TRUE, DBMS_LOB.CALL);
          DBMS_LOB.OPEN (v_srcfile);
          DBMS_LOB.loadclobfromfile (dest_lob          => v_tmpclob,
                                     src_bfile         => v_srcfile,
                                     amount            => DBMS_LOB.lobmaxsize,
                                     dest_offset       => v_dest_offset,
                                     src_offset        => v_src_offset,
                                     bfile_csid        => 0,
                                     lang_context      => v_lang,
                                     warning           => v_warning
          -- Una vez cargado el CLOB se puede cerrar el BFILE
          DBMS_LOB.CLOSE (v_srcfile);
          v_tamfich := DBMS_LOB.getlength (v_tmpclob);
          --DBMS_OUTPUT.put_line ('v_tamfich: ' || v_tamfich);
          UTL_FILE.put_line (v_log, 'v_tamfich: ' || v_tamfich);
          UTL_FILE.fflush (v_log);
          posfinlinea := 0;
          posiniciolinea := posfinlinea + 1;
          -- Despreciamos el último fin de linea (tiene que existir)
          IF (UPPER (p_os) = 'WINDOWS')
          THEN
             v_tamfich := v_tamfich - 4;
          ELSE
             v_tamfich := v_tamfich - 2;
          END IF;
          contlin := 1;
          WHILE (v_tamfich + 1 - posfinlinea > 0)
          LOOP
             --contlin := contlin + 1;
             IF (UPPER (p_os) = 'WINDOWS')
             THEN
                posfinlinea :=
                   DBMS_LOB.INSTR (v_tmpclob,
                                   CHR (13) || CHR (10) || CHR (13) || CHR (10),
                                   posiniciolinea
             ELSE
                posfinlinea :=
                   DBMS_LOB.INSTR (v_tmpclob, CHR (13) || CHR (13),
                                   posiniciolinea);
             END IF;
             IF (posfinlinea = 0)
             THEN
                RAISE no_fin_linea;
             END IF;
             --DBMS_OUTPUT.put_line ('posfinlinea: ' || posfinlinea);
             UTL_FILE.put_line (v_log, 'posfinlinea: ' || posfinlinea);
             UTL_FILE.fflush (v_log);
             IF (DBMS_LOB.getlength (v_lin) != 0)
             THEN
                DBMS_LOB.freetemporary (v_lin);
                UTL_FILE.put_line (v_log,
                                   'Se ha reinicializado el temporary clob v_lin'
                UTL_FILE.fflush (v_log);
             END IF;
             DBMS_LOB.createtemporary (v_lin, TRUE, DBMS_LOB.CALL);
             DBMS_LOB.COPY (dest_lob         => v_lin,
                            src_lob          => v_tmpclob,
                            amount           => posfinlinea,
                            dest_offset      => 1,
                            src_offset       => posiniciolinea
    -- Tratamos la linea
    --DBMS_OUTPUT.put_line
             UTL_FILE.put_line
                (v_log,
             UTL_FILE.fflush (v_log);
             tratar_linea (v_lin, contlin, v_log, msg);
             posiniciolinea := posfinlinea + 1;
             contlin := contlin + 1;
             --DBMS_OUTPUT.put_line ('posiniciolinea: ' || posiniciolinea);
             UTL_FILE.put_line (v_log, 'posiniciolinea: ' || posiniciolinea);
             UTL_FILE.fflush (v_log);
          END LOOP;
          -- Se valida la transaccion
          COMMIT;
          --Se cierra el fichero
          --DBMS_LOB.CLOSE (v_srcfile);
          DBMS_LOB.freetemporary (v_tmpclob);
          UTL_FILE.put_line (v_log, 'FIN carga_t_pets_respuestas_emisor');
          UTL_FILE.fclose (v_log);
       EXCEPTION
          WHEN no_fin_linea
          THEN
             ROLLBACK;
             msg := 'Fichero mal formateado, no se encuentra el fin de linea';
             IF (DBMS_LOB.ISOPEN (v_srcfile) = 1)
             THEN
                DBMS_LOB.fileclose (v_srcfile);
             END IF;
             IF UTL_FILE.is_open (v_log)
             THEN
                UTL_FILE.fclose (v_log);
             END IF;
          WHEN OTHERS
          THEN
             ROLLBACK;
             msg := SQLERRM;
             IF (DBMS_LOB.ISOPEN (v_srcfile) = 1)
             THEN
                DBMS_LOB.fileclose (v_srcfile);
             END IF;
             IF UTL_FILE.is_open (v_log)
             THEN
                UTL_FILE.fclose (v_log);
             END IF;
       END carga_t_pets_respuestas_emisor;
    END carga_tablas;
    /Thanks in advance.

    Thank you again for answering.
    I am reading from the file in the procedure carga_t_pets_respuestas_emisor I posted above (the procedure is able to load the whole file in the table but takes very long).
    What I am doing is loading the whole file in a BFILE and then loading it in a CLOB variable using loadclobfromfile (it is not taking very long because I can see that early in the log):
          v_srcfile := BFILENAME (p_dir, p_filename);
          DBMS_LOB.createtemporary (v_tmpclob, TRUE, DBMS_LOB.CALL);
          DBMS_LOB.OPEN (v_srcfile);
          DBMS_LOB.loadclobfromfile (dest_lob          => v_tmpclob,
                                     src_bfile         => v_srcfile,
                                     amount            => DBMS_LOB.lobmaxsize,
                                     dest_offset       => v_dest_offset,
                                     src_offset        => v_src_offset,
                                     bfile_csid        => 0,
                                     lang_context      => v_lang,
                                     warning           => v_warning
                                    );Then I read in a loop all the records (I cannot call them lines because the CLOB columns can contain line feeds) from the file and load them it in another CLOB variable:
    WHILE (v_tamfich + 1 - posfinlinea > 0)
          LOOP
             --contlin := contlin + 1;
             IF (UPPER (p_os) = 'WINDOWS')
             THEN
                posfinlinea :=
                   DBMS_LOB.INSTR (v_tmpclob,
                                   CHR (13) || CHR (10) || CHR (13) || CHR (10),
                                   posiniciolinea
             ELSE
                posfinlinea :=
                   DBMS_LOB.INSTR (v_tmpclob, CHR (13) || CHR (13),
                                   posiniciolinea);
             END IF;
             IF (posfinlinea = 0)
             THEN
                RAISE no_fin_linea;
             END IF;
             --DBMS_OUTPUT.put_line ('posfinlinea: ' || posfinlinea);
             UTL_FILE.put_line (v_log, 'posfinlinea: ' || posfinlinea);
             UTL_FILE.fflush (v_log);
             IF (DBMS_LOB.getlength (v_lin) != 0)
             THEN
                DBMS_LOB.freetemporary (v_lin);
                UTL_FILE.put_line (v_log,
                                   'Se ha reinicializado el temporary clob v_lin'
                UTL_FILE.fflush (v_log);
             END IF;
             DBMS_LOB.createtemporary (v_lin, TRUE, DBMS_LOB.CALL);
             DBMS_LOB.COPY (dest_lob         => v_lin,
                            src_lob          => v_tmpclob,
                            amount           => posfinlinea,
                            dest_offset      => 1,
                            src_offset       => posiniciolinea
    -- Tratamos la linea
    --DBMS_OUTPUT.put_line
             UTL_FILE.put_line
                (v_log,
             UTL_FILE.fflush (v_log);
             tratar_linea (v_lin, contlin, v_log, msg);
             posiniciolinea := posfinlinea + 1;
             contlin := contlin + 1;
             --DBMS_OUTPUT.put_line ('posiniciolinea: ' || posiniciolinea);
             UTL_FILE.put_line (v_log, 'posiniciolinea: ' || posiniciolinea);
             UTL_FILE.fflush (v_log);
          END LOOP;(I have also loaded the whole file using sql*loader, but I have asked to try to do it with pl/sql)
    Thanks again and regards.

  • String literal too long error while invoking a package with clob variable

    I have a package.One of the input variables of the procedure in packae is clob.
    I want to invoke this package with a huge clob as input.
    when i invoke this package like that i am getting following error
    PLS-00172 string literal too long
    can't we pass clob(huge clob) as input .is there any solution for that ?
    Thanks
    Pramod Garre

    842802 wrote:
    If insert this data into a table , from sql prompt still i get the same error.Do you mean SQL*Plus? Then there is buffer limitation and it is better to split literal into, let say 1000 character chunks:
    SQL*Plus: Release 10.2.0.4.0 - Production on Tue Mar 29 16:17:26 2011
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
      6  from dual;
    TO_CLOB('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    SQL> SY.

  • Query optimization in Oracle 8i (tunning)

    Hi everyone,
    The following SQL statement use more than 15% of the CPU of the machine where it is executed. Please if somebody can help me to rewrite or hinting the query.
    This is the statement:
    SELECT
    /*+ INDEX(APD IDX_ABAPLANI_DET_SOL)  */ 
    apd.sinonimo,
    apd.sinonimo_planificacion,
    apd.cod_despensa,
    apd.estante_cod,
    apd.correlativo_solicitud,
    apd.prioridad,
    apd.correlativo_det_sol,
    apd.insumo_sinonimo,
    apd.cantidad_solicitada,
    apd.cantidad_despachada,
    apd.estado,
    apd.sinonimo_usuario,
    apd.sinonimo_observacion,
    ap.fecha_creacion,
    ap.centro_resultado,
    aud.nombre,
    aud.a_paterno,
    aud.rut,
    aud.username,
    cenres.cod_flex codigocr,
    insumo.cod_flex insumocod,
    cenres.des_flex despensa_descripcion,
    cenres.des_flex crdescripcion,
    insumo.des_flex insumodescripcion
    FROM
    aba_usuario_despachador aud,
    cenres,
    insumo,
    aba_planificacion_detalle apd,
    aba_planificacion ap
    WHERE ap.sinonimo = apd.sinonimo_planificacion
    AND aud.sinonimo = apd.sinonimo_usuario
    AND ap.centro_resultado = cenres.sinonimo
    AND insumo.sinonimo = apd.insumo_sinonimo
    AND apd.sinonimo_usuario = NVL (:b1, apd.sinonimo_usuario)
    AND apd.sinonimo_planificacion = NVL (:b2, apd.sinonimo_planificacion)
    AND apd.correlativo_solicitud = NVL (:b3, apd.correlativo_solicitud)
    AND apd.estante_cod = NVL (UPPER (:b4), apd.estante_cod)
    AND apd.cod_despensa = NVL (UPPER (:b5), apd.cod_despensa)
    AND apd.estado = NVL (:b6, apd.estado)
    AND ap.centro_resultado = NVL (:b7, ap.centro_resultado)
    AND TO_DATE (TO_CHAR (ap.fecha_creacion, 'dd/mm/yyyy'), 'dd/mm/yyyy')
    BETWEEN TO_DATE (NVL (:b8,TO_CHAR (ap.fecha_creacion, 'dd/mm/yyyy')),'dd/mm/yyyy')
    AND TO_DATE (NVL (:b9,TO_CHAR (ap.fecha_creacion, 'dd/mm/yyyy')),'dd/mm/yyyy')
    AND apd.estado NOT LIKE :b10
    ORDER BY apd.sinonimo;The version of the database is 8.1.7.4.0.
    Here is the output of EXPLAIN PLAN:
    Plan
    SELECT STATEMENT  CHOOSECost: 2,907  Bytes: 104,312  Cardinality: 472                                               
         32 SORT ORDER BY  Cost: 2,907  Bytes: 104,312  Cardinality: 472                                          
              31 CONCATENATION                                     
                   15 FILTER                                
                        14 NESTED LOOPS  Cost: 11  Bytes: 52,156  Cardinality: 236                           
                             11 NESTED LOOPS  Cost: 10  Bytes: 177  Cardinality: 1                      
                                  8 NESTED LOOPS  Cost: 9  Bytes: 133  Cardinality: 1                 
                                       5 NESTED LOOPS  Cost: 8  Bytes: 67  Cardinality: 1            
                                            2 TABLE ACCESS BY INDEX ROWID ADMABA.ABA_PLANIFICACION_DETALLE Cost: 7  Bytes: 52  Cardinality: 1       
                                                 1 INDEX FULL SCAN NON-UNIQUE ADMABA.IDX_ABAPLANI_DET_SOL Cost: 3  Cardinality: 1 
                                            4 TABLE ACCESS BY INDEX ROWID ADMABA.ABA_PLANIFICACION Cost: 1  Bytes: 15  Cardinality: 1       
                                                 3 INDEX UNIQUE SCAN UNIQUE ADMABA.PK_ABA_PLANIFICACION Cardinality: 1 
                                       7 TABLE ACCESS BY INDEX ROWID ADMABA.ABA_USUARIO_DESPACHADOR Cost: 1  Bytes: 3,498  Cardinality: 53            
                                            6 INDEX UNIQUE SCAN UNIQUE ADMABA.ABA_USUARIO_DESPACHADOR_PK Cardinality: 53       
                                  10 TABLE ACCESS BY INDEX ROWID OPS$NUCLEO.NUC_CODIGOS_FLEXIBLES Cost: 1  Bytes: 14,828  Cardinality: 337                 
                                       9 INDEX UNIQUE SCAN UNIQUE OPS$NUCLEO.NUC_CODFLEX_PK Cardinality: 337            
                             13 TABLE ACCESS BY INDEX ROWID OPS$NUCLEO.NUC_CODIGOS_FLEXIBLES Cost: 1  Bytes: 1.037.828  Cardinality: 23,587                      
                                  12 INDEX UNIQUE SCAN UNIQUE OPS$NUCLEO.NUC_CODFLEX_PK Cardinality: 23,587                 
                   30 FILTER                                
                        29 NESTED LOOPS  Cost: 11  Bytes: 52,156  Cardinality: 236                           
                             26 NESTED LOOPS  Cost: 10  Bytes: 177  Cardinality: 1                      
                                  23 NESTED LOOPS  Cost: 9  Bytes: 133  Cardinality: 1                 
                                       20 NESTED LOOPS  Cost: 8  Bytes: 67  Cardinality: 1            
                                            17 TABLE ACCESS BY INDEX ROWID ADMABA.ABA_PLANIFICACION_DETALLE Cost: 7  Bytes: 52  Cardinality: 1       
                                                 16 INDEX RANGE SCAN NON-UNIQUE ADMABA.IDX_ABAPLANI_DET_SOL Cost: 3  Cardinality: 1 
                                            19 TABLE ACCESS BY INDEX ROWID ADMABA.ABA_PLANIFICACION Cost: 1  Bytes: 15  Cardinality: 1       
                                                 18 INDEX UNIQUE SCAN UNIQUE ADMABA.PK_ABA_PLANIFICACION Cardinality: 1 
                                       22 TABLE ACCESS BY INDEX ROWID ADMABA.ABA_USUARIO_DESPACHADOR Cost: 1  Bytes: 3,498  Cardinality: 53            
                                            21 INDEX UNIQUE SCAN UNIQUE ADMABA.ABA_USUARIO_DESPACHADOR_PK Cardinality: 53       
                                  25 TABLE ACCESS BY INDEX ROWID OPS$NUCLEO.NUC_CODIGOS_FLEXIBLES Cost: 1  Bytes: 14,828  Cardinality: 337                 
                                       24 INDEX UNIQUE SCAN UNIQUE OPS$NUCLEO.NUC_CODFLEX_PK Cardinality: 337            
                             28 TABLE ACCESS BY INDEX ROWID OPS$NUCLEO.NUC_CODIGOS_FLEXIBLES Cost: 1  Bytes: 1.037.828  Cardinality: 23,587                      
                                  27 INDEX UNIQUE SCAN UNIQUE OPS$NUCLEO.NUC_CODFLEX_PK Cardinality: 23,587                 Thanks in advance!
    Edited by: user491853 on 21-ago-2012 15:29

    A few comments looking at your sql query:
    How much time the query is taking?
    How many rows are there in the tables?
    Make sure the stats are up-to-date.
    Please kindly follow the instructions provided by others as well.
    >
    The version of the database is 8.1.7.4.0
    >
    Suggestion: Upgrade your version. Oracle Cost Based Optimizer is more smarter now.Upgrading will make your life much more easier as there are so many enhancements.
    AND TO_DATE (TO_CHAR (ap.fecha_creacion, 'dd/mm/yyyy'), 'dd/mm/yyyy')
    BETWEEN TO_DATE (NVL (:b8,TO_CHAR (ap.fecha_creacion, 'dd/mm/yyyy')),'dd/mm/yyyy')
    AND TO_DATE (NVL (:b9,TO_CHAR (ap.fecha_creacion, 'dd/mm/yyyy')),'dd/mm/yyyy')Why are you using TO_DATE/TO_CHAR on a date column?
    AND ap.centro_resultado = NVL (:b7, ap.centro_resultado)the same can be rewritten as below:
    AND (ap.centro_resultado =:b7 and :b7 is not null) or :b7 is null This applies to other predicates you are using as well.
    The table used in the plan is not found in your sql query eg NUC_CODIGOS_FLEXIBLES.
    Regards
    Biju

  • Execution plan with Concatenation

    Hi All,
    Could anyone help in finding why concatenation is being used by optimizer and how can i avoid it.
    Oracle Version : 10.2.0.4
    select * from
                               select distinct EntityType, EntityID, DateModified, DateCreated, IsDeleted
                               from ife.EntityIDs i
                               join (select orgid from equifaxnormalize.org_relationships where orgid is not null and related_orgid is not null
                                  and ((Date_Modified >= to_date('2011-06-12 14:00:00','yyyy-mm-dd hh24:mi:ss') and Date_Modified < to_date('2011-06-13 14:00:00','yyyy-mm-dd hh24:mi:ss'))
                                        OR (Date_Created >= to_date('2011-06-12 14:00:00','yyyy-mm-dd hh24:mi:ss') and Date_Created < to_date('2011-06-13 14:00:00','yyyy-mm-dd hh24:mi:ss'))
                     ) r on(r.orgid= i.entityid)
                               where EntityType = 1
                and ((DateModified >= to_date('2011-06-12 14:00:00','yyyy-mm-dd hh24:mi:ss') and DateModified < to_date('2011-06-13 14:00:00','yyyy-mm-dd hh24:mi:ss'))
                                              OR (DateCreated >= to_date('2011-06-12 14:00:00','yyyy-mm-dd hh24:mi:ss') and DateCreated < to_date('2011-06-13 14:00:00','yyyy-mm-dd hh24:mi:ss'))
                               and ( IsDeleted = 0)
                               and IsDistributable = 1
                               and EntityID >= 0
                               order by EntityID
                               --order by NLSSORT(EntityID,'NLS_SORT=BINARY')
                             where rownum <= 10;
    Execution Plan
    Plan hash value: 227906424
    | Id  | Operation                                 | Name                          | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT                          |                               |    10 |   570 |    39   (6)| 00:00:01 |       |       |
    |*  1 |  COUNT STOPKEY                            |                               |       |       |            |          |       |       |
    |   2 |   VIEW                                    |                               |    56 |  3192 |    39   (6)| 00:00:01 |       |       |
    |*  3 |    SORT ORDER BY STOPKEY                  |                               |    56 |  3416 |    39   (6)| 00:00:01 |       |       |
    |   4 |     HASH UNIQUE                           |                               |    56 |  3416 |    38   (3)| 00:00:01 |       |       |
    |   5 |      CONCATENATION                        |                               |       |       |            |          |       |       |
    |*  6 |       TABLE ACCESS BY INDEX ROWID         | ORG_RELATIONSHIPS             |     1 |    29 |     1   (0)| 00:00:01 |       |       |
    |   7 |        NESTED LOOPS                       |                               |    27 |  1647 |    17   (0)| 00:00:01 |       |       |
    |   8 |         TABLE ACCESS BY GLOBAL INDEX ROWID| ENTITYIDS                     |    27 |   864 |     4   (0)| 00:00:01 | ROWID | ROWID |
    |*  9 |          INDEX RANGE SCAN                 | UX_TYPE_MOD_DIST_DEL_ENTITYID |    27 |       |     2   (0)| 00:00:01 |       |       |
    |* 10 |         INDEX RANGE SCAN                  | IX_EFX_ORGRELATION_ORGID      |     1 |       |     1   (0)| 00:00:01 |       |       |
    |* 11 |       TABLE ACCESS BY INDEX ROWID         | ORG_RELATIONSHIPS             |     1 |    29 |     1   (0)| 00:00:01 |       |       |
    |  12 |        NESTED LOOPS                       |                               |    29 |  1769 |    20   (0)| 00:00:01 |       |       |
    |  13 |         PARTITION RANGE ALL               |                               |    29 |   928 |     5   (0)| 00:00:01 |     1 |     3 |
    |* 14 |          TABLE ACCESS BY LOCAL INDEX ROWID| ENTITYIDS                     |    29 |   928 |     5   (0)| 00:00:01 |     1 |     3 |
    |* 15 |           INDEX RANGE SCAN                | IDX_ENTITYIDS_ETYPE_DC        |    29 |       |     4   (0)| 00:00:01 |     1 |     3 |
    |* 16 |         INDEX RANGE SCAN                  | IX_EFX_ORGRELATION_ORGID      |     1 |       |     1   (0)| 00:00:01 |       |       |
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM<=10)
       3 - filter(ROWNUM<=10)
       6 - filter(("DATE_MODIFIED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "DATE_MODIFIED"<TO_DATE(' 2011-06-13
                  14:00:00', 'syyyy-mm-dd hh24:mi:ss') OR "DATE_CREATED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "DATE_CREATED"<TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss')) AND "RELATED_ORGID" IS NOT NULL)
       9 - access("I"."ENTITYTYPE"=1 AND "I"."DATEMODIFIED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "I"."ISDISTRIBUTABLE"=1 AND "I"."ISDELETED"=0 AND "I"."ENTITYID">=0 AND "I"."DATEMODIFIED"<=TO_DATE(' 2011-06-13 14:00:00',
                  'syyyy-mm-dd hh24:mi:ss'))
           filter("I"."ISDISTRIBUTABLE"=1 AND "I"."ISDELETED"=0 AND "I"."ENTITYID">=0)
      10 - access("ORGID"="I"."ENTITYID")
           filter("ORGID" IS NOT NULL AND "ORGID">=0)
      11 - filter(("DATE_MODIFIED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "DATE_MODIFIED"<TO_DATE(' 2011-06-13
                  14:00:00', 'syyyy-mm-dd hh24:mi:ss') OR "DATE_CREATED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "DATE_CREATED"<TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss')) AND "RELATED_ORGID" IS NOT NULL)
      14 - filter("I"."ISDISTRIBUTABLE"=1 AND "I"."ISDELETED"=0 AND (LNNVL("I"."DATEMODIFIED">=TO_DATE(' 2011-06-12 14:00:00',
                  'syyyy-mm-dd hh24:mi:ss')) OR LNNVL("I"."DATEMODIFIED"<=TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss'))) AND
                  "I"."ENTITYID">=0)
      15 - access("I"."ENTITYTYPE"=1 AND "I"."DATECREATED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "I"."DATECREATED"<=TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      16 - access("ORGID"="I"."ENTITYID")
           filter("ORGID" IS NOT NULL AND "ORGID">=0)ife.entityids table has been range - partitioned on data_provider column.
    Is there any better way to rewrite this sql OR is there any way to eliminate concatenation ?
    Thanks

    We cant use data_provider in the given query. We need to pull data irrespective of data_provider and it should be based on ENTITYID.
    Yes table has only three partitions...
    Not sure issue is due to concatenation....but we are in process to create desired indexes which will help for this sql.
    In development we have created multicolumn index and below is the execution plan.....Also in development it takes just 4-5 seconds to execute. But in production it takes more than 8-9 minutes.
    Below is the execution plan from Dev which seems to perform fast:
    Execution Plan
    Plan hash value: 3121857971
    | Id  | Operation                                 | Name                          | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT                          |                               |     1 |    57 |   353   (1)| 00:00:05 |       |       |
    |*  1 |  COUNT STOPKEY                            |                               |       |       |            |          |       |       |
    |   2 |   VIEW                                    |                               |     1 |    57 |   353   (1)| 00:00:05 |       |       |
    |*  3 |    SORT ORDER BY STOPKEY                  |                               |     1 |    58 |   353   (1)| 00:00:05 |       |       |
    |   4 |     HASH UNIQUE                           |                               |     1 |    58 |   352   (1)| 00:00:05 |       |       |
    |   5 |      CONCATENATION                        |                               |       |       |            |          |       |       |
    |*  6 |       TABLE ACCESS BY INDEX ROWID         | ORG_RELATIONSHIPS             |     1 |    26 |     3   (0)| 00:00:01 |       |       |
    |   7 |        NESTED LOOPS                       |                               |     1 |    58 |   170   (1)| 00:00:03 |       |       |
    |   8 |         PARTITION RANGE ALL               |                               |    56 |  1792 |    16   (0)| 00:00:01 |     1 |     3 |
    |*  9 |          TABLE ACCESS BY LOCAL INDEX ROWID| ENTITYIDS                     |    56 |  1792 |    16   (0)| 00:00:01 |     1 |     3 |
    |* 10 |           INDEX RANGE SCAN                | IDX_ENTITYIDS_ETYPE_DC        |    56 |       |     7   (0)| 00:00:01 |     1 |     3 |
    |* 11 |         INDEX RANGE SCAN                  | EFX_ORGID                     |     2 |       |     2   (0)| 00:00:01 |       |       |
    |* 12 |       TABLE ACCESS BY INDEX ROWID         | ORG_RELATIONSHIPS             |     1 |    26 |     3   (0)| 00:00:01 |       |       |
    |  13 |        NESTED LOOPS                       |                               |     1 |    58 |   181   (0)| 00:00:03 |       |       |
    |  14 |         PARTITION RANGE ALL               |                               |    57 |  1824 |    10   (0)| 00:00:01 |     1 |     3 |
    |* 15 |          INDEX RANGE SCAN                 | UX_TYPE_MOD_DIST_DEL_ENTITYID |    57 |  1824 |    10   (0)| 00:00:01 |     1 |     3 |
    |* 16 |         INDEX RANGE SCAN                  | EFX_ORGID                     |     2 |       |     2   (0)| 00:00:01 |       |       |
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM<=10)
       3 - filter(ROWNUM<=10)
       6 - filter("RELATED_ORGID" IS NOT NULL AND ("DATE_CREATED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "DATE_CREATED"<TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss') OR "DATE_MODIFIED">=TO_DATE(' 2011-06-12 14:00:00',
                  'syyyy-mm-dd hh24:mi:ss') AND "DATE_MODIFIED"<TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss')))
       9 - filter("I"."ISDISTRIBUTABLE"=1 AND "I"."ISDELETED"=0 AND "I"."ENTITYID">=0)
      10 - access("I"."ENTITYTYPE"=1 AND "I"."DATECREATED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "I"."DATECREATED"<TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      11 - access("ORGID"="I"."ENTITYID")
           filter("ORGID" IS NOT NULL AND "ORGID">=0)
      12 - filter("RELATED_ORGID" IS NOT NULL AND ("DATE_CREATED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "DATE_CREATED"<TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss') OR "DATE_MODIFIED">=TO_DATE(' 2011-06-12 14:00:00',
                  'syyyy-mm-dd hh24:mi:ss') AND "DATE_MODIFIED"<TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss')))
      15 - access("I"."ENTITYTYPE"=1 AND "I"."DATEMODIFIED">=TO_DATE(' 2011-06-12 14:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "I"."ISDISTRIBUTABLE"=1 AND "I"."ISDELETED"=0 AND "I"."ENTITYID">=0 AND "I"."DATEMODIFIED"<TO_DATE(' 2011-06-13 14:00:00',
                  'syyyy-mm-dd hh24:mi:ss'))
           filter("I"."ISDISTRIBUTABLE"=1 AND "I"."ISDELETED"=0 AND (LNNVL("I"."DATECREATED">=TO_DATE(' 2011-06-12 14:00:00',
                  'syyyy-mm-dd hh24:mi:ss')) OR LNNVL("I"."DATECREATED"<TO_DATE(' 2011-06-13 14:00:00', 'syyyy-mm-dd hh24:mi:ss'))) AND
                  "I"."ENTITYID">=0)
      16 - access("ORGID"="I"."ENTITYID")
           filter("ORGID" IS NOT NULL AND "ORGID">=0)Thanks

  • How to retreive soap xml data from clob column in a table

    Hi,
    I am trying to retrieve the XML tag value from clob column.
    Table name = xyz and column= abc (clob datatype)
    data stored in abc column is as below
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:head="http://www.abc.com/gcgi/shared/system/header" xmlns:v6="http://www.abc.com/gcgi/services/v6_0_0_0" xmlns:sys="http://www.abc.com/gcgi/shared/system/systemtypes">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <RqHeader soapenv:mustUnderstand="0" xmlns="http://www.abc.com/gcgi/shared/system/header">
    <DateAndTimeStamp>2011-12-20T16:02:36.677+08:00</DateAndTimeStamp>
    <UUID>1000002932</UUID>
    <Version>6_0_0_0</Version>
    <ClientDetails>
    <Org>ABC</Org>
    <OrgUnit>ABC</OrgUnit>
    <ChannelID>HBK</ChannelID>
    <TerminalID>0000</TerminalID>
    <SrcCountryCode>SG</SrcCountryCode>
    <DestCountryCode>SG</DestCountryCode>
    <UserGroup>HBK</UserGroup>
    </ClientDetails>
    </RqHeader>
    <wsa:Action>/SvcImpl/bank/
    SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq</wsa:Action></soapenv:Header>
    <soapenv:Body>
    <v6:AlertDeleteInqRq>
    <v6:Base>
    <v6:VID>20071209013112</v6:VID>
    <!--Optional:-->
    <v6:Ref>CTAA00000002644</v6:Ref>
    </v6:Base>
    </v6:AlertDeleteInqRq>
    </soapenv:Body>
    </soapenv:Envelope>
    And i want to retrieve the values of tag
    <ChannelID> and <v6:VID>
    can somebody help, i have tried with extractvalue but not able to get the values

    I have used the below two queries but not able to get the expected results. Both queries result into no values.
    select xmltype(MED_REQ_PAYLOAD).extract('//ClientDetails/Org','xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" || xmlns="http://www.abc.com/gcgi/shared/system/header"').getStringValue() from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/alerts/v6_0_0_0/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
    select EXTRACTVALUE(xmltype(MED_REQ_PAYLOAD),'/RqHeader/) from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
    Well, for starters, both queries are syntactically wrong :
    - non terminated string
    - incorrect namespace mapping declaration
    - unknown XMLType method "getStringValue()"
    Secondly, all those functions are deprecated now.
    Here's an up-to-date example using XMLTable. It will retrieve the two tag values you mentioned :
    SQL> select x.*
      2  from esb_output_temp t
      3     , xmltable(
      4         xmlnamespaces(
      5           'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
      6         , 'http://www.abc.com/gcgi/shared/system/header' as "head"
      7         , 'http://www.abc.com/gcgi/services/v6_0_0_0' as "v6"
      8         )
      9       , '/soap:Envelope'
    10         passing xmlparse(document t.med_req_payload)
    11         columns ChannelID  varchar2(10) path 'soap:Header/head:RqHeader/head:ClientDetails/head:ChannelID'
    12               , VID        varchar2(30) path 'soap:Body/v6:AlertDeleteInqRq/v6:Base/v6:VID'
    13       ) x
    14  ;
    CHANNELID  VID
    HBK        20071209013112
    You may also want to store XML in XMLType columns for both performance and storage optimizations.

  • Combining clob taking too much time - need help

    Hello,
    I want to append clob values into another clob value like
    declare
    v_temp clob;
    v_c1_temp clob;
    cursor c1 as select clob_data from t;
    -- here t table contains clob_data column holding clob data
    -- t table have more then 1500 rows
    begin
    v_temp := '';
    open c1 into v_c1_temp;
    loop
    v_temp := v_temp + v_c1_temp; --------- combining clob (concat may be used)
    end loop;
    close(c1);
    end;
    above part also repeats in outer loop (not shown here)
    my problem is :- it is taking too much time - you dont believe 90% more time due to that concatenation.
    is it any smart way to do same thing?
    It will be very helpful to me.

    Hi ,
    You should also always try and have the latest BI content patch installed but I don't think this is the problem. It seems that there
    are alot of objects to collect. Under 'grouping' you can select the option 'only necessary objects', please check if you can
    use this option to  install the objects that you need from content.
    Best Regards,
    Des.

  • How to use PLSQL CLOB IN WORKFLOW

    Dear all,
    I have follwoing query with workflow.
    I have developed FYI WF.
    1) In my WF mail, I am getting click here to respond.
    I want to hide this.
    Pl. let me know how to do that?
    2) I have developed a workflow with Document type.
    I am calling a PL/SQL CLOB procedure to pass my values( 4 columns from a table)
    I need to pass approximately 70 to 100 rows to clob.
    when I pass 14 rows, I am not getting any error.
    where as if I pass morethen 15 rows, I am getting follwoing error
    "ORA-06502: PL/SQL: numeric or value error ORA-06512: at "APPS.WF_NOTIFICATION", line 5046 ORA-06512: at line 5 "
    Pl. let me know, do I need to setup any thing in workflow from my side

    Hi,
    I'm not sure whether it is because of the length of variable.
    However, did you use concatenation (||) to store the value in the varchar variable before putting it into the CLOB variable?
    If so, perhaps you forget to reset the varchar variable inside the loop, thus making it longer and longer each loop.
    You should empty the varchar variable by
    loop
      l_string := '';
      -- your code, perhaps concat the variable
      l_string := l_string || 'blah blah';
    end loop;For the FYI Notification, perhaps you should check the Notfication in the Workflow Builder, whether it has an Attribute with Respond type on the Notification.
    If you didn't put anything (only the message body) in the Notification, the message will suppose to be a FYI one.
    Regards,
    Buntoro

  • Optimize a select query

    Hi,
    Following query is taking about 30-40 mins to fetch the data in a procedure.I tried using the hints and ran the explain plan but the cost is still the same (151,894) . Can anyone please help me in tuning the query.
    SELECT SYSDATE c_creation_date, glcc.code_combination_id c_ccid,
    glcc.segment1 c_funding, glcc.segment2 c_resp_ctr,
    glcc.segment3 c_account, glcc.segment4 c_pgm_phase,
    glcc.segment5 c_project_cd, null c_vendor_id,
    null c_vendor_num, null c_vendor_name,
    null c_site_code,
    null c_vendor_type,
    null c_project_id, null c_project,
    null c_project_name,
    null c_organization_id,
    null c_organization, null c_expenditure_type_id,
    null c_expenditure_type,
    null c_task_id, null c_task,
    null c_task_name, null c_award_id,
    null c_award, null c_award_name,
    jel.je_header_id c_document_batch_id,
    jeh.name c_document_batch_name,
    -- jel.reference_2 c_document_id, --- Note: reference_2 invoice_id,po_header_id,req_header_id
    case
    when je_source = 'Purchasing'
    then jel.reference_2
    when je_source = 'Payables'
    then jel.reference_2
    else null
    end c_document_id,
    case
    when je_source = 'Purchasing'
    then 'GLJE-'||je_source||' '||jel.reference_1
    else 'GLJE-'||je_source
    end c_document_type,
    case
    when je_source = 'Payables'
    then jel.reference_5
    when je_source = 'Purchasing'
    then reference_4
    else
    reference_4
    end c_document_number,
    NULL c_document_release_id, NULL c_document_release,
    NULL c_document_line_id,
    null c_document_line_num,
    case
    when je_source = 'Purchasing'
    then jel.reference_3
    else null
    end c_document_dist_id,
    case
    when je_source = 'Payables'
    then jel.reference_3
    else null
    end c_document_dist_num,
    0 c_distr_amount,
    (nvl(accounted_dr,0) - nvl(accounted_cr,0)) c_encumbered_amount,
    0,0,0,0,0,0,NULL,jel.je_line_num c_je_line_num
    FROM gl_je_lines jel,
    gl_je_headers jeh,
    gl_encumbrance_types jee ,
    gl_code_combinations glcc
    WHERE jel.je_header_id = jeh.je_header_id
    AND jel.CODE_COMBINATION_ID = glcc.CODE_COMBINATION_ID
    AND jee.encumbrance_type_id = jeh.encumbrance_type_id
    AND actual_flag = 'E'
    and glcc.segment1
    || '-'
    || glcc.segment2
    || '-'
    || glcc.segment3
    || '-'
    || glcc.segment4
    || '-'
    || glcc.segment5
    || '-'
    || glcc.segment6
    || '-'
    || glcc.segment7 between nvl(:p_min_flex, :l_min_flex) and nvl(:p_max_flex,: l_max_flex )
    and encumbrance_type = nvl(:l_enc_type,encumbrance_type)
    and jel.EFFECTIVE_DATE between nvl(:p_encumbrance_date_from,:l_date_low)
    and nvl(:p_encumbrance_date_to,:l_date_high)
    and decode(je_source,'Purchasing',jel.reference_4,'Payables',jel.reference_5)
    =nvl(:l_doc_number,decode(je_source,'Purchasing',jel.reference_4,'Payables',jel.reference_5))
    and je_source != 'Payables';
    I will appreciate the help!
    Regards,
    Darshini

    Hi,
    Thanks Sundar and Miguel for the article, it is very helpful.
    I was able to get the output from explain plan as well as sql_trace.But I could not understand how to compare the files and optimize the query. follwing are the outputs
    select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 2 | 336 | 151K|
    | 1 | CONCATENATION | | | | |
    | 2 | FILTER | | | | |
    | 3 | NESTED LOOPS | | 1 | 168 | 54873 |
    | 4 | NESTED LOOPS | | 1 | 155 | 54872 |
    | 5 | NESTED LOOPS | | 1633 | 180K| 53237 |
    | 6 | TABLE ACCESS FULL | GL_CODE_COMBINATIONS | 1387 | 77672 | 3713 |
    | 7 | TABLE ACCESS BY INDEX ROWID| GL_JE_LINES | 1 | 57 | 66 |
    | 8 | INDEX RANGE SCAN | GL_JE_LINES_N1 | 135 | | 3 |
    | 9 | TABLE ACCESS BY INDEX ROWID | GL_JE_HEADERS | 1 | 42 | 1 |
    | 10 | INDEX UNIQUE SCAN | GL_JE_HEADERS_U1 | 1 | | 0 |
    | 11 | TABLE ACCESS BY INDEX ROWID | GL_ENCUMBRANCE_TYPES | 1 | 13 | 1 |
    | 12 | INDEX UNIQUE SCAN | GL_ENCUMBRANCE_TYPES_U1 | 1 | | 0 |
    | 13 | FILTER | | | | |
    | 14 | NESTED LOOPS | | 1 | 168 | 97021 |
    | 15 | NESTED LOOPS | | 1633 | 200K| 95386 |
    | 16 | NESTED LOOPS | | 1387 | 95703 | 3714 |
    PLAN_TABLE_OUTPUT
    | 17 | TABLE ACCESS BY INDEX ROWID| GL_ENCUMBRANCE_TYPES | 1 | 13 | 1 |
    | 18 | INDEX UNIQUE SCAN | GL_ENCUMBRANCE_TYPES_U2 | 1 | | 0 |
    | 19 | TABLE ACCESS FULL | GL_CODE_COMBINATIONS | 1387 | 77672 | 3713 |
    | 20 | TABLE ACCESS BY INDEX ROWID | GL_JE_LINES | 1 | 57 | 66 |
    | 21 | INDEX RANGE SCAN | GL_JE_LINES_N1 | 135 | | 3 |
    | 22 | TABLE ACCESS BY INDEX ROWID | GL_JE_HEADERS | 1 | 42 | 1 |
    | 23 | INDEX UNIQUE SCAN | GL_JE_HEADERS_U1 | 1 | | 0 |
    sql_trace
    PARSING IN CURSOR #2 len=3812 dep=0 uid=173 oct=3 lid=173 tim=3338840240188 hv=2038351921 ad='aaf94e98'
    SELECT SYSDATE c_creation_date, glcc.code_combination_id c_ccid ,
    glcc.segment1 c_funding, glcc.segment2 c_resp_ctr,
    glcc.segment3 c_account, glcc.segment4 c_pgm_phase,
    glcc.segment5 c_project_cd, null c_vendor_id,
    null c_vendor_num, null c_vendor_name,
    null c_site_code,
    null c_vendor_type,
    null c_project_id, null c_project,
    null c_project_name,
    null c_organization_id,
    null c_organization, null c_expenditure_type_id,
    null c_expenditure_type,
    null c_task_id, null c_task,
    null c_task_name, null c_award_id,
    null c_award, null c_award_name,
    jel.je_header_id c_document_batch_id,
    jeh.name c_document_batch_name,
    case
    when je_source = 'Purchasing'
    then jel.reference_2
    when je_source = 'Payables'
    then jel.reference_2
    else null
    end c_document_id,
    case
    when je_source = 'Purchasing'
    then 'GLJE-'||je_source||' '||jel.reference_1
    else 'GLJE-'||je_source
    end c_document_type,
    case
    when je_source = 'Payables'
    then jel.reference_5
    when je_source = 'Purchasing'
    then reference_4
    else
    reference_4
    end c_document_number,
    NULL c_document_release_id, NULL c_document_release,
    NULL c_document_line_id,
    null c_document_line_num,
    case
    when je_source = 'Purchasing'
    then jel.reference_3
    else null
    end c_document_dist_id,
    case
    when je_source = 'Payables'
    then jel.reference_3
    else null
    end c_document_dist_num,
    0 c_distr_amount,
    (nvl(accounted_dr,0) - nvl(accounted_cr,0)) c_encumbered_amount,
    0,0,0,0,0,0,NULL,jel.je_line_num c_je_line_num
    FROM gl_je_lines jel,
    gl_je_headers jeh,
    gl_encumbrance_types jee ,
    gl_code_combinations glcc
    WHERE jel.je_header_id = jeh.je_header_id
    AND jel.CODE_COMBINATION_ID = glcc.CODE_COMBINATION_ID
    AND jee.encumbrance_type_id = jeh.encumbrance_type_id
    AND actual_flag = 'E'
    and glcc.segment1
    || '-'
    || glcc.segment2
    || '-'
    || glcc.segment3
    || '-'
    || glcc.segment4
    || '-'
    || glcc.segment5
    || '-'
    || glcc.segment6
    || '-'
    || glcc.segment7 between nvl(null,'F017-M029300-1980200200-CF2004-000000-00000-00000')
    and nvl(null,'F017-M029300-1980200200-CF2004-000000-00000-00000' )
    and encumbrance_type = nvl('Obligation',encumbrance_type)
    and jel.EFFECTIVE_DATE between nvl(null,'01-JAN-1900')
    and nvl(null,'31-DEC-4712')
    and decode(je_source,'Purchasing',jel.reference_4,'Payables',jel.reference_5)
    =nvl('5013794',decode(je_source,'Purchasing',jel.reference_4,'Payables',jel.reference_5))
    and je_source != 'Payables'
    END OF STMT
    PARSE #2:c=50000,e=42317,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=3338840240172
    EXEC #2:c=0,e=621,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=3338840243240
    FETCH #2:c=5910000,e=5837875,p=13246,cr=19198,cu=0,mis=0,r=1,dep=0,og=1,tim=3338846081769
    FETCH #2:c=0,e=1166,p=0,cr=8,cu=0,mis=0,r=15,dep=0,og=1,tim=3338846086521
    *** 2008-08-06 12:24:18.016
    FETCH #2:c=10000,e=2155,p=0,cr=21,cu=0,mis=0,r=15,dep=0,og=1,tim=3338854116887
    FETCH #2:c=0,e=1812,p=0,cr=14,cu=0,mis=0,r=15,dep=0,og=1,tim=3338860800729
    *** 2008-08-06 12:24:31.298
    FETCH #2:c=10000,e=1729,p=0,cr=10,cu=0,mis=0,r=15,dep=0,og=1,tim=3338867087393
    FETCH #2:c=0,e=1810,p=0,cr=14,cu=0,mis=0,r=15,dep=0,og=1,tim=3338872996057
    *** 2008-08-06 12:24:43.317
    FETCH #2:c=0,e=1728,p=0,cr=9,cu=0,mis=0,r=15,dep=0,og=1,tim=3338878825390
    FETCH #2:c=0,e=2058,p=0,cr=12,cu=0,mis=0,r=15,dep=0,og=1,tim=3338884698870
    *** 2008-08-06 12:24:57.286
    FETCH #2:c=0,e=2095,p=0,cr=10,cu=0,mis=0,r=10,dep=0,og=1,tim=3338892467618
    STAT #2 id=1 cnt=116 pid=0 pos=1 obj=0 op='HASH JOIN (cr=19296 pr=13246 pw=0 time=5837597 us)'
    STAT #2 id=2 cnt=5464 pid=1 pos=1 obj=33979 op='TABLE ACCESS FULL GL_JE_HEADERS (cr=6120 pr=183 pw=0 time=796948 us)'
    STAT #2 id=3 cnt=174 pid=1 pos=2 obj=34028 op='TABLE ACCESS BY INDEX ROWID GL_JE_LINES (cr=13176 pr=13063 pw=0 time=5576761 us)'
    STAT #2 id=4 cnt=176 pid=3 pos=1 obj=0 op='NESTED LOOPS (cr=13088 pr=13063 pw=0 time=487814114 us)'
    STAT #2 id=5 cnt=1 pid=4 pos=1 obj=0 op='MERGE JOIN CARTESIAN (cr=13076 pr=13063 pw=0 time=5575083 us)'
    STAT #2 id=6 cnt=1 pid=5 pos=1 obj=34354 op='TABLE ACCESS FULL GL_ENCUMBRANCE_TYPES (cr=6 pr=0 pw=0 time=453 us)'
    STAT #2 id=7 cnt=1 pid=5 pos=2 obj=0 op='BUFFER SORT (cr=13070 pr=13063 pw=0 time=5574591 us)'
    STAT #2 id=8 cnt=1 pid=7 pos=1 obj=33834 op='TABLE ACCESS FULL GL_CODE_COMBINATIONS (cr=13070 pr=13063 pw=0 time=5573921 us)'
    STAT #2 id=9 cnt=174 pid=4 pos=2 obj=34055 op='INDEX RANGE SCAN GL_JE_LINES_N1 (cr=12 pr=0 pw=0 time=349 us)'
    =====================
    I will greatly appreciate if any one can help me further.
    Thanks,
    Darshini

  • Performance Impact with OR concatenation / Inlist Iterator

    Hello guys,
    is there any performance impact with using OR concatenations or some IN-Lists?
    The function of both is the "same":
    1) Concatenation (OR-processing)
    SELECT * FROM emp WHERE mgr# = 1 OR job = ‘YOURS’;- Similar to query rewrite into 2 seperate queries
    - Which are then ‘concatenated’
    2) Inlist Iterator
    SELECT * FROM dept WHERE d# in (10,20,30);- Iteration over enumerated value-list
    - Every value executed seperately
    - Same as concatenation of 3 “OR-red” values
    So i want to know if there is any performance impact if using IN-Lists instead of OR concatenations.
    Thanks and Regards
    Stefan

    The note is very misleading and far from complete; but there is one critical point of difference that you need to observe. It's talking about using a tablescan to deal with an IN-list (and that's NOT "in-list iteration"), my comments start by saying "if there is a suitable indexed access path."
    The note, by the way, describes a transformation to a UNION ALL - clearly that would be inefficient if there were no indexed access path. (Given the choice between one tablescan and several consecutive tablescans, which option would you choose ?).
    The note, in effect, is just about a slightly more subtle version of "why isn't oracle using my index". For "shorter" lists you might get an indexed iteration, for "longer" lists you might get a tablescan.
    Remember, Metalink is not perfect; most of it is just written by ordinary people who learned about Oracle in the normal fashion.
    Quick example to demonstrate the difference between concatenation and iteration:
    drop table t1;
    create table t1 as
    select
         rownum     id,
         rownum     n1,
         rpad('x',100)     padding
    from
         all_objects
    where
         rownum <= 10000
    create index t1_i1 on t1(id);
    execute dbms_stats.gather_table_stats(user,'t1')
    set autotrace traceonly explain
    select
         /*+ use_concat(t1) */
         n1
    from
         t1
    where
         id in (10,20,30,40,50,60,70,80,90,100)
    set autotrace offThe execution plan I got from 8.1.7.4 was as follows - showing the transformation to a UNION ALL - this is concatenation and required 10 query block optimisations (which were all done three times):
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=20 Card=10 Bytes=80)
       1    0   CONCATENATION
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
       3    2       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
       4    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
       5    4       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
       6    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
       7    6       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
       8    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
       9    8       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
      10    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
      11   10       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
      12    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
      13   12       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
      14    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
      15   14       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
      16    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
      17   16       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
      18    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
      19   18       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)
      20    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=2 Card=1 Bytes=8)
      21   20       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=1 Card=1)This is the execution plan I got from 9.2.0.8, which doesn't transform to the UNION ALL, and only needs to optimise one query block.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=3 Card=10 Bytes=80)
       1    0   INLIST ITERATOR
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=3 Card=10 Bytes=80)
       3    2       INDEX (RANGE SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=2 Card=10)Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • Simple string optimization question

    ABAPpers,
    Here is the problem description:
    In a SELECT query loop, I need to build a string by concatenating all the column values for the current row. Each column is represented as a length-value pair. For example, let's say the current values are:
    Column1 (type string)  : 'abc          '
    Column2 (type integer) : 7792
    Column3 (type string)  : 'def                    '
    The resulting string must be of the form:
    0003abc000477920003def...
    The length is always represented by a four character value, followed by the actual value.
    Note that the input columns may be of mixed types - numeric, string, date-time, etc.
    Given that data is of mixed type and that the length of each string-type value is not known in advance, can someone suggest a good algorithm to build such a result? Or, is there any built-in function that already does something similar?
    Thank you in advance for your help.
    Pradeep

    Hi,
    At the bottom of this message, I have posted a program that I currently wrote. Essentially, as I know the size of each "string" type column, I use a specific function to built the string. For any non-string type column, I assume that the length can never exceed 25 characters. As I fill 255 characters in the output buffer, I have to write the output buffer to screen.
    The reason I have so many functions for each string type is that I wanted to optimize concatenate operation. Had I used just one function with the large buffer, then "concatenate" statement takes additional time to fill the remaining part of the buffer with spaces.
    As my experience in ABAP programming is limited to just a couple of days, I'd appreciate it if someone can suggest me a better way to deal with my problem.
    Thank you in advanced for all your help. Sorry about posting such a large piece of code. I just wanted to show you the complexity that I have created for myself :-(.
    Pradeep
    REPORT ZMYREPORTTEST no standard page heading line-size 255.
    TABLES: GLPCA.
    data: GLPCAGL_SIRID like GLPCA-GL_SIRID.
    data: GLPCARLDNR like GLPCA-RLDNR.
    data: GLPCARRCTY like GLPCA-RRCTY.
    data: GLPCARVERS like GLPCA-RVERS.
    data: GLPCARYEAR like GLPCA-RYEAR.
    data: GLPCAPOPER like GLPCA-POPER.
    data: GLPCARBUKRS like GLPCA-RBUKRS.
    data: GLPCARPRCTR like GLPCA-RPRCTR.
    data: GLPCAKOKRS like GLPCA-KOKRS.
    data: GLPCARACCT like GLPCA-RACCT.
    data: GLPCAKSL like GLPCA-KSL.
    data: GLPCACPUDT like GLPCA-CPUDT.
    data: GLPCACPUTM like GLPCA-CPUTM.
    data: GLPCAUSNAM like GLPCA-USNAM.
    data: GLPCABUDAT like GLPCA-BUDAT.
    data: GLPCAREFDOCNR like GLPCA-REFDOCNR.
    data: GLPCAAWORG like GLPCA-AWORG.
    data: GLPCAKOSTL like GLPCA-KOSTL.
    data: GLPCAMATNR like GLPCA-MATNR.
    data: GLPCALIFNR like GLPCA-LIFNR.
    data: GLPCASGTXT like GLPCA-SGTXT.
    data: GLPCAAUFNR like GLPCA-AUFNR.
    data: data(255).
    data: currentPos type i.
    data: lineLen type i value 255.
    data len(4).
    data startIndex type i.
    data charsToBeWritten type i.
    data remainingRow type i.
    SELECT GL_SIRID
    RLDNR
    RRCTY
    RVERS
    RYEAR
    POPER
    RBUKRS
    RPRCTR
    KOKRS
    RACCT
    KSL
    CPUDT
    CPUTM
    USNAM
    BUDAT
    REFDOCNR
    AWORG
    KOSTL
    MATNR
    LIFNR
    SGTXT
    AUFNR into (GLPCAGL_SIRID,
    GLPCARLDNR,
    GLPCARRCTY,
    GLPCARVERS,
    GLPCARYEAR,
    GLPCAPOPER,
    GLPCARBUKRS,
    GLPCARPRCTR,
    GLPCAKOKRS,
    GLPCARACCT,
    GLPCAKSL,
    GLPCACPUDT,
    GLPCACPUTM,
    GLPCAUSNAM,
    GLPCABUDAT,
    GLPCAREFDOCNR,
    GLPCAAWORG,
    GLPCAKOSTL,
    GLPCAMATNR,
    GLPCALIFNR,
    GLPCASGTXT,
    GLPCAAUFNR) FROM GLPCA
    perform BuildFullColumnString18 using GLPCAGL_SIRID.
    perform BuildFullColumnString2 using GLPCARLDNR.
    perform BuildFullColumnString1 using GLPCARRCTY.
    perform BuildFullColumnString3 using GLPCARVERS.
    perform BuildFullColumnString4 using GLPCARYEAR.
    perform BuildFullColumnString3 using GLPCAPOPER.
    perform BuildFullColumnString4 using GLPCARBUKRS.
    perform BuildFullColumnString10 using GLPCARPRCTR.
    perform BuildFullColumnString4 using GLPCAKOKRS.
    perform BuildFullColumnString10 using GLPCARACCT.
    perform BuildFullColumnNonString using GLPCAKSL.
    perform BuildFullColumnNonString using GLPCACPUDT.
    perform BuildFullColumnNonString using GLPCACPUTM.
    perform BuildFullColumnString12 using GLPCAUSNAM.
    perform BuildFullColumnNonString using GLPCABUDAT.
    perform BuildFullColumnString10 using GLPCAREFDOCNR.
    perform BuildFullColumnString10 using GLPCAAWORG.
    perform BuildFullColumnString10 using GLPCAKOSTL.
    perform BuildFullColumnString18 using GLPCAMATNR.
    perform BuildFullColumnString10 using GLPCALIFNR.
    perform BuildFullColumnString50 using GLPCASGTXT.
    perform BuildFullColumnString12 using GLPCAAUFNR.
    ENDSELECT.
    if currentPos > 0.
      move '' to datacurrentPos.
      write: / data.
    else.
      write: / '+'.
    endif.
    data fullColumn25(29).
    data fullColumn1(5).
    Form BuildFullColumnString1 using value(currentCol). 
      len = STRLEN( currentCol ).
      concatenate len currentCol into fullColumn1.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn1 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn1+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn1+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn1+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.
    data fullColumn2(6).
    Form BuildFullColumnString2 using value(currentCol). 
      len = STRLEN( currentCol ).
      concatenate len currentCol into fullColumn2.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn2 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn2+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn2+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn2+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.
    data fullColumn3(7).
    Form BuildFullColumnString3 using value(currentCol). 
    EndForm.
    data fullColumn4(8).
    Form BuildFullColumnString4 using value(currentCol). 
    EndForm.
    data fullColumn50(54).
    Form BuildFullColumnString50 using value(currentCol). 
    EndForm.
    Form BuildFullColumnNonString using value(currentCol). 
      move currentCol to fullColumn25.
      condense fullColumn25.     
      len = STRLEN( fullColumn25 ).
      concatenate len fullColumn25 into fullColumn25.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn25 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn25+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn25+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn25+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.

Maybe you are looking for