Synonym of ALTER with Create or replace synonym

Oracle 9i Release 2 database

I need to change the thesaurus during execution to point to a new owner of the table. But I'm running into errors of "insufficient privileges".

SQL> select grantee,owner,table_name,privilege from dba_tab_privs
  2  where table_name IN ('OE4PNFGETDATA','OEBGGETDATA','OEGETDATA');

GRANTEE       OWNER     TABLE_NAME        PRIVILEGE
------------- --------- ----------------- -----------
OEMUSER       OEM2      OE4PNFGETDATA     EXECUTE
OEMUSER       OEM2      OEBGGETDATA       EXECUTE
OEMUSER       OEM2      OEGETDATA         EXECUTE
OEMUSER       OEM1      OEBGGETDATA       EXECUTE
OEMUSER       OEM1      OEGETDATA         EXECUTE
OEMUSER       OEM1      OE4PNFGETDATA     EXECUTE

SQL> sho user
USER is "OEMUSER"
SQL> select synonym_name,table_owner,table_name from user_synonyms ;

SYNONYM_NAME                   TABLE_OWNER                    TABLE_NAME
------------------------------ ------------------------------ ------------------------------
OE4PNFGETDATA                  OEM1                           OE4PNFGETDATA
OEBGGETDATA                    OEM1                           OEBGGETDATA
OEGETDATA                      OEM1                           OEGETDATA

I need to change the owner of the table to OEM2. Using create or replace synonym in a procedure:

CREATE OR REPLACE PROCEDURE oemuser.p_switch_users (  i_nonactive_user  IN  VARCHAR2
                                                    , o_msg             OUT VARCHAR2 )
AS
   v_synonym_name VARCHAR2(30) ;
   v_table_owner  VARCHAR2(30) := i_nonactive_user ;
   v_table_name   VARCHAR2(30) ;
   v_sql          VARCHAR2(255);
BEGIN
   FOR   rec   IN   ( select synonym_name, table_owner, table_name from user_synonyms )
   LOOP
      v_synonym_name := rec.synonym_name ;
      v_table_name   := rec.table_name   ;
      v_sql := 'CREATE OR REPLACE SYNONYM ' || v_synonym_name || ' FOR ' || v_table_owner || 
               '.' || v_table_name ;
      EXECUTE IMMEDIATE v_sql ;

   END LOOP ;
   
   o_msg := 'Completed successfully' ;
   
   EXCEPTION
      WHEN  others  THEN
         o_msg := 'Error_Stack...' || Chr(10) ||
                  DBMS_UTILITY.FORMAT_ERROR_STACK ;
         RAISE ;
END p_switch_users ;
/

var o_msg varchar2(512)
var i_user varchar2(10)
exec :i_user := 'OEM2'

exec p_switch_users(:i_user,:o_msg)

ORA-01031: insufficient privileges
ORA-06512: at "OEMUSER.P_SWITCH_USE
RS", line 

I have not tried to drop the synonyms and re - create, but I expect the same error. Any suggestions?

Hello

the owner of the procedure should the privilege of creating its own synonyms if i_nonactive_user is defined on its own behalf (this case has no interest), and he has the privilege to create ANY synonym in other... At first glance, I would say that this is not a good idea.

Note: you can also save a job: no need to redefine a synonym to point to the same thing, so I would limit synonyms selected in the loop:

FOR rec IN (SELECT u.synonym_name, u.table_owner, u.table_name

U user_synonyms

WHERE u.table_owner! = v_table_owner

)

Best regards

Bruno Vroman

Tags: Database

Similar Questions

  • . Help copying images - "cannot create or replace family photos. Access is denied.

    When I try to copy pictures from my computer to a Lexar removable I get this message. "Cannot create or replace family photos. Access is denied. Make sure that the disk is not full or write protected and this file is not currently in use. Please help, but keep it simple that I am barely computer literate

    Just a guess... but maybe you copied too
    files in the directory root of the card. (Root directory
    simply means level 1 with no folder)

    Remove files from the media, and then try again.

    For example I just tested a 1 GB SD card and the
    maximum number of files I can copy to the root
    Directory is 180. If I add a file more I get a dialog box
    who says: "cannot copy IMG_4321; The directory
    or file cannot be created. And if I try to add a file
    before removing a file to make room for it... I have
    Get the following message: "unable to create the folder.
    "New folder" failed to create the directory or file.

    If I make space by deleting files and add empty
    files to the card... I can copy as many files as I have
    here in the files (up to the limit of memory of)
    the card).

    I don't know if you noticed but most digital
    Cameras to create folders with 100 photos per folder.
    They do not image files in the root directory
    of the card.

  • SQL > create or replace procedure sp_Validate3 (p_acr_no IN varchar2 2)

    Hi all

    11.2.0.1

    Can you help me to debug what is that pl/sql code error? Thank you
    SQL> create or replace procedure sp_Validate3(p_acr_no    IN  varchar2
      2                                         ,p_recordset OUT sys_refcursor
      3                                         ) as
      4  begin
      5   open p_recordset for
      6      select am.acr_no as acr_no
      7            ,'TEST' as lastname
      8            ,nvl(a.or_no,'0') as ecc_orno
      9            ,nvl(b.or_no,'0') as rp_orno
     10            ,nvl(c.or_no,'0') as ar_orno
     11      from   tab t
     12                        join acr_master     am on (trim(acr_no) = p_acr_no)
     13             left outer join payment_master a  on (payment_type = 'ECC' and trim(acr_no) = p_acr_no)
     14             left outer join payment_master b  on (payment_type = 'RP'  and trim(acr_no) = p_acr_no)
     15             left outer join payment_master c  on (payment_type = 'AR'  and trim(acr_no) = p_acr_no);
     16  end;
     17  / 
     
    Warning: Procedure created with compilation errors.
     
    SQL> show error
    Errors for PROCEDURE SP_VALIDATE3:
     
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    6/5      PL/SQL: SQL Statement ignored
    13/80    PL/SQL: ORA-00918: column ambiguously defined
    SQL>
    create table acr_master(acr_no varchar2(10))
    
    drop table payment_master
    
    create table payment_master(or_no varchar2(10),acr_no varchar2(10),payment_type varchar2(10))
    
    /* Formatted on 06/06/2013 6:06:58 PM (QP5 v5.126.903.23003) */
    CREATE OR REPLACE PROCEDURE sp_Validate3 (p_acr_no      IN     VARCHAR2,
                                              p_recordset      OUT sys_refcursor)
    AS
    BEGIN
       OPEN p_recordset FOR
          SELECT   am.acr_no AS acr_no,
                   'TEST' AS lastname,
                   NVL (a.or_no, '0') AS ecc_orno,
                   NVL (b.or_no, '0') AS rp_orno,
                   NVL (c.or_no, '0') AS ar_orno
            FROM               tab t
                            JOIN
                               acr_master am
                            ON (TRIM (acr_no) = p_acr_no)
                         LEFT OUTER JOIN
                            payment_master a
                         ON (payment_type = 'ECC' AND TRIM (acr_no) = p_acr_no)
                      LEFT OUTER JOIN
                         payment_master b
                      ON (payment_type = 'RP' AND TRIM (acr_no) = p_acr_no)
                   LEFT OUTER JOIN
                      payment_master c
                   ON (payment_type = 'AR' AND TRIM (acr_no) = p_acr_no);
    END;
    /
    
    SQL> show error
    Errors for PROCEDURE SP_VALIDATE3:
    
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    6/5      PL/SQL: SQL Statement ignored
    13/80    PL/SQL: ORA-00918: column ambiguously defined
    SQL>
    
    --In the below code after keeping alias names of the tables, the procedure compiled successfully 
    
    /* Formatted on 06/06/2013 6:06:58 PM (QP5 v5.126.903.23003) */
    CREATE OR REPLACE PROCEDURE sp_Validate3 (p_acr_no      IN     VARCHAR2,
                                              p_recordset      OUT sys_refcursor)
    AS
    BEGIN
       OPEN p_recordset FOR
          SELECT   am.acr_no AS acr_no,
                   'TEST' AS lastname,
                   NVL (a.or_no, '0') AS ecc_orno,
                   NVL (b.or_no, '0') AS rp_orno,
                   NVL (c.or_no, '0') AS ar_orno
            FROM               tab t
                            JOIN
                               acr_master am
                            ON (TRIM (acr_no) = p_acr_no)
                         LEFT OUTER JOIN
                            payment_master a
                         ON (a.payment_type = 'ECC' AND TRIM (a.acr_no) = p_acr_no)
                      LEFT OUTER JOIN
                         payment_master b
                      ON (b.payment_type = 'RP' AND TRIM (b.acr_no) = p_acr_no)
                   LEFT OUTER JOIN
                      payment_master c
                   ON (c.payment_type = 'AR' AND TRIM (c.acr_no) = p_acr_no);
    END;
    /
    
  • Procedure crashes while create or replace!

    Dear all,

    My Oracle 11 g RAC database is.

    I made some changes in one of my procedure and tried to recreate it using the CREATE or REPLACE procedure...

    The statement hangs for a long time and simultaneity in OEM increases up to a very high level. I tried to find blocking sessions, but for some time, there was no session blocking.

    I also tried to stop the activities on the tables used in this procedure.

    Please suggest me what can I do in this situation. I also tried directly from the server running the query.

    Best regards, Imran

    Oh, layout of the dining Forum, I copied correctly ;)

    In fact, it is not equal to '<>' operator & no '=' equql, please correct & let me know if useful

    Once again his lack below, will give you session killin commnd

    Select / * + CHOOSE * / ' alter system kill session "' | a.SID | ',' | a.Serial #| " « ; »
    session v$, $ v b access
    where a.sid = select
    and b.type<>'does not EXIST.
    and (b.owner is not null) and (b.owner<>'SYSTEM') and (b.owner<>'SYS') and serial No. <> 1
    and upper (b.object) like '% VSNL_CORP_TASK_READY_CMPL % ';

    Thank you
    Ajay more
    http://moreajays.blogspot.com

  • Create Or Replace function error

    Hello

    I do the search of texts using Oracle SQL Developer: ODMiner... I imported the "WEBLOG" data into a table... These weblog data consists of the activity of users, date, time, url, etc. The first step I took was to use a function to convert the date and time I have in the data table, in a number representing the 40 minutes since 01/01/1990. I did it by dividing by 2400 (seconds in 40 minutes). The main objective is to have a period of time for the sessions.
    I used the following code,

    (SsnDate) CREATE or REPLACE FUNCTION
    DEFAULT VARCHAR2 03/01/18 EFFECTIVE DATE,
    TIME IN VARCHAR2
    ) RETURN NUMBER
    AS
    BEGIN
    RETURN TRUNC ((to_date(DATE||) e '|| TIME, ' Hh: mm: DD-MM-YY ')-to_date('01-JAN-1990','DD-MON-YYYY')) * (86400/2400);
    END ssnDate;

    This is what appeared in the newspaper after the execution of the statement,

    SsnDate compiled FUNCTION
    WARNING: the execution is completed with warning

    After that, I tried to create a VIEW to change the DATE and TIME with the ssnDate that was created earlier and concatenate the CS_URI_STEM (which is the accessible resource) and CS_URI_QUERY (which is the query, if any, the client was trying to perform) in a new field called WEB_LINK.

    This is the code used

    CREATE OR REPLACE VIEW WEBLOG_VIEWS ("C_IP", "WEB_LINK", "CS_USER_AGENT", "SESSION")
    AS
    SELECT ssnDate (LOG_DATE, LOG_TIME) AS "SESSION."
    C_IP,
    CS_USER_AGENT,
    (CS_URI_STEM |'?) ' || CS_URI_QUERY) AS WEB_LINK
    OF THE WEB BLOG.

    Now that I got the following error...

    Error from the 1 in the command line:
    CREATE OR REPLACE VIEW WEBLOG_VIEWS ("C_IP", "WEB_LINK", "CS_USER_AGENT", "SESSION")
    AS
    SELECT ssnDate (LOG_DATE, LOG_TIME) AS "SESSION."
    C_IP,
    CS_USER_AGENT,
    (CS_URI_STEM |'?) ' || CS_URI_QUERY) AS WEB_LINK
    WEBLOG
    Error in the command line: 3 column: 38
    Error report:
    SQL error: ORA-00923: KEYWORD not found where expected
    00923 00000 - "FROM keyword not found where expected"
    * Cause:
    * Action:

    I do not understand where I am going wrong with this... It comes to the data preparation step that requires me to prepare the data before applying the techniques of modeling or algorithms... The next step might be to group the data, based on the time of the session, ip and the user agent of each session as well as the fields web_links visited by the user of the session.

    I would be really grateful for all entries on where I'm wrong and all the solutions for it!

    Good. Please close the message.

    Concerning
    Girish Sharma

  • Ampersand substitution in create or replace procedure statement

    Hi guys,.

    I wonder why my replacement ampersand works in a create or replace statement of the stored procedure.

    CREATE OR REPLACE PROCEDURE UPDATE_DIM_SALES AS


    Cancel the DEFINITION DimSales;
    Cancel the DEFINITION FactTable;
    SET DimSales = 'TESTTAB;
    SET FactTable = myfact;


    BEGIN
    *...*

    Error (5,20): PLS-00103: encountered the symbol "=" when expected as follows: =. (@ %; not null default range character)


    If I assign the value with: = I get the error "invalid table" thereafter for the statemnt of INSERTION:

    CREATE OR REPLACE PROCEDURE UPDATE_DIM_SALES AS


    Cancel the DEFINITION DimSales;
    Cancel the DEFINITION FactTable;
    SET DimSales: = ' x 2';
    SET FactTable: = ' x 1';


    BEGIN
    INSERT INTO & DimSales (column1, column2,...)

    Why not the ampersand substitution work in a stored procedure?

    No problem with the carpet. Display. But you don't need to create and drop them again. Simply create a time and refresh just before departure if necessary. I expect the creation and updating of points of view is fast comparibly. Also access to the seller_id should be indexed.

    Your original pl/sql block is slow due to several reasons. One might be that you agree to each line. Engage is an extremely slow process. He avoid as much as possible. Another part might be that you make all the changes of context of pl/sql. The obvious way to avoid this would be to BULK operations (bulk-select + Forall). It is not so difficult. The size of the collection must be limited to a lower amount.

    Best way would be to measure the performance of pl/sql parts using a tool such as DBMS_PROFILER. Then you can decide what part is slow and must be granted.

    A simple insert could be faster. Did you test that?

    example not tested

    INSERT /*+append */
    INTO &DimSales (K_Sales,REG,BVL,DS, VS,RS,GS,VK)
    (SELECT trim(leading '0' from RS||GS) ,REG, BVL,DS, VS,RS,GS,VK
    from &FactTable f
    join &testsales s on f.SellerNo =s.Seller_No;
    
    commit;
    

    You can run the other issues, but this is generally the fastest approach. Try to avoid the separate if possible. This requires a sort and will slow down the insert of a lot.

    Published by: Sven w. on November 30, 2010 17:10

  • problems with creating a view

    Hello experts,

    I am having trouble with my opinion. I need to create a view of 3 tables, but the view is empty. Its settlement data not at all
    CREATE OR REPLACE FORCE VIEW inv_serial_tracking_v
    (
      PRODUCT_ID            ,
      GAME                  ,
      SERIES                ,
      SERIAL_NUMBER         ,
      PORTION_NUMBER        ,
      BEGIN_PIECE           ,
      END_PIECE             ,
      LOCATION_TYPE         ,
      LOCATION_ID           ,
      retailer_name         ,
      INV_STATUS_ID         ,
      inv_status_name       ,
      REF_DOC_TYPE          ,
      REF_DOC_NUMBER        ,
      REF_DOC_LINE          ,
      LOAD_NUMBER           ,
      CARTON_NUMBER         ,
      STATUS_DATE_MODIFIED  ,
      PCT_VALIDATED         ,
      LAST_DATE_MODIFIED    ,
      USER_MODIFIED         ,
      CDC                   ,
      LT_PAID_CNT           ,
      MT_PAID_CNT           ,
      FST_PAID_TKT          ,
      LST_PAID_TKT          ,
      SOLD_OUT              
    )
    AS
       SELECT   a.product_id,
                b.name game,
                a.series,
                a.serial_number,
                a.portion_number,
                a.begin_piece,
                a.end_piece,
                a.location_type,
                a.location_id ,
                a.inv_status_id,
                j.status inv_status_name,
                a.REF_DOC_TYPE          ,
                a.REF_DOC_NUMBER        ,
                a.REF_DOC_LINE          ,
                a.LOAD_NUMBER           ,
                a.CARTON_NUMBER         ,
                a.STATUS_DATE_MODIFIED  ,
                a.PCT_VALIDATED         ,
                a.LAST_DATE_MODIFIED    ,
                a.USER_MODIFIED         ,
                a.CDC                   ,
                a.LT_PAID_CNT           ,
                a.MT_PAID_CNT           ,
                a.FST_PAID_TKT          ,
                a.LST_PAID_TKT          ,
                a.SOLD_OUT 
                
    --            f_get_cdc_date (a.cdc) cdc_date,
    --            f_get_week_num (TO_NUMBER (a.cdc)) week_num,
    --            TO_DATE (
    --               SUBSTR (a.last_date_modified, 1, INSTR (a.last_date_modified,
    --                                                       '.',
    --                                                       1,
    --                                                       3)
    --                                                - 1),
    --               'YYYY-MM-DD-HH24.MI.SS'
    --            )
    --               last_modified_date,
    
         FROM   inv_serial_tracking a,
                games b,
                inventory_status j
        WHERE       a.product_id = b.id
                AND a.inv_status_id = j.id;

    Hello

    The base table/s are? You have used FORCE, which means that the display will be created regardless of whether or not the base tables exist.

    Kind regards.

    Published by: Spongebob on April 28, 2010 15:10

  • CREATE (or REPLACE) procedure_definition | function definition

    A manual I read says to use the function CREATE or REPLACE function, but my function will not compile with one of these. It compiles only when I use the FUNCTION itself. The CREATION or replacement is no longer used in Oracle 10 g?

    Thank you

    Rich75 wrote:
    I tried in SQL * more and it worked for me too, but I usually use SQL Navigator. That's where I got the error.

    I'm pretty new to Oracle, so I probably don't understand some things too well. I realized that when I created the function in SQL * Plus, it appeared in SQL Navigator under functions. I created this function in a package, so I think it's a little different than the creation of a global function.

    Published by: Rich75 on January 27, 2010 10:02

    Yes, OK if you create a function inside a package, then you do not have to give create or replace keywords.

  • CREATE OR REPLACE TABLE

    Hi, I need to write a script that recreates a table. Something similar to the VIEW to CREATE or REPLACE. I came up with the following
    DECLARE
       does_not_exist   EXCEPTION;
       PRAGMA EXCEPTION_INIT (does_not_exist, -942);
    BEGIN
       EXECUTE IMMEDIATE 'DROP TABLE foobar';
    EXCEPTION
       WHEN does_not_exist
       THEN
          NULL;
    END;
    /
    
    CREATE TABLE foobar (c1 INT);
    I wonder if there is an easier way. Are there?

    TIA, Markus

    I wonder if there is an easier way. Are there?

    DROP TABLE foobar;
    CREATE TABLE foobar (c1 INT);

  • Create or replace view still holding

    Hello

    I'm trying to update an existing view, but "CREATE or REPLACE" takes forever. When I try to see the results of this point of view, I can see the results quickly. Also, I am able to create/upgrade new or existing views very fast.
    CREATE OR REPLACE VIEW OBR.IFV_OFFC_MGR_INFO
    AS 
     /* --------------------------------------------------------
      *   IFV_OFFC_MGR_INFO
      * --------------------------------------------------------
      *
      *   View to be used by those objects that require the office
      *       manager information pertinent to an office.
      *
      *   This is designed to return all Office Manager Info from
      *   various tables that store the related information
      *   for an agent.
      *
      *
      * --------------------------------------------------------
      */
    SELECT           
         NVL(MD.OFFC_TERR_CD, NVL(OCM.OFFC_TERR_CD, NVL(TVP.OFFC_CD, COS.OFFC_CD))) OFFC_CD,
         MD.IONS_ID      MD_IONS_ID, 
         MD.ASSOC_NAME      MD_NAME, 
         MD.ASSOC_EMAIL_ID      MD_EMAIL_ID, 
         OCM.IONS_ID      OCM_IONS_ID, 
         OCM.ASSOC_NAME      OCM_NAME, 
         OCM.ASSOC_EMAIL_ID      OCM_EMAIL_ID, 
         OCC.IONS_ID      OCC_IONS_ID, 
         OCC.ASSOC_NAME      OCC_NAME, 
         OCC.ASSOC_EMAIL_ID      OCC_EMAIL_ID,
         TVP.IONS_ID      TVP_IONS_ID, 
         TVP.ASSOC_NAME      TVP_NAME, 
         TVP.ASSOC_EMAIL_ID      TVP_EMAIL_ID, 
         COS.IONS_ID      TVP_COS_IONS_ID, 
         COS.ASSOC_NAME      TVP_COS_NAME, 
         COS.ASSOC_EMAIL_ID      TVP_COS_EMAIL_ID,
         NVL(MD.TERR_DESC, NVL(OCM.TERR_DESC, NVL(TVP.TERR_DESC, COS.TERR_DESC))) TERR_NAME
    FROM 
    (     SELECT 
              DISTINCT OFFC_TERR_CD, 
              TC.TERR_DESC, 
              FMA.IONS_ID, 
              OTC.OFFC_CD, 
              FMA.ASSOC_NAME, 
              FMA.ASSOC_EMAIL_ID 
         FROM OBR.IFT_IONS_OFFC_TERR IOT, 
                             OBR.IFT_OFFC_TERR_CD OTC, 
                             OBR.IFT_FLD_MGMT_ASSOC FMA, 
                             OBR.IFT_TERR_CD TC 
         WHERE IOT.OFFC_TERR_CD = OTC.TERR_CD 
                    AND ROLE_CD='TVP' 
                    AND IOT.OBR_ASSOC_ID = FMA.OBR_ASSOC_ID
                    AND TC.TERR_CD = OTC.TERR_CD) TVP
    FULL OUTER JOIN
    (     SELECT           
              DISTINCT OFFC_TERR_CD, 
              TC.TERR_DESC, 
              FMA.IONS_ID, 
              OTC.OFFC_CD, 
              FMA.ASSOC_NAME, 
              FMA.ASSOC_EMAIL_ID 
         FROM OBR.IFT_IONS_OFFC_TERR IOT, 
                             OBR.IFT_OFFC_TERR_CD OTC, 
                             OBR.IFT_FLD_MGMT_ASSOC FMA, 
                             OBR.IFT_TERR_CD TC 
         WHERE IOT.OFFC_TERR_CD = OTC.TERR_CD 
                    AND ROLE_CD='COS' 
                    AND IOT.OBR_ASSOC_ID = FMA.OBR_ASSOC_ID
                    AND TC.TERR_CD = OTC.TERR_CD) COS
    ON TVP.OFFC_CD = COS.OFFC_CD
    FULL OUTER JOIN 
    (     SELECT           
              DISTINCT OFFC_TERR_CD, 
              TC.TERR_DESC, 
              FMA.IONS_ID, 
              FMA.ASSOC_NAME, 
              FMA.ASSOC_EMAIL_ID 
         FROM OBR.IFT_IONS_OFFC_TERR IOT, 
                             OBR.IFT_OFFC_TERR_CD OTC, 
                             OBR.IFT_FLD_MGMT_ASSOC FMA, 
                             OBR.IFT_TERR_CD TC 
         WHERE IOT.OFFC_TERR_CD = OTC.OFFC_CD 
                    AND ROLE_CD='OCC' 
                    AND IOT.OBR_ASSOC_ID = FMA.OBR_ASSOC_ID 
                    AND OTC.TERR_CD = TC.TERR_CD) OCC
    ON TVP.OFFC_CD = OCC.OFFC_TERR_CD
    FULL OUTER JOIN 
    (     SELECT 
              DISTINCT OFFC_TERR_CD, 
              TC.TERR_DESC, 
              FMA.IONS_ID, 
              FMA.ASSOC_NAME, 
              FMA.ASSOC_EMAIL_ID 
         FROM OBR.IFT_IONS_OFFC_TERR IOT, 
                             OBR.IFT_OFFC_TERR_CD OTC, 
                             OBR.IFT_FLD_MGMT_ASSOC FMA, 
                             OBR.IFT_TERR_CD TC 
         WHERE IOT.OFFC_TERR_CD = OTC.OFFC_CD 
                    AND ROLE_CD='OCM' 
                    AND IOT.OBR_ASSOC_ID = FMA.OBR_ASSOC_ID 
                    AND OTC.TERR_CD = TC.TERR_CD) OCM
    ON TVP.OFFC_CD = OCM.OFFC_TERR_CD
    FULL OUTER JOIN
    (     SELECT 
              DISTINCT OFFC_TERR_CD, 
              TC.TERR_DESC, 
              FMA.IONS_ID, 
              FMA.ASSOC_NAME, 
              FMA.ASSOC_EMAIL_ID 
         FROM OBR.IFT_IONS_OFFC_TERR IOT, 
                             OBR.IFT_OFFC_TERR_CD OTC, 
                             OBR.IFT_FLD_MGMT_ASSOC FMA, 
                             OBR.IFT_TERR_CD TC 
         WHERE IOT.OFFC_TERR_CD = OTC.OFFC_CD 
                    AND ROLE_CD='MD' 
                    AND IOT.OBR_ASSOC_ID = FMA.OBR_ASSOC_ID 
                               AND OTC.TERR_CD = TC.TERR_CD) MD 
    ON TVP.OFFC_CD = MD.OFFC_TERR_CD
    ORDER BY 2;
    Some history: previously, we had a table IFT_OFFC_MGR_INFO store information from each office and the details of MD, CMO, PST etc each office has a line with name, email, and id of MD, CMO, PST and COS. Since it wasn't standard if we standardized it for new extensions of office associates by creating several tables. Since we use this non standard table IFT_OFFC_MGR_INFO in various places and to minimize the impact, we have created this point of view that would return results in a similar format, as it was in this table. We found that some of the existing views with IFT_OFFC_MGR_INFO and replacing with new view that ifv_offc_mgr_info hung just this point of view. I don't know if there is no best approach to create this view so that it can return the result in a similar format as table not standardized. This table has generally only 50 odd lines. Please help me to solve this problem of production!

    Hello

    All those FULL of the EXTERNAL JOINTS are going to be slow.
    It seems that all the subqueries in the FULL OUTER JOIN are the same, except that each of them is limited to a single role_cd. In this case, it would be preferable to simply rotate your ITO the form table you want that it:

    WITH     universe     AS
    (
         SELECT
              DISTINCT OFFC_TERR_CD,
              TC.TERR_DESC,
              FMA.IONS_ID,
              OTC.OFFC_CD,
              FMA.ASSOC_NAME,
              FMA.ASSOC_EMAIL_ID,
              ROLE_CD                                   -- added
         FROM OBR.IFT_IONS_OFFC_TERR IOT,
                             OBR.IFT_OFFC_TERR_CD OTC,
                             OBR.IFT_FLD_MGMT_ASSOC FMA,
                             OBR.IFT_TERR_CD TC
         WHERE IOT.OFFC_TERR_CD = OTC.TERR_CD
                    AND ROLE_CD IN ('TVP', 'COS', 'OCC', 'OCM', 'MD')     -- All role_cds of interest
                    AND IOT.OBR_ASSOC_ID = FMA.OBR_ASSOC_ID
                    AND TC.TERR_CD = OTC.TERR_CD
    )
    SELECT       offc_terr_cd          AS offc_cd,
           MAX (CASE WHEN role_cd = 'MD'  THEN ions_id          END)       AS md_ions_id,
           MAX (CASE WHEN role_cd = 'MD'  THEN assoc_name     END)       AS md_name,
           MAX (CASE WHEN role_cd = 'MD'  THEN assoc_email_id     END)       AS md_email_id,
           MAX (CASE WHEN role_cd = 'OCM' THEN ions_id          END)       AS ocm_ions_id,
    ...
           MAX (CASE WHEN role_cd = 'COS' THEN assoc_email_id     END)       AS tvp_cos_email_id,
           MAX (terr_desc)                                         AS terr_name
    FROM       universe
    GROUP BY  offc_terr_cd
    ;
    

    That's assuming that this terr_desc is dependent on offc_terr_cd. If this isn't the case, then the expression for computing, it will be a bit more complicated. In this case, after a few sample data and the results you need from these data.

  • CREATE or REPLACE 2 dependent object types

    I have the task to create or replace the 2 types of dependent object, i.e.

    CREATE or REPLACE TYPE myObject AS OBJECT
    (
    name varchar2 (200),
    Age number
    )

    CREATE or REPLACE TYPE myObjectTable IS TABLE OF myObject
    /

    If I run these two statements, the first time, they are very good.
    If I run them again they do not
    ORA-02303: cannot drop or replace a type load type or table.
    The reason is clear: myObjectTable depends on myObject

    If I now inserts a DROP TYPE myObjectTable before these 2 instructions, they work very well, because the myObjectTable of the object exists.
    But if these 3 instructions are now executed from scratch they deliver the error ORA-04043: myObjectTable of the object does not exist.

    Now I need a solution that can deal with two situations:
    A. types already exist
    B. types do not yet exist

    Is there a way to DROP TYPE something and remove the error "object does not exist"?
    Is it possible to use CREATE or REPLACE and use something like a 'FORCE' option to remove the dependency problems?

    Thank you
    Frank

    You can remove your ora-04043 following this approach:

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:286816015990 #51943736724660

    !! Don't forget: the example is on a TABLE, you have an OBJECT, where a different error code!

      object_does_not_exist exception;
      pragma exception_init( object_does_not_exist, -4043 );
    
  • TDMS Create or Replace returns an error

    This example using FPGA (towards the end of the page):

    http://zone.NI.com/DevZone/CDA/tut/p/ID/11198#toc4

    Step #26 under FPGA section implements the open or create TDMS files.

    It always returns error #7 of the PDM create or replace VI.  When you create a new file, it should not return error "file not found".

    You are receving error 7 the path of the file that you specify. Make sure you use the correct path to the file. If you still have problems is an article in the knowledge base that may shed more light on what goes wrong.

    http://digital.NI.com/public.nsf/allkb/BBCAD1AB08F1B6BB8625741F0082C2AF?OpenDocument

    Kind regards

    David has.

  • Hello all, I need help with creating a dynamic region in jdeveloper 11.1.2.3 version

    . Hello everyone, I need help with creating a dynamic region in jdeveloper 11.1.2.3 version

    What JDK you are using?

    You are probably using an old version of the JDK, that class while compiled under JDK 1.7.0

    http://java67.blogspot.com/2012/10/how-to-fix-javalangunsupportedclassversionerror-major-minor-version-49-50-51.html

    For example, work with the correct version, and it will be fine...

  • Create or replace Index supported?

    I could type "create or replace index...". "and found that it worked.  Then I went looking for it or not "or replace" is supported the option for 'create index' and can't find anything that tells me that it is.  I don't want to use it if it is not supported.  Anyone know?  I'm using Oracle Database 11 g Release 11.2.0.3.0.

    Thank you

    Meredith

    There are some RDBMS that support certain types of logic for the index - but Oracle is not among them. CREATE or REPLACE can be used for certain types of objects, but not for the index.

  • Where is stored the packagebody create or replace?

    Friends,

    anyone can clear this doubt pls?...
    write, create or replace packagebody in the sql * more will be stored in the database.
    But if I write this account create or replace packagebody in the forms where it will be stored?
    It will store in the database or in the temporary memory?

    Thank you

    The values are stored in the memory of duration of forms, on the application server.
    When you exit forms, PL/SQL code is deleted form the forms runtime memory.

    François

Maybe you are looking for