Create a View with Aggregation Function (COUNT)

I've been looking up and down for a way to create a view with a few basic fields and some other fields containing aggregation function.
For instance:
To display a view that contain all the Contract Agreement and the corresponding count of the PO releases.
Agreement Nbr, Total PO releases
I need this view so that I can create a search help with this view.
I found something about the "CREATE VIEW" statement, but I don't have any idea how to use it.
Any helps toward this matter is very much appreciated, thanks.

Hello Aldern
I guess you have read about the SQL statement "CREATE VIEW". When we create a view in the dictionary this SQL statement is finally called to create the view on the DB. Thus, since we do not have any aggregation options in views you cannot achieve what you want using views.
The solution for your problem is to create a <b>search help</b> having a <b>search help exit</b>. Within the exit you can do your aggregation functions and add these values to the displayed search help data.
Regards
  Uwe

Similar Messages

  • How to create a view with a column of counts of the occurence of values

    If my table is:
    ID
    1
    2
    3
    3
    5
    5
    5
    I want to create a view with the following result:
    ID   COUNT
    1     1
    2     1
    3     2
    5     3
    How would I accomplish this?

    Sorry, my mistake. I was thinking about counting distinct events.
    I created a table with your example values:
    You should do a projection with a calculated column = 1:
    And then add this calculated column as an aggregated measure on the aggregation node:
    Result:
    Cheers,
    Fernando

  • Create a view with parameter

    it's posible create a view with parameters?
    i want to create a view and pass it parameters, in the same way when i create a procedure or function.
    i never have seen it, but i would like to know if that's posible
    thanks

    You cannot create a view with parameters. The only way is to use a stored proc to dynamically create the sql statement. The substitution variable approach does not work. SQL*Plus will prompt for the value of the variable at compile time (i.e. when you create the view) and use the value you provide in the view's query.
    SQL> create or replace view jws_test_v as
      2  select * from jws_test where flag = '&flg'
      3  /
    Enter value for flg: AA
    old   2: select * from jws_test where flag = '&flg'
    new   2: select * from jws_test where flag = 'AA'
    View created.
    SQL> select * from jws_test_v
      2  /
    no rows selected
    SQL> select text from user_views where view_name = 'JWS_TEST_V'
      2  /
    TEXT
    select "LEV1","LEV2","LEV3","LEV4","LEV5","LEV6","FC","FLAG","ONAFT","ONAPT","CU
    PEFT","CUPEPT" from jws_test where flag = 'AA'This makes sense, since substitution vartiables are a sqlplus construct, not a sql or Oracle construct. A view constructed in this way would not be callable from anywhere other than sqlplus.

  • How can i create a view with jdevlopper 10132

    hi,
    i want to know how to create a view with JDeveloper 10132.
    thanks

    Sorry, but I had to jump in here.
    7rouz - you've certainly violated the 10 commandments for posting here...
    Do you want to:
    1). Create a database view directly in the database
    2). Model a database view using the database modeller
    3). Create an ADF BC View Object
    4). Create some type of visual object (web page, Swing panel)
    5). something else.
    Your question is too ambiguous to yield an answer, unless by luck.
    Regards,
    John

  • How to create a view with parameter?

    who can tell me hwo to create a view with
    parameters just like a cursor?

    Hi,
    This is not possible in Oracle. What u can do is create the view without the where clasue and supply the where clause at runtime.
    Hope this helps...
    Regards,
    Ganesh R

  • Need help in creating a view with Encryption for hiding the code used by the multiple users

    Hi,
    Can anyone help me out in creating view with encryption data to hide the stored procedure logic with other users.
    I have create a stored procedure with encryted view but while running this manually temporary views are getting created, therefore the problem is if there are 500 entries then 500 temp views will get created.
    Any solution to aviod creating temporary views, please refer my code below
    USE [etl_validation]
    GO
    /****** Object:  StoredProcedure [dbo].[Pr_DBAccess_mod]    Script Date: 05/23/2014 12:53:22 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[Pr_DBAccess_mod](@ETL_CONFIG_ID INT)
    AS
    BEGIN
    DECLARE @openquery NVARCHAR(MAX),
     @DATABASENAME NVARCHAR(100),
     @HIERNAME NVARCHAR(100),
     @TABLENAME NVARCHAR(100),
     @SERVERTYPE NVARCHAR(100),
     @SERVERNAME NVARCHAR(100),
     @USERNAME NVARCHAR(100),
     @PASSWORD NVARCHAR(100),
     @ETL_CONFIG_IDN NVARCHAR(100);
     SET @ETL_CONFIG_IDN=CAST(@ETL_CONFIG_ID AS NVARCHAR);
     SET @TABLENAME='Department';
     SET @SERVERTYPE='SQL';
     SET @SERVERNAME ='192.168.31.176';
     SET @DATABASENAME='AdventureWorks2008R2';
     SET @HIERNAME = 'HumanResources';
     IF @SERVERTYPE='SQL'
     BEGIN
    /*SET @openquery= 'SELECT * INTO ##TestTable
                     FROM OPENROWSET(''SQLNCLI'',''server=192.168.31.176;Trusted_Connection=yes;'','''+@query+''')'
    SET @openquery=  'CREATE VIEW '+@TABLENAME+@ETL_CONFIG_IDN+
                     ' WITH ENCRYPTION AS SELECT * FROM OPENROWSET(''SQLNCLI'',''SERVER='+@SERVERNAME+';TRUSTED_CONNECTION=YES;'',''SELECT * FROM '+@DATABASENAME+'.'+@HIERNAME+'.'+@TABLENAME+''')'
    SELECT @openquery
    END
    EXECUTE sp_executesql @openquery
    END

    Hi aa_rif,
    According to your description and code message, you execute the sp_executesql statement in your stored procedure, it indeed create many views with a tablename and ETL_CONFIG_ID named. If you need not to use these temporary views, you can delete them when
    it contains the tablename in one view name.  
    In addition, if you want to create view with encryption in SQL Server, you can use directly the ENCRYPTION option to encrypt the T-SQL of a view in create view commands, for more information, see:
    http://learnsqlserver.in/4/Create-View-With-Encryption.aspx. if not, you can descript more detail about requriements, so that more forum members can involve into the thread and help you
    out. 
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Creating Materialized View with the Distinct key word

    Hi
    I need help to create Materialized View with the Distinct key word.
    my query is
    select distinct col1, col2 from t1;
    is there any alternate of DISTINCT because I can not refresh the MV as fast on demand if I am using it and Fast on Demand is a must for me.

    hi
    check out this link
    http://download-west.oracle.com/docs/cd/B12037_01/server.101/b10736/basicmv.htm#i1007299
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/intro.htm#sthref183
    hope this helps
    CHeers

  • How to create a view with parameters; read the documentation but nothing!

    Hello!
    I'm new to the Oracle world but together with my coworkers we need to very quickly study Oracle to figure out whether we'll add Oracle to our list of supported databases or not.
    Question: How do I create a view with parameters?
    I've read the documentation but I could not find this! I found the sql syntax to create a view but no parameters whatsoever...
    I have found on the web some very complicated way of doing this, but doesn't Oracle support Views with parameters?
    The goal here is to return a recordset, don't forget, so,please don't speak about stored procedures unless you are going to tell me how to get a recordset out of a stored procedure! ;)
    Thanks for all your help and attention!
    Jorge C.

    You can set up a parameterized view via context as follows:
    1. Set up a procedure to set your context values:
    create or replace procedure p_set_context (p_context IN VARCHAR2,p_param_name IN VARCHAR2,p_value IN VARCHAR2)
    as
    BEGIN
    sys.dbms_session.set_context(p_context,p_param_name,p_value);
    END;
    2. Create your context using the procedure you just created
    create or replace context my_ctx using p_set_context
    3. This is the test table I'll use
    create table my_table(col1 number)
    and populate it:
    begin
    for v_index in 1..10
    loop
    insert into my_table values(v_index);
    end loop;
    end;
    and the view that will be parameterised
    create or replace view v_my_table as select col1 from my_table where col1 between sys_context('my_ctx','start_range') and sys_context('my_ctx','end_range')
    4. Now set the parameters using the procedure above.
    begin
    p_set_context('my_ctx','start_range','1');
    p_set_context('my_ctx','end_range','5');
    end;
    5. Selecting from my_table will give you 1 to 10 (no surprise there :-) )
    selectng from v_my_table will give you 1 to 5
    You can use the context to set formats etc using the same principle. A common gotcha to watch for is trying to set the context directly using DBMS_SESSION.SET_CONTEXT instead of creating a procedure. This belongs to SYS and SYS won't have the privileges to set your context so you get an insufficient privileges result leading to much headscratching and unnecessary grants (at least that's my understanding of it).
    Sorry Jorge, as you're new to Oracle I should also have pointed out for completeness sake, that you can change the parameters at any time through recalling the p_set_context, for example, following on from above, after your "select * from v_my_table" and seeing 1 to 5, you could then do
    begin
    p_set_context('my_ctx','start_range','3');
    end;
    and when you requery 'Select * from v_my_table' you will now see rows 3 to 5.
    Bit of a simplistic example, but you can see how easy it is. :-)
    Message was edited by:
    ian512

  • Creating a view with a primary key

    I want to create a view with a defined primary key. I understand
    the view is created within a select statement, but do not
    understand how you would define a particular field as a primary
    key in the view. Also if your select statement attempts to build
    the view and has duplicate keys in the select result set, what
    would happen when the duplicate key is found? Would it just not
    include the duplicate key in the view?
    Thanks in advance for your help.
    -Pat

    I have a rather difficult problem with duplicate invoice numbers
    contained in unique records. In other words I have many records
    that appear as follows:
    3593, 0004009090, CUSTOMER, TAX, 20000117,014011976-01
    4411, 0004009090, CUSTOMER, TAX, 20000718,014011976-01
    The last field is invoice number '014011976-01' In my case I am
    building a flat file using UTL_FILE for loading into SAP
    Business Warehouse. In SAP I need to have Invoice number as a
    key in which case I can't have duplicate invoice numbers. All
    the SQL I have tried to date returns a large amount of records
    similar to the above records. I am selecting these records from
    4 different schemas which represent 4 different companies. I
    realize the data is the problem and that the vendor of the
    product I am working with should not allow records with
    duplicate invoice numbers, but I have to get the data loaded as
    that is what they want and are paying for. So back to my View. I
    was hoping to create a view and be able to work in the view to
    remove duplicate records prior to writing them to a file. Any
    suggestions are welcomed.
    Thanks
    -Pat

  • How to create table view with reference table

    Hi experts,
    How to create table view with reference table in SE11, plz gve me stp by stp procedure.
    pints grnded for hlp.

    Hi
    Go to Tcode se11 choose view and enter the name and create a popup opens up choose database view option
    enter the description
    On the left hand side choose the table name.
    Click on view fields tab and choose your table fields.Here you can choose which fields you want in your view.
    Save and then activate.
    Hope this helps.
    Regards,
    Harish

  • Create material view with MATERIAL_MAINTAIN_DARK

    Hello !
    I have done a material migration program with FM MATERIAL_MAINTAIN_DARK. The program integrate the basic data, and then each view one by one.
    It works fine except with material with internal number. It creats the basic data but when i use the number generated to create the other view i get this message :
    No external number assignment possible for mat. type GENERIC MATERIALS
    I found this field in mara_ueb : KZ_MAT_RES
    But when i put X in it, it returns that i forgot mandatory data. So I tried to select the data already in MARA and MAKT, but now the message is that the material already exist ! It is true but I want to create another view.
    Here's a piece of my code to help you to understand, the commentary part is what I tried to do to resolved my problem :
      ADD 1 TO v_count.
      ADD 1 TO v_line.
      MOVE v_line TO v_line_c.
    *---MARA
      MOVE sy-mandt TO t_mara_ueb-mandt.
      MOVE 'MM01' TO t_mara_ueb-tcode.
      MOVE v_count TO t_mara_ueb-tranc.
      MOVE k_purcha TO t_mara_ueb-vpsta.
      SELECT COUNT(*) FROM t134 WHERE mtart = t_data_pur-mtart
                                   AND envop = space.
      IF sy-subrc = 0.
        TABLES : mara, makt.
       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
         EXPORTING
           input         = t_data_pur-matnr
        IMPORTING
          OUTPUT        = t_data_pur-matnr.
       SELECT SINGLE * FROM mara WHERE matnr = t_data_pur-matnr.
       MOVE-CORRESPONDING mara TO t_mara_ueb.
       SELECT SINGLE * FROM makt WHERE matnr = t_data_pur-matnr.
       MOVE-CORRESPONDING makt TO t_makt_ueb.
         MOVE 'X' TO t_mara_ueb-KZ_MAT_RES.
      ENDIF.
      MOVE t_data_pur-matnr TO t_mara_ueb-matnr.
      MOVE t_data_pur-mbrsh TO t_mara_ueb-mbrsh.
      MOVE t_data_pur-mtart TO t_mara_ueb-mtart.
      MOVE t_data_pur-ekwsl TO t_mara_ueb-ekwsl.
      APPEND t_mara_ueb.
    *---MARC
      MOVE sy-mandt TO t_marc_ueb-mandt.
      MOVE v_count TO t_marc_ueb-tranc.
      MOVE t_data_pur-matnr TO t_marc_ueb-matnr.
      MOVE t_data_pur-werks TO t_marc_ueb-werks.
      MOVE t_data_pur-ekgrp TO t_marc_ueb-ekgrp.
      MOVE t_data_pur-mmsta TO t_marc_ueb-mmsta.
      MOVE t_data_pur-mmstd TO t_marc_ueb-mmstd.
      MOVE t_data_pur-webaz TO t_marc_ueb-webaz.
      MOVE t_data_pur-kordb TO t_marc_ueb-kordb.
      MOVE t_data_pur-usequ TO t_marc_ueb-usequ.
      APPEND t_marc_ueb.
    *---!!! Call FUNCTION MODULE !!!
      CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'
        EXPORTING
        FLAG_MUSS_PRUEFEN               = 'X'
        SPERRMODUS                      = 'E'
        MAX_ERRORS                      = 0
         p_kz_no_warn                    = 'X'
         kz_prf                          = space
        KZ_VERW                         = 'X'
        KZ_AEND                         = 'X'
        KZ_DISPO                        = 'X'
         kz_test                         = lv_test
        NO_DATABASE_UPDATE              = ' '
         call_mode                       = ' '   "OR RMD OR space OR BAP
        CALL_MODE2                      = ' '
         user                            = sy-uname
        SUPPRESS_ARRAY_READ             = ' '
        FLG_MASS                        = ' '
        IMPORTING
         matnr_last                      = lv_matnr
         number_errors_transaction       = lv_nb_error
        TABLES
         amara_ueb                       = t_mara_ueb
         amakt_ueb                       = t_makt_ueb
         amarc_ueb                       = t_marc_ueb
         amard_ueb                       = t_mard_ueb
        AMFHM_UEB                       =
        AMARM_UEB                       =
        AMEA1_UEB                       =
         ambew_ueb                       = t_mbew_ueb
         asteu_ueb                       = t_steu_ueb
        ASTMM_UEB                       =
         amlgn_ueb                       = t_mlgn_ueb
         amlgt_ueb                       = t_mlgt_ueb
        AMPGD_UEB                       =
         ampop_ueb                       = t_mpop_ueb
        AMVEG_UEB                       =
        AMVEU_UEB                       =
         amvke_ueb                       = t_mvke_ueb
        ALTX1_UEB                       =
        AMPRW_UEB                       =
        AMFIELDRES                      =
         amerrdat                        = t_amerrdat
       EXCEPTIONS
         kstatus_empty                   = 1
         tkstatus_empty                  = 2
         t130m_error                     = 3
         internal_error                  = 4
         too_many_errors                 = 5
         update_error                    = 6
         OTHERS                          = 7.
    I really need you help !
    thank you in advance.

    OK I found the answer !
    It is because the matnr generate add 00000... before the number. So I have to add it for the other view. But it is not the case for material number define externally. And the message was not comprensive.
    *---MARA
      MOVE sy-mandt TO t_mara_ueb-mandt.
      MOVE 'MM01' TO t_mara_ueb-tcode.
      MOVE v_count TO t_mara_ueb-tranc.
      MOVE k_purcha TO t_mara_ueb-vpsta.
      SELECT COUNT(*) FROM t134 WHERE mtart = t_data_pur-mtart
                                  AND envop = space.
      IF sy-subrc = 0.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  input  = t_data_pur-matnr
             IMPORTING
                  output = t_data_pur-matnr.
      ENDIF.
      MOVE t_data_pur-matnr TO t_mara_ueb-matnr.
      MOVE t_data_pur-mbrsh TO t_mara_ueb-mbrsh.
      MOVE t_data_pur-mtart TO t_mara_ueb-mtart.
      MOVE t_data_pur-ekwsl TO t_mara_ueb-ekwsl.
      APPEND t_mara_ueb.
    *---MARC
      MOVE sy-mandt TO t_marc_ueb-mandt.
      MOVE v_count TO t_marc_ueb-tranc.
      MOVE t_data_pur-matnr TO t_marc_ueb-matnr.
      MOVE t_data_pur-werks TO t_marc_ueb-werks.
      MOVE t_data_pur-ekgrp TO t_marc_ueb-ekgrp.
      MOVE t_data_pur-mmsta TO t_marc_ueb-mmsta.
      MOVE t_data_pur-mmstd TO t_marc_ueb-mmstd.
      MOVE t_data_pur-webaz TO t_marc_ueb-webaz.
      MOVE t_data_pur-kordb TO t_marc_ueb-kordb.
      MOVE t_data_pur-usequ TO t_marc_ueb-usequ.
      APPEND t_marc_ueb.
    Edited by: Louis-Arnaud Bouquin on Mar 5, 2008 3:04 PM

  • How to create a view with columns from multiple rows

    I have posted this in SQL/PSL forum, but I hope database experts in this group can give me ideas too, also the need is from BI reports.
    I have a table, say, project_milestones, which has these columns in concern:
    proj_id, milestone_name, actual_end_date
    with data:
    proj_id, milestone_name, actual_end_date
    ===== ================ ==============
    1001, Key Element Approve, 2009-10-02
    1001, Final Synopsis, 2009-10-07
    1001, Final Protocol Approved, 2009-10-15
    1001, FPFV, 2010-01-10
    1001, LPFV, 2010-03-12
    1002, Key Element Approve, 2008-12-02
    1002, Final Synopsis, 2009-01-07
    1002, Final Protocol Approved, 2009-01-12
    1002, FPFV, 2009-03-30
    1002, LPFV, 2009-10-04
    There are about 10 milestones in each project.
    I have to create a view to flat these data at project level, looks like this:
    proj_id, key_element_date, final_synopsis_date, final_protocol_approved_date, FPFV_date, LPFV_date, key_element_to_final_synopsis_days, final_synopsis_final_protocol_days, ....
    How can I do this?
    Thanks,

    user9175541 wrote:
    I have posted this in SQL/PSL forum, but I hope database experts in this group can give me ideas too, also the need is from BI reports.
    I have a table, say, project_milestones, which has these columns in concern:
    proj_id, milestone_name, actual_end_date
    with data:
    proj_id, milestone_name, actual_end_date
    ===== ================ ==============
    1001, Key Element Approve, 2009-10-02
    1001, Final Synopsis, 2009-10-07
    1001, Final Protocol Approved, 2009-10-15
    1001, FPFV, 2010-01-10
    1001, LPFV, 2010-03-12
    1002, Key Element Approve, 2008-12-02
    1002, Final Synopsis, 2009-01-07
    1002, Final Protocol Approved, 2009-01-12
    1002, FPFV, 2009-03-30
    1002, LPFV, 2009-10-04
    There are about 10 milestones in each project.
    I have to create a view to flat these data at project level, looks like this:
    proj_id, key_element_date, final_synopsis_date, final_protocol_approved_date, FPFV_date, LPFV_date, key_element_to_final_synopsis_days, final_synopsis_final_protocol_days, ....
    How can I do this?
    Thanks,Create a pivot table and put "milestone_name" in the Columns section under the Labels.
    Put "actual_end_date" in the Measures section and change the Aggregation Rule to "Max."
    The rest of the attributes keep in Rows section.

  • Create a view with datatype from dual

    I have Windows XP with 10g 10.2.0.1.0
    I need to create a view from dual and with data type, such as NUMBER(5,2), NUMBER or VARCHAR2(20) .
    such as:
    create view test(view_test varchar2(20)) as (select view_test from dual)
    Please help. Thanks in advance.

    It does seem kind of odd, but you can do something like this with the CAST function:
    SQL> create view dual_view as
      2  select cast(null as number(5,2)) col1
      3        ,cast(null as date)    col2
      4        ,cast(null as varchar2(30)) col3
      5  from   dual;
    View created.
    SQL> desc dual_view
    Name                                      Null?    Type
    COL1                                               NUMBER(5,2)
    COL2                                               DATE
    COL3                                               VARCHAR2(30)I used NULLs but you can use actual values if you want.

  • Error Creating Materialized View With a Job

    Oracle 9ir2
    I've created a job like this in a java class:
    ...Java Code ...
    cs = conn.prepareCall ("DECLARE v_job NUMBER; BEGIN DBMS_JOB.SUBMIT(v_job,'begin CTH_REGENERA_VM; end;', TRUNC(SYSDATE+1) + (3/24)); END;");
    ...Java Code ...
    The Procedure called in the Job:
    CREATE OR REPLACE PROCEDURE CTH_REGENERA_VM
         AUTHID CURRENT_USER IS
         existe NUMBER(1);
         cur BINARY_INTEGER := DBMS_SQL.OPEN_CURSOR;
         fdbk BINARY_INTEGER;
    BEGIN
         SELECT count(*) INTO existe FROM user_mviews WHERE mview_name = 'CTH_PRESENTA_A_VM';
         IF existe > 0 THEN
              DBMS_SQL.PARSE(cur, 'DROP MATERIALIZED VIEW CTH_PRESENTA_A_VM', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
              INSERT INTO CTH_HISTORIAL VALUES('ELIMINADA VM CTH_PRESENTA_A_VM', SYSDATE);
              COMMIT;
         END IF;
         DBMS_SQL.PARSE(cur, 'CREATE MATERIALIZED VIEW CTH_PRESENTA_A_VM
         TABLESPACE DAT1_CTH
         STORAGE(INITIAL 16M NEXT 8M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)
                   XMLTYPE XML STORE AS CLOB (           TABLESPACE DAT1_CTH
                   STORAGE(INITIAL 16M NEXT 8M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0))
         AS select FICHA, XML,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_a'') as MUNICIPIO,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_c'') as CALIFICACION,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_b'') as PROVINCIA,
         extractvalue(xml, ''/FICHE/Encab_tem�tico_de_materia_a[1]'') as MATERIA,
         extractvalue(xml, ''/FICHE/Fecha_cronol�gica_b[1]'') as FECHA,
         extractvalue(xml, ''/FICHE/Datos_matem�ticos_a[1]'') as ESCALA
         from cth_xmltable', DBMS_SQL.NATIVE);
         INSERT INTO CTH_HISTORIAL VALUES('ASIGNO EL PARSE DE MATERIALIZED', SYSDATE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('EJECUTO EL PARSE DE MATERIALIZED', SYSDATE);
         INSERT INTO CTH_HISTORIAL VALUES('CREADA VM CTH_PRESENTA_A_VM', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_INDEX1
         ON CTH_PRESENTA_A_VM(XML)
         INDEXTYPE IS CTXSYS.CONTEXT
         PARAMETERS (''storage cth section group ctxsys.auto_section_group'')', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE ORACLE TEXT CTH_INDEX1', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_IDX_MUNICIPIO3
              ON CTH_PRESENTA_A_VM(UPPER(MUNICIPIO))
              TABLESPACE IDX1_CTH
              STORAGE (INITIAL 1M NEXT 512K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE CTH_IDX_MUNICIPIO2', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_IDX_FICHA2
         ON CTH_PRESENTA_A_VM
         (FICHA)
         TABLESPACE IDX1_CTH
         STORAGE(INITIAL 1M NEXT 512K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE CTH_IDX_FICHA2', SYSDATE);
         DBMS_SQL.CLOSE_CURSOR(cur);
    COMMIT;
    END;
    I got always an error in the created materialized view. If I call the procedure with SQL Plus, it run ok. The user
    has CTXAPP, DBA roles, so I supouse it is not a privileges problem. I also tried to create a simple materialized view or a table, and always got an error ora-12011
    Thanks in advance.

    If I call the procedure with SQL Plus, it run ok. Are you using the same user to run it in SQL*Plus as runs it from Java.
    The normal reason for procedures to fail like this is privileges. Particularly, we cannot run procedures using privileges we have been granted through roles.
    The user has CTXAPP, DBA roles, so I supouse it is not a privileges problem. Try granting the system privilege CREATE MATERIALIZED VIEW to the user and see what happens.
    I drop the materialized and create again, cause it's the fastest way I've found. With a DBMS_MVIEW.REFRESH is too slow.I find that surprising as drop & create has to do all the work that a refresh has to do plus some more - maybe it's something to do with XML. Did you try adding a snapshot log and going for FAST? I don't know whwther the XML procesing would render the view complex - have you explained it?
    Cheers, APC

  • Creating a View with "clipped" data

    Hi all,
    I'm wondering if someone might know if it's possible to have clipped data in a view without clipping the original data that the view is drawing from.
    The problem we have is that we have a full dataset that we need to keep in a complete state (as a table in Oracle). We want to be able to create a View that will display a subset of data from this table, however, some of the objects in the full dataset cross a boundary and for these objects, we want the View to only show the part of the object within that boundary.
    I know we can clip the original layer but we ideally need to keep that layer untouched and do the clipping on-the-fly in the View. Is this possible?
    Thanks for any help you can give,
    Cheers, Paul

    Do you want to:
    create view my_clip
    as
    select a.id,
    a.attribute,
    mdsys.sdo_intersection(a.geometry,b.geometry,0.005) as geometry
    from mycliparea b,
    mytable a
    where sdo_anyinteract(a.geometry,b.geometry) = 'TRUE'
    Now this will work but to get performance you will have to do one of two things:
    1. Create a function based index. See doco or other postings in this forum for examples
    of how to do this.
    2. Change the view from an ordinary view to a materialized view. And then create
    a normal spatial index on the computed shape. (I recommend the use of
    these as against ordinary views.)
    However, Bryan is right, the problem with SDO_INTERSECTION is that it can return:
    1. Polygons;
    2. Lines;
    3. Points;
    4. Compound objects containing one or more of the above.
    If you want polygons only, then you need to extract them.
    <selfpromtion>
    I have written a set of extraction functions that do this which are available for free.
    Contact me at "spatialdbadvisor at netspace dot net dot au" or "simon at spatialdbadvisor dot com"
    </selfpromotion>
    The correct view definition using one of my functions would be:
    create view my_clip
    as
    select a.id,
    a.attribute,
    geom.ExtractPolygon(
    mdsys.sdo_intersection(a.geometry,b.geometry,0.005))
    as geometry
    from mycliparea b,
    mytable a
    where sdo_anyinteract(a.geometry,b.geometry) = 'TRUE'
    regards
    S

Maybe you are looking for

  • Windows error message when trying to install ACR 4.5

    Hi. Following the download instructions the best that I can, I run into problems when reaching the instructions' point 6: moving the newly downloaded zip file 8b file into the ......../File Formats folder from which I just had moved the existing 4.4

  • Custom Chart Effects

    Hello, I am interested in creating my own chart effects... I assume I will need to extend SeriesEffect (or SeriesInterpolateEffect, which is close to what I want to do), but I am not really sure what to do from there. What methods do I override? Does

  • Transaction Type for Activities

    Hi, In Web UI, I open an activity and select the option 'More -> Send E-Mail'. A popup opens, asking me to select a transaction type. However, there are no entries in the popup. I think the data in this popup comes from some customizing setting. Can

  • Please help how to design query to implement this requirement.

    Dear Expert, Here is what I have and what the requirement is: I have a InfoCube: Dimensions: 1. Material 2. Currency Key Figures: 1. Qty 2. Amount We want to get the Qty and Amount by Material, but use Currency to be the filter. It means for example,

  • How to see OB40 tcode screen through spro

    Hi All, how to see OB40 tcode screen through spro (need path in SPRO) Thanks, Amit