Need to group by using a Table WITH

Hello

I use a database of XE 11.g.  I have the following query, and it works.  It generates the XML code for an email I send.  I need to make a change.  I think I need a group so I can can insert empty lines when the use_date_time field has changed in the output.

I put comment where I think that the Group By clause must go.  When I try a comment this line and run the query, I get an ORA-00979: not a GROUP BY expression error.

Thanks for looking at this.

DECLARE

l_html_header varchar2 (1024);

CLOB l_html_body;

l_html_footer varchar2 (1024);

CLOB l_html_total;

BEGIN

l_html_body: = ' < div >

< table >

< b >

< tr / >

< th Width = "180" Align = "left" > mass Date time < /th >

< th Width = "100" Align = "left" > anthem Type < /th >

< th Width = "275" Align = "left" > name < /th > anthem

< th Width = "200" Align = "left" > definition < /th >

< th Width = "200" Align = "left" > < /th > interpreter

< /tr > ';

I'm in)

With html_table as)

Select hm.use_date_time

hm.use_type

hm.hymn_full_name

hm.gather_number

hm.setting

hm.performer

hm.use_type_key

Of HYMN_MAILING hm

order of use_date_time)

Select

use_date_time

use_type

hymn_full_name

gather_number

setting

interpreter

use_type_key

Html_table t

-Group By t.use_date_time

Order of t.use_date_time, t.use_type_key

) Loop

l_html_body: = l_html_body | "< tr >";

l_html_body: = l_html_body | "< td >" | TO_CHAR (i.use_date_time, ' MM/DD/YYYY HH: mi AM' ') | '< table > ";

l_html_body: = l_html_body | "< td >" | i.use_type | "< table >";

l_html_body: = l_html_body | "< td >" | i.hymn_full_name | "< table >";

l_html_body: = l_html_body | "< td >" | i.Setting | "< table >";

l_html_body: = l_html_body | "< td >" | i.performer | "< table >";

l_html_body: = l_html_body | "< /tr >";

end loop;

l_html_body: = l_html_body | '< /table > ';

l_html_header: = ' <! DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 / / IN" ""http://www.w3.org/TR/html4/strict.dtd"> ".

< html > < head > < title > anthem reminder < / title > < / head > < body > ';

l_html_footer: = ' < / div > < body / > < / html > ';

l_html_total: = l_html_header | l_html_body | l_html_footer;

dbms_output.put_line (l_html_total);

-html_email (p_to = > ' [email protected]', )

--          p_from          => ' [email protected] ',

-p_subject = > 'Message of Test using subject and UTL_SMTP.

-p_text = > "This is a test message."

-p_html = > l_html_total,

-p_smtp_hostname = > "mail.site.org"

-p_smtp_portnum = > 587);

END;

/

Hello

I don't know what you want, either.

In pure SQL, you can use the GROUP BY ROLLUP to produce an additional line (called a Super row aggregate) at the end of each group.

However, given that you are using PL/SQL and stopping after each line, it is simpler test a change of value at that time here.  (As a general rule, you want the back-end to retrieve data and nothing else.  How do you present this data is best done by front end.)

For example, that you want to add a couple of
items between different values of use_date_time:

DECLARE

prev_use_date_time html_table.use_date_time%TYPE;

l_html_header varchar2 (1024);

...

hm.hymn_full_name

-Joke the anthem:

-(Q) what was the name of Ralph Vaughn Williams's dog?

-(A) AMPNEY

...

) Loop

IF prev_use_date_time <> i.use_date_time

THEN

l_html_body: = l_html_body | '

';

END IF;

prev_use_date_time: = i.use_date_time;

l_html_body: = l_html_body | '';

...

The rest of your code can remain unchanged.

Tags: Database

Similar Questions

  • I need to export videos using adobe premiere with these video resolution: DV 25 420, MXF. I have tried many of the export preset, but the MXFop1a give a video exorted with codec 411 instead of 420

    I need to export videos using adobe premiere with these video resolution: DV 25 420, MXF. I have tried many of the export preset, but the MXFop1a give a video exorted with codec 411 instead of 420

    It doesn't seem to be any adjustment for this user.

  • I have a power shot sx HS 40 &amp; need information about the use of filters with this camera? Thank you ~.

    I have a power shot sx 40 & would like information on the use of filters with this device?

    Thank you ~.

    Hi Rainlily,

    You will need the # model Canon adapter filter f-DC67A to use filters on this camera, which costs about $25.00. Bower makes one for about $9.00 available in B & H and Bower products work well with the Canon. This adapter uses 67 mm filters. If you have not yet all filters, I would recommend Hoya or Tiffen filters as they are of high quality at reasonable prices. Do not get the expensive filters because in general they can cause color casts that may be difficult to view the process on. Have fun!

    Steve M.

  • The use of tables with void / vi

    Hello!

    I have a question about the correct method for the use of a Subvi to update an array of integers. How to pass the array to the Subvi, without creating a second table to the output (or what is returned)?

    It is for the calculation of the histogram data. Basically, I have a set of input values are evaluated to determine which bin location (array index) to increment the counter on. I then want to use the same Subvi to update table (let's call it "BinsIn", for the sake of discussion) and return to the main VI. Think in terms of textual programming I want to pass the array of reference, so I'm not wasting resources.

    I read a few posts that deal with using Ctl Refnum, but I don't know if that's what I want to do...

    Any help would be appreciated.

    Thank you

    Shaun

    Don't think in textual languages.  There is no difference in passing by reference and by value.  If the compiler determines that the input array can be reused as the output array, and then she'll do.  You can give him some advice that he should do by writing your code to perform operations "on the spot" (search for this term on this forum) and avoiding the functions requiring a copy the table as delete table.  Best thing to do is probably to write your code to make it work, then download it here so that other contributors can comment and help to make it more effective.

  • Insert using the table with the clause and select?

    Hello gurus,

    Can I insert in a table by making use of clause and select?

    something similar to this...
         insert into test_table
          (with abc as 
              (select * from emp_tble
               where dept_no = 10
               )
             select * from abc;
       );          
    
         if not i would i do by making use of  with clause & select ... any example would be great !!
    
    
      
    Thank you very much!!!

    Brackets are disturbing only:

    SQL> insert into test_table
       (with t as (select * from emp) select * from t)
    /
    Error at line 12
    ORA-32034: unsupported use of WITH clause
    
    SQL> insert into test_table
      with t as (select * from emp) select * from t
    /
    14 rows created.
    
  • Update statement using unique table with null values

    Hi all

    I want to update the table example table contain columns of c1.c2, c3 as below data

    tab1: -.
    ------------------------
    C1 c2 c3
    1 2 null
    3 null null
    4 5 null
    6 null null
    -----------------------------------------

    now, I want to update each value null to bellows value c3 c3
    for example, the data as below

    C1 c2 c3
    1 2 3
    4 5 6

    How can using the update statement update it please help me

    Thanks in advance
    Bala

    So you can never be sure of your order by...

    SQL> create table tab1 as
      2  (
      3  select 1 c1, 2 c2,  null c3 from dual union all
      4  select null, null, 3 from dual union all
      5  select 4 ,5, null from dual union all
      6  select null, null ,6 from dual
      7  );
    
    Table created.
    
    SQL>
    SQL> select *
      2    from tab1
      3  /
    
            C1         C2         C3
    ---------- ---------- ----------
             1          2
                                   3
             4          5
                                   6
    
    SQL>
    SQL> merge into tab1 t
      2  using (select rowid rid
      3              , c1
      4              , c2
      5              , c3
      6              , lead (c3) over (order by rowid) ld
      7           from tab1
      8        ) v
      9   on (t.rowid = v.rid)
     10   when matched
     11   then update set c3 = ld
     12   delete where c3 is null
     13  ;
    
    4 rows merged.
    
    SQL>
    SQL>
    SQL> select *
      2    from tab1
      3  ;
    
            C1         C2         C3
    ---------- ---------- ----------
             1          2          3
             4          5          6
    
    SQL> 
    

    @Peter: PTR, het is niet koud. Het zonnetje schijnt ;)
    for everyone: no, it's not cold. The Sun is shining.

  • ADF table with checkbox refresh data binding problem

    Hello.

    I use JDeveloper 11.1.1.3. I need to use the table with checkboxes in each row of the table in my project. I use VO with transitional 'Selected' attribute that has a boolean type.
    Everything works well, wait one thing:
    When you click checbox with valueChangeListener and try to get the selected line in the managedBean you won't get any selected lines. After selecting second maaged bean evil shows that 1 single line is selected. It's my managedBean method:

    public void SelectCountyClick (ValueChangeEvent valueChangeEvent) {}

    DCIteratorBinding it = ADFUtils.findIterator (ITERATOR_NAME);

    int selectedRowCount = 0;
    RowSetIterator laughs = it.getRowSetIterator ();
    Line r = rit.first ();
    If (r! = null) {}
    If ((Boolean) r.getAttribute ("Selected"))
    selectedRowCount ++;
    }

    While (rit.hasNext ()) {}
    r = rit.next ();
    If ((Boolean) r.getAttribute ("Selected"))
    selectedRowCount ++;
    }

    System.out.println ("selected all THE LINES:" + selectedRowCount);


    }

    I tried to change this event to the client event, I got the line number, I put 'true' or 'false' to the code data binding, but whenever I can't correct data after the value change event.

    Please help me.

    The latest idea is updated databing after click of checkbox, I think. Please help me.

    Thank you!

    You must go through the concepts of life cycle of page ADF. In simple terms the Boolean value in the model is not defined in valueChangeListener. Try adding (.processUpdates) valueChangeEvent.getComponent (FacesContext.getCurrentInstance ()); on top of your listener method and see the effect.

    Reference:
    http://docs.Oracle.com/CD/E15051_01/Web.1111/b31974/adf_lifecycle.htm

  • Select tables with a number of corresponding columns

    Hi guys

    I need to find a list of tables with columns in common.

    So basically I need a list of tables and tables that have 3 or more column in common with her, and what are these columns.

    This could take the form of pairs of tables, IE table A table B on columns 1,2,3 games
    Table of an array of matches C on columns 1,3,4

    or it could be games table A table B and C columns 1,2,3 etc.

    I think I do with PL/SQL, what I can do - but I was wondering if this kind of thing is possible with just an SQL statement - if any of you have done it before and you have some SQL, which would be a great help.

    Thank you very much

    Scott

    Well, most of the work is done.
    'Just', you need to add an aggregation function to present the list of corresponding columns.

    In 11.2, it has LISTAGG:

    SELECT a.table_name tab1,
           b.table_name tab2,
           count(*) match_count,
           listagg(a.column_name,',') within group(order by a.column_id) col_list
    FROM user_tab_columns a
         JOIN user_tab_columns b ON a.column_name = b.column_name AND a.table_name != b.table_name
    GROUP BY a.table_name, b.table_name
    HAVING count(*) > 2
    ;
    

    For older versions, other techniques are summarized here:
    http://www.Oracle-base.com/articles/Misc/StringAggregationTechniques.php

  • Difference between an XMLType table and one table with an XMLType column?

    Hi all

    Still trying to get my mind on all that XML stuff.

    Can someone explain briefly the difference between:
    create table this_is_xmltype_tab of xmltype;
    and
    create table this_is_tab_w_xmltpe_col(id number, document xmltype);
    What are the advantages and disadvantages of each solution? How are they really different?

    Thank you

    -Mark

    Sorry Mark, as far as I know it is not a real difference despite the fact that you can use the table with the column (ID), probably more effective for document-focused while driving the query via the ID column and anything else I can think off automatically about XMLType contra XMLType table columns is that (as far as I KNOW) you can not use a column of XMLType to shred the data into it via WebDAV o FTP. But then again I never really tried to do an XMLType column-based. Alternatives, for example, a binary XML column begins with a column of $ sys_nc_oid which is indexed, so in principle you shouldn't need an ID (number) column that has an index (a read also on http://www.liberidu.com/blog/?p=494). If there has been non-null that you could use this index for document oriented applications.

  • How to match tunnel-group with auth ASA 8.2 and IPSec VPN Client using digital certificates with Microsoft CA

    Hello

    I set up a lab for RA VPN with a version of the ASA5510 8.2 and VPN Client 5 software using digital certificates with Microsoft CA on a Windows 2003 server. I did the configuration based on this document from Cisco's Web site:

    http://www.Cisco.com/en/us/partner/products/ps6120/products_configuration_example09186a0080930f21.shtml

    Now, the vpn works fine, but now I need to configure a tunnel-different groups so I can provide different services to different users. The problem I have now is that I don't know how to set it up for the certificate is the name of tunnel-group. If I do an ASA debug crypto isakmp I get this error message:

    % ASA-713906 7: IP = 165.98.139.12, trying to find the group through OR...
    % 3 ASA-713020: IP = 165.98.139.12, no group found by matching well payload ID: unknown
    % ASA-713906 7: IP = 165.98.139.12, trying to find the group via IKE ID...
    % 3 ASA-713020: IP = 165.98.139.12, no group found by matching well payload ID: unknown
    % ASA-713906 7: IP = 165.98.139.12, trying to find the group via IP ADDR...
    % ASA-713906 7: IP = 165.98.139.12, trying to find the group using default group...
    % ASA-713906 7: IP = 165.98.139.12, connection landed on tunnel_group DefaultRAGroup

    So, basically, when using certificates I connect always VPN RA only with the group default DefaultRAGroup. Do I have to use a model of different web registration for application for a certificate instead of the user model? How can I determine the OU on the user certificate so that match tunnel-group?

    Please help me!

    Kind regards

    Fernando Aguirre

    You can use the group certificate mapping feature to map to a specific group.

    This is the configuration for your reference guide:

    http://www.Cisco.com/en/us/partner/docs/security/ASA/asa82/configuration/guide/IKE.html#wp1053978

    And here is the command for "map of crypto ca certificate": reference

    http://www.Cisco.com/en/us/docs/security/ASA/asa80/command/reference/C5.html#wp2186685

    Hope that helps.

  • Fill table with result group discount

    Hello world

    I need a little help.

    I'm working on an Oracle 10.2.0.4 on windows.

    I have a table I created like this:
    Table name: DIM_REPLICA

    COD_SEZ VCHAR2 (2)
    NOME_SEZ VCHAR2 (20)
    FLAG TANK (1)
    DATE OF D_REPLICA

    This DB I have 210 discount groups running every night. I need fill this table with the results of the refresh groups.

    So when the refresh for example called ROME group runs I need to write on the table the name ROME in the field "NOME_SEZ", a Y or N if the refresh Group has worked in the field of the INDICATOR and LAST_DATE refresh force ran into the field of the D_REPLICA. The COD_SEZ field is a code that I get other things. It is not necessary for the moment. I can add it myself on my own.

    Can someone help me please?

    I was looking on the tables SYS DBA_JOBS and DBA_REFRESH these data, but I don't know what to take and how to fill the table. Trigger? Procedure? Any help will be great!

    Thank you all in advance!

    It is not tested, but here's the basic approach. (I'm in 11.1.0.7).

    select r.refgroup nome_sez,
           decode(j.failures,0,'Y','N') flag,
           last_date d_replica
      from dba_refresh r,
           dba_jobs j
     where r.job=j.job;
    

    Personally, I would create this as a view having up-to-date information, rather than maintaining a separate on my own table.

  • Fill a table with the results of the refresh groups

    Hello world

    I need a little help.

    I'm working on an Oracle 10.2.0.4 on windows.

    I have a table I created like this:
    Table name: DIM_REPLICA

    COD_SEZ VCHAR2 (2)
    NOME_SEZ VCHAR2 (20)
    FLAG TANK (1)
    DATE OF D_REPLICA

    This DB I have 210 discount groups running every night. I need fill this table with the results of the refresh groups.

    So when the refresh for example called ROME group runs I need to write on the table the name ROME in the field "NOME_SEZ", a Y or N if the refresh Group has worked in the field of the INDICATOR and LAST_DATE refresh force ran into the field of the D_REPLICA. The COD_SEZ field is a code that I get other things. It is not necessary for the moment. I can add it myself on my own.

    Can someone help me please?

    I was looking on the tables SYS DBA_JOBS and DBA_REFRESH these data, but I don't know what to take and how to fill the table. Trigger? Procedure? Any help will be great!

    Thank you all in advance!

    This forum is for SQL * PLus, questions and your question is about general issues Oracle. You will get a better response by posting your question in another forum - probably the General database instance.

    Please close this thread and start over in another forum.

  • bug using dbms_redefinition on table with the altered text index?

    I think I can found a bug when you use DBMS_REDEFINITION on a table with a text index that has been modified using ALTER INDEX index-name REBUILD PARAMETERS (REPLACE...). It seems that DBMS_REDEFINITION does not recognize the syntax with REPLACE and redefining fails. However, if I remove the text index and re-create it with all the parameters set during the initial creation and no ALTER INDEX command, then redo the redefinition, it works correctly. I have provided below a script that reproduces the problem, then use workaround mentioned. I have provided a copy of the script and executing the script separately, so that it can be copied and pasted to reproduce the problem. It is a simplification of a problem which has emerged over the diagnosis of a larger problem presented by someone on another forum, where the objective was to perform a loop on a group of tables that meet certain criteria and change some columns varchar2, nvarchar2 columns of these tables, where there are indexes in full text on the other columns in the tables and indexes have been changed using the syntax above. This seems to be a bug or am I missing something or is at - it an easier solution for the redefinition?

    -version:
    SCOTT@orcl_11gR2> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    
    5 rows selected.
    
    SCOTT@orcl_11gR2>
    -run the script:
    SCOTT@orcl_11gR2> -- table, data, altered text index:
    SCOTT@orcl_11gR2> CREATE TABLE t_test
      2    (col1  NUMBER PRIMARY KEY,
      3       col2  VARCHAR2 (10),
      4       col3  CLOB)
      5  /
    
    Table created.
    
    SCOTT@orcl_11gR2> INSERT INTO t_test VALUES (1, 'A', 'test data')
      2  /
    
    1 row created.
    
    SCOTT@orcl_11gR2> CREATE INDEX i1 ON t_test (col3) INDEXTYPE IS CTXSYS.CONTEXT
      2  /
    
    Index created.
    
    SCOTT@orcl_11gR2> ALTER INDEX i1 REBUILD PARAMETERS ('REPLACE SYNC (ON COMMIT)')
      2  /
    
    Index altered.
    
    SCOTT@orcl_11gR2> SELECT * FROM t_test WHERE CONTAINS (col3, 'test data') > 0
      2  /
    
          COL1 COL2       COL3
    ---------- ---------- ----------
             1 A          test data
    
    1 row selected.
    
    SCOTT@orcl_11gR2> -- redefinition that fails:
    SCOTT@orcl_11gR2> CREATE TABLE t_test_interim
      2    (col1  NUMBER,
      3       col2  NVARCHAR2 (10),
      4       col3  CLOB)
      5  /
    
    Table created.
    
    SCOTT@orcl_11gR2> DECLARE
      2    v_num_errors  NUMBER;
      3  BEGIN
      4    DBMS_REDEFINITION.CAN_REDEF_TABLE
      5        (USER, 'T_TEST', DBMS_REDEFINITION.CONS_USE_PK);
      6    DBMS_REDEFINITION.START_REDEF_TABLE
      7        (USER, 'T_TEST', 'T_TEST_INTERIM',
      8         'COL1 COL1,TO_NCHAR(COL2) COL2,COL3 COL3',
      9          DBMS_REDEFINITION.CONS_USE_PK);
     10    DBMS_REDEFINITION.SYNC_INTERIM_TABLE
     11        (USER, 'T_TEST', 'T_TEST_INTERIM');
     12    DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS
     13        (USER, 'T_TEST', 'T_TEST_INTERIM',
     14         DBMS_REDEFINITION.CONS_ORIG_PARAMS,
     15         TRUE, TRUE, TRUE, FALSE, v_num_errors, TRUE);
     16    DBMS_REDEFINITION.FINISH_REDEF_TABLE
     17        (USER, 'T_TEST', 'T_TEST_INTERIM');
     18  END;
     19  /
    DECLARE
    *
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-20000: Oracle Text error:
    DRG-11000: invalid keyword REPLACE
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 1364
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 2025
    ORA-06512: at line 12
    
    
    SCOTT@orcl_11gR2> -- clean up the mess:
    SCOTT@orcl_11gR2> DROP MATERIALIZED VIEW t_test_interim
      2  /
    
    Materialized view dropped.
    
    SCOTT@orcl_11gR2> DROP TABLE t_test_interim CASCADE CONSTRAINTS
      2  /
    
    Table dropped.
    
    SCOTT@orcl_11gR2> BEGIN
      2    DBMS_REDEFINITION.ABORT_REDEF_TABLE
      3        (USER, 'T_TEST', 'T_TEST_INTERIM');
      4  END;
      5  /
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> -- drop and recreate index with all parameters without altering:
    SCOTT@orcl_11gR2> DROP INDEX I1
      2  /
    
    Index dropped.
    
    SCOTT@orcl_11gR2> CREATE INDEX I1 ON T_TEST (COL3) INDEXTYPE IS CTXSYS.CONTEXT
      2  PARAMETERS ('SYNC (ON COMMIT)')
      3  /
    
    Index created.
    
    SCOTT@orcl_11gR2> -- redo redefinition:
    SCOTT@orcl_11gR2> CREATE TABLE t_test_interim
      2    (col1  NUMBER,
      3       col2  NVARCHAR2 (10),
      4       col3  CLOB)
      5  /
    
    Table created.
    
    SCOTT@orcl_11gR2> DECLARE
      2    v_num_errors  NUMBER;
      3  BEGIN
      4    DBMS_REDEFINITION.CAN_REDEF_TABLE
      5        (USER, 'T_TEST', DBMS_REDEFINITION.CONS_USE_PK);
      6    DBMS_REDEFINITION.START_REDEF_TABLE
      7        (USER, 'T_TEST', 'T_TEST_INTERIM',
      8         'COL1 COL1,TO_NCHAR(COL2) COL2,COL3 COL3',
      9          DBMS_REDEFINITION.CONS_USE_PK);
     10    DBMS_REDEFINITION.SYNC_INTERIM_TABLE
     11        (USER, 'T_TEST', 'T_TEST_INTERIM');
     12    DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS
     13        (USER, 'T_TEST', 'T_TEST_INTERIM',
     14         DBMS_REDEFINITION.CONS_ORIG_PARAMS,
     15         TRUE, TRUE, TRUE, FALSE, v_num_errors, TRUE);
     16    DBMS_REDEFINITION.FINISH_REDEF_TABLE
     17        (USER, 'T_TEST', 'T_TEST_INTERIM');
     18  END;
     19  /
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> DROP TABLE t_test_interim CASCADE CONSTRAINTS
      2  /
    
    Table dropped.
    
    SCOTT@orcl_11gR2> -- results:
    SCOTT@orcl_11gR2> DESC t_test
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     COL1                                               NUMBER
     COL2                                               NVARCHAR2(10)
     COL3                                               CLOB
    
    SCOTT@orcl_11gR2> COLUMN col3 FORMAT A10
    SCOTT@orcl_11gR2> SELECT * FROM t_test WHERE CONTAINS (col3, 'test data') > 0
      2  /
    
          COL1 COL2       COL3
    ---------- ---------- ----------
             1 A          test data
    
    1 row selected.
    
    SCOTT@orcl_11gR2> -- clean-up:
    SCOTT@orcl_11gR2> DROP TABLE t_test
      2  /
    
    Table dropped.
    
    SCOTT@orcl_11gR2>
    -script:
    -- table, data, altered text index:
    CREATE TABLE t_test
      (col1  NUMBER PRIMARY KEY,
       col2  VARCHAR2 (10),
       col3  CLOB)
    /
    INSERT INTO t_test VALUES (1, 'A', 'test data')
    /
    CREATE INDEX i1 ON t_test (col3) INDEXTYPE IS CTXSYS.CONTEXT
    /
    ALTER INDEX i1 REBUILD PARAMETERS ('REPLACE SYNC (ON COMMIT)')
    /
    SELECT * FROM t_test WHERE CONTAINS (col3, 'test data') > 0
    /
    -- redefinition that fails:
    CREATE TABLE t_test_interim
      (col1  NUMBER,
       col2  NVARCHAR2 (10),
       col3  CLOB)
    /
    DECLARE 
      v_num_errors  NUMBER;
    BEGIN 
      DBMS_REDEFINITION.CAN_REDEF_TABLE
        (USER, 'T_TEST', DBMS_REDEFINITION.CONS_USE_PK);
      DBMS_REDEFINITION.START_REDEF_TABLE
        (USER, 'T_TEST', 'T_TEST_INTERIM',
         'COL1 COL1,TO_NCHAR(COL2) COL2,COL3 COL3',
          DBMS_REDEFINITION.CONS_USE_PK);
      DBMS_REDEFINITION.SYNC_INTERIM_TABLE
        (USER, 'T_TEST', 'T_TEST_INTERIM');
      DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS
        (USER, 'T_TEST', 'T_TEST_INTERIM',
         DBMS_REDEFINITION.CONS_ORIG_PARAMS, 
         TRUE, TRUE, TRUE, FALSE, v_num_errors, TRUE);
      DBMS_REDEFINITION.FINISH_REDEF_TABLE
        (USER, 'T_TEST', 'T_TEST_INTERIM');
    END;
    /
    -- clean up the mess:
    DROP MATERIALIZED VIEW t_test_interim
    /
    DROP TABLE t_test_interim CASCADE CONSTRAINTS
    /
    BEGIN 
      DBMS_REDEFINITION.ABORT_REDEF_TABLE
        (USER, 'T_TEST', 'T_TEST_INTERIM');
    END;
    /
    -- drop and recreate index with all parameters without altering:
    DROP INDEX I1
    /
    CREATE INDEX I1 ON T_TEST (COL3) INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('SYNC (ON COMMIT)')
    /
    -- redo redefinition:
    CREATE TABLE t_test_interim
      (col1  NUMBER,
       col2  NVARCHAR2 (10),
       col3  CLOB)
    /
    DECLARE 
      v_num_errors  NUMBER;
    BEGIN 
      DBMS_REDEFINITION.CAN_REDEF_TABLE
        (USER, 'T_TEST', DBMS_REDEFINITION.CONS_USE_PK);
      DBMS_REDEFINITION.START_REDEF_TABLE
        (USER, 'T_TEST', 'T_TEST_INTERIM',
         'COL1 COL1,TO_NCHAR(COL2) COL2,COL3 COL3',
          DBMS_REDEFINITION.CONS_USE_PK);
      DBMS_REDEFINITION.SYNC_INTERIM_TABLE
        (USER, 'T_TEST', 'T_TEST_INTERIM');
      DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS
        (USER, 'T_TEST', 'T_TEST_INTERIM',
         DBMS_REDEFINITION.CONS_ORIG_PARAMS, 
         TRUE, TRUE, TRUE, FALSE, v_num_errors, TRUE);
      DBMS_REDEFINITION.FINISH_REDEF_TABLE
        (USER, 'T_TEST', 'T_TEST_INTERIM');
    END;
    /
    DROP TABLE t_test_interim CASCADE CONSTRAINTS
    /
    -- results:
    DESC t_test
    COLUMN col3 FORMAT A10
    SELECT * FROM t_test WHERE CONTAINS (col3, 'test data') > 0
    /
    -- clean-up:
    DROP TABLE t_test
    /

    No real workaround DBMS_REDEFINITION uses function DBMS_METADATA. GET_DDL() and a string of invalid parameter is returned due to known bugs when you use the ALTER INDEX REBUILD with parameter REPLACE; try to avoid changing the index with REPLACE if you export or use DBMS_REDEFINITION for this table/index.

    Note to change the text index metadata, to change the existing class preference, you can use the REPLACE METADATA, IE

    ALTER INDEX i1 REBUILD PARAMETERS ("replace metadata sync (on commit)" ");

    Will not rebuild the index so that your DOF is to rebuild the index

    ALTER INDEX i1 REBUILD PARAMETERS ('REPLACE SYNC (ON COMMIT)")

  • Need to dimension aggregated using the summary tables

    Hello

    I have two made tables workdetail and worksummary. Worksummary is grouped in time Sun and workdetail is at the level of day Timedim.

    Now, I set up my business model with Timedim and secondary table work. (creates a hirerchy for time (year-month-day) Sun). Now I want to use the tables of worksummary, how can I include this in my business model. I know to create a new Source of logic and mentioning levels.

    My important question is what do I have to create another physical table for time-months? or can I use same calendar dim physical to use with the summary fact tables?

    the answer to your question is YES, to use aggregated summary tables, we have grouped the dimensions. Other wise data will be redundant and return values incosistent.

    In your case if you use the same table of Timedim-day level with summaries, data tables will be multiplied by 30 days due to the time-Sun monthkey will be repeated in several lines.

    the simplest solution is to create Time_Dim table view, select separate year, month, monthkey. This view returns only unique year-month. Thus, each month will have only one line.
    -> view to import in your physical layer and create a join with the fact summary table.
    -> The table of months (which is the point of view) in the logic time_dim as another source, mention levels.
    -> and include your table of facts in logical fact table and mention that the levels at months time Sun

    It will work. Let me know if I'm not clear. Also, we can expect further comments of experts.

    -Madan

  • Error when try to use the rowid with the table alias

    I tried using a table alias to test the functions of Manager of rules and met the following problems.

    1. I have clone from a schema HR employees and departments tables.

    2. create data as follows:

    BEGIN
    dbms_rlmgr.create_event_struct (data = > 't_a');
    dbms_rlmgr.add_elementary_attribute (data = > 't_a',)
    attr_name = > "a_employees"
    tab_alias = > exf$ table_alias ('employees'));
    dbms_rlmgr.add_elementary_attribute (data = > 't_a',)
    attr_name = > "a_departments"
    tab_alias = > exf$ table_alias ('departments'));
    END;

    3. create the class rule as follows:

    BEGIN
    dbms_rlmgr.create_rule_class (rule_class = > 't_as',)
    Event_Struct = > 't_a. "
    action_cbk = > 't_acb ',.
    rslt_viewnm = > 't_arv');
    END;

    4. After adding a rule to the rule class, I try to test as follows

    DECLARE
    r_emp ROWID.
    r_dept ROWID.
    CURSOR a_cur IS
    SELECT emp. ROWID, Dept. ROWID
    Employees OF ministries dept (IEM),
    WHERE emp.department_id = dept.department_id;
    I have NUMBER: = 1;
    BEGIN
    OPEN a_cur;
    LOOP
    EXTRACTION a_cur
    IN r_emp, r_dept;
    EXIT WHEN a_cur % NOTFOUND;
    dbms_output.put_line (i);
    i: = i + 1;
    dbms_output.put_line (r_emp);
    dbms_rlmgr.add_event (rule_class = > 't_alia',)
    event_inst = > r_emp,
    event_type = > 'employees');
    dbms_rlmgr.add_event (rule_class = > 't_alia',)
    event_inst = > r_dept,
    event_type = > "departments");
    END LOOP;
    END;

    But I got the following error

    SQL > DECLARE
    2 r_emp ROWID.
    3 r_dept ROWID.
    4 a_cur CURSOR IS
    5. SELECT emp. ROWID, Dept. ROWID
    6 employees OF ministries dept (IEM),
    7 WHERE emp.department_id = dept.department_id;
    8 I COMP: = 1;
    BEGIN 9
    10 a_cur OPEN;
    11 LOOP
    12 FETCH a_cur
    13. IN r_emp, r_dept;
    EXIT 14 WHEN a_cur % NOTFOUND;
    15 dbms_output.put_line (i);
    16 I: = i + 1;
    17 dbms_output.put_line (r_emp);
    18 dbms_rlmgr.add_event (rule_class = > 't_alia',)
    19 event_inst = > r_emp,
    20 event_type = > 'employees');
    21 dbms_rlmgr.add_event (rule_class = > 't_alia',)
    22 event_inst = > r_dept,
    23 event_type = > "departments");
    24 END LOOP;
    25 END;
    26.
    DECLARE
    *
    ERROR on line 1:
    ORA-06550: line 1, column 36:
    PLS-00201: identifier 'AAAVN9AAEAAAQH8AAA' must be declared.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-06512: at "EXFSYS. DBMS_RLMGR', line 974
    ORA-06512: at line 18 level

    Hello

    ROWID for individual tables can be added as events only if the rule class is set up as a Composite. For all other cases, ROWID is treated as data and they need to be formatted as a string of instances of AnyData or name-value pairs. Your script is to think that you intend to create a composite rule class while you might add ROWID individually. If please, recreate the rule as a composite class and try again. The error message you received is incorrect and has been corrected to indicate that the error is with the format data point past.

    Hope this helps,
    -Aravind.

Maybe you are looking for