Synonym for sequence.nextval

Hi all,
I have an error on this
Error(48,48): PL/SQL: ORA-02287: sequence number not allowed here
SELECT MAX (capacity_id_seq) - capacity_id_seq.NEXTVAL
INTO lv_new_importmaxrecord
FROM capacity_current;
Shoud I create a public synonym for this??to solve this...

SQL>
SQL> drop table t;
Table dropped.
SQL> drop sequence t_seq;
Sequence dropped.
SQL> create table t (x) as
select rownum from all_objects
where rownum <= 1000;
Table created.
SQL>
SQL> create sequence t_seq;
Sequence created.
SQL>
declare
  n number;
begin
  select max(x) - t_seq.nextval
  into n
  from t;
  dbms_output.put_line(n);
end;
  select max(x) - t_seq.nextval
ERROR at line 4:
ORA-06550: line 4, column 25:
PL/SQL: ORA-02287: sequence number not allowed here
ORA-06550: line 4, column 3:
PL/SQL: SQL Statement ignored
SQL>
SQL> set serveroutput on size 1000000
SQL>
declare
  n number;
begin
  select maxn - t_seq.nextval
  into n
  from (select max(x) as maxn from t);
  dbms_output.put_line(n);
end;
999
PL/SQL procedure successfully completed.
SQL>
SQL>pratz

Similar Messages

  • Synonym for Sequence e grant to other user

    Hola,
    I have two user
    AAA e BBB
    In AAA I have this sequence SQ_NUMEAVVI
    I create in BBB user
    CREATE SYNONYM SQ_NUMEAVVI_AAA FOR AAAA.SQ_NUMEAVVIAnd from sql connection of user BBB I haven't problem to see this sequence, but when I compile this function
    CREATE OR REPLACE  FUNCTION F_CALCNUMEAVVISEQU (VC_USER IN VARCHAR2)
    RETURN varchar2 IS
         VC_NUMEAVVI             VARCHAR2(15);
    BEGIN
         SELECT      DECODE((SELECT CODI_TIPO_UTEN FROM ANAGUTEN WHERE NOME_UTEN = upper(ltrim(rtrim(VC_USER)))),10,'C',11,'R',12,'S',13,'D','C')||SQ_NUMEAVVI_AAA.NEXTVAL
         INTO      VC_NUMEAVVI
               FROM      DUAL;
    RETURN(VC_NUMEAVVI);
    EXCEPTION
         WHEN OTHERS THEN
         RETURN(1);
    END;
    /I have the error "The sequence doesn't exist"
    Do you have to give a grant to this sequence from AAA to BBB?
    And How can do?
    Thank's!!
    Paolo

    GRANT SELECT ON SQ_NUMEAVVI TO BBB;SY.

  • Deleted synonyms for sequences when checking catalog

    Hi forum,
    we are using community version 7.6.06.03 on Linux 64bit (yes - it's rather old, but still working well). There we have created some sequences for db user A and added grants to db user B. User B works with own synonyms on the sequences of user A (needed for generic application). Running "dbmcli ... db_execute check catalog" gives a warning about inconsistencies. Same command plus additional "... with update" deletes the synonyms from user B and removes the inconsistencies.
    How to reproduce:
    1. dbuserA: create sequence seq1
    2. dbuserA: grant select on seq1 to dbuserB
    3. dbuserB: create synonym dbuserB.ownseq1 for dbuserA.seq1
    4. dbmcli ... db_execute check catalog with update
    => synonyms from step 3 are deleted (at new db sessions)
    Is this a false construct in our structure, a wrong usage of a command or maybe an error in maxdb? I've found the command "check catalog [with update]" only in this forum, but not in the official documentation of 7.6.
    BTW: Version 7.6.06.10 shows the same behaviour.
    Regards,
    Thomas

    Hi Thomas,
    I was able to reproduce this even with 7.7.06 Build 15.
    OK - wild guess: in SAP we don't make use of cross-schema synonyms on MaxDB.
    So, maybe this awkward little part of the catalog check had been created before there was something like SCHEMAs in MaxDB (say. before 7.5).
    Back then, a non-public synonym not belonging to the same schema would have been a inconsistency (well, likely).
    I tried to use public synonym instead - that works (that is, the check doesn't delete them).
    Hope that helps a bit.
    regards,
    Lars

  • Error In Adadmin Re-Create Grants And Synonyms For Apps Schema

    HI,
    I upgraded the my DB from 9.2.6 to 10.2.4.It was sucessfull.
    While doing Postupgradayion steps -
    Recreate grants and synonym for apps
    a. Log in to server with applmgr user
    b. Execute adadmin
    c. Choose -> Maintain Applications Database Entities menu
    d. Choose -> Re-create grants and synonyms for APPS schema
    2 workers got failed ...
    i chked the worker log file i found
    sqlplus -s APPS/***** @/stageAPP/stageappl/ad/11.5.0/admin/sql/adappsgs.pls &systempwd 1 PO APPLSYS APPS TRUE FALSE TRUE
    Connected.
    old 2: ad_apps_private.create_grants_and_synonyms(&2,'&3','&4','&5','FALSE');
    new 2: ad_apps_private.create_grants_and_synonyms(1,'PO','APPLSYS','APPS','FALSE');
    begin
    ERROR at line 1:
    ORA-20000: ORA-00955: name is already used by an existing
    object:create_grants_and_synonyms(1,PO,APPLSYS,APPS): create_base_gs(PO,APPS):
    In Synonyms
    Loop:create_synonym(PO,XXGOD_SEQ_DECORTIMESHEET_HDR,APPS,XXGOD_SEQ_DECORTIMESHEE
    T_HDR): do_apps_ddl(APPS,CREATE SYNONYM "XXGOD_SEQ_DECORTIMESHEET_HDR" FOR
    PO."XXGOD_SEQ_DECORTIMESHEET_HDR"):
    ORA-06512: at line 5
    Workaround $adctrl
    Control
    Worker Code Context Filename Status
    1 Run Grants/Synonyms R115 adappsgs.pls FAILED
    2 Run Grants/Synonyms R115 Wait
    3 Run Grants/Synonyms R115 Wait
    4 Run Grants/Synonyms R115 Wait
    5 Run Grants/Synonyms R115 Wait
    6 Run Grants/Synonyms R115 Wait
    7 Run Grants/Synonyms R115 Wait
    8 Run Grants/Synonyms R115 Wait
    9 Run Grants/Synonyms R115 Wait
    10 Run Grants/Synonyms R115 Wait
    11 Run Grants/Synonyms R115 Wait
    12 Run Grants/Synonyms R115 Wait
    13 Run Grants/Synonyms R115 Wait
    14 Run Grants/Synonyms R115 Wait
    15 Run Grants/Synonyms R115 Wait
    16 Run Grants/Synonyms R115 Wait
    SQL> select owner, object_type from dba_objects where object_name = 'XXGOD_SEQ_DECORTIMESHEET_HDR';
    OWNER OBJECT_TYPE
    PO SEQUENCE
    APPS SEQUENCE
    Its Cutom Object .. I think i need to drop/rename anyone .. which one i should drop / rename .
    Or
    Is it possible to skip the failed workers .. if do .. please give me the steps ...
    Thanks

    Hi;
    There is 8 option(hidden) avaliable but i suggest dont use this option.(As you mention its a custom,if you belive it wont problem you can use this hidden option or drop 'XXGOD_SEQ_DECORTIMESHEET_HDR' and recreate it later,its own your risk) By the way please check below notes which is similar error like yours
    Run Adadmin To Recreate Grants And Synonyms ORA-20000 ORA-00955 In Synonyms Loop:create_synonym(GL,PLAN_TABLE,APPS,PLAN_TABLE) [ID 437714.1]
    ADADMIN MAINTAINING APPLICATIONS GRANTS AND SYNONYMS APP-931 ORA-955 ORA-20000 [ID 1014455.102]
    Regard
    Helios

  • Synonyms of sequences not shown in Database-studio 7.7.06.09.

    We use two databaseschema's OWNER + USER.
    We create the tables and sequences as OWNER.
    We grant the tables and sequences as schema-user OWNER to the schema-user USER.
    Then as schema-user we create a synonym for every table and sequence which belongs to the schema-user OWNER.
    Now when i look in the Database-studio (login as USER) i see in the map tables all the tables from the OWNER-schema.
    But i don't see the sequences in the map Sequences.
    My question is why ?

    Hello,
    Please change the Database Studio preferences:
    Window->Preferences->Database Studio->Show only own catalog objects.
    Best Regards
       Wolfgang
    Edited by: Wolfgang Auer on Feb 15, 2010 4:42 PM

  • Insert Select sequence.nextval Problme

    Hi,
    I am trying to insert records in the table using query similar to
    insert into table1 (id, col1, col2)
    select
    sequence.nextval
    t1. col1, t1.col2
    from table t1;
    I am getting following error
    ORA-02287: sequence number not allowed here
    Will you please let me know how to resolve this?
    Regards
    ~Pravin

    Hmm...
    See here ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>
    satyaki>create table ff_gg
      2      (
      3        a_col   number(5),
      4        b_col   varchar2(30)
      5      );
    Table created.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>create sequence dd_qq
      2     start with 1
      3     increment by 1;
    Sequence created.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>insert into ff_gg
      2     select rn, ename
      3     from (
      4            select dd_qq.nextval, ename
      5            from emp
      6          );
              select dd_qq.nextval, ename
    ERROR at line 4:
    ORA-02287: sequence number not allowed here
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  insert into ff_gg
      2     select dd_qq.nextval rn, ename
      3     from (
      4            select ename
      5            from emp
      6*         )
    satyaki>/
    12 rows created.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>select * from ff_gg;
         A_COL B_COL
             1 WARD
             2 MARTIN
             3 SCOTT
             4 KING
             5 TURNER
             6 ADAMS
             7 JAMES
             8 FORD
             9 MILLER
            10 Smith
            11 Glen
         A_COL B_COL
            12 boock
    12 rows selected.
    Elapsed: 00:00:00.00
    satyaki>Got me?
    Regards.
    Satyaki De.

  • Top 5 queries  - One of them is sequence.nextval from dual !!!!!

    Hi All,
    I am using ORACLE DATABASE 11g and Oracle Linux 5.
    My intentions are to get the top resource consuming or time consuming queries from database in the particular time frame. I formed the below query to get the same :-
    select a.SQL_FULLTEXT,
                 s.module,
                 s.cpu_time_total / 1000000,
                 s.iowait_total / 1000000,
                 s.fetches_total,
                 s.sorts_total,
                 s.executions_total,
                 s.loads_total,
                 s.disk_reads_total /
                 DECODE(s.executions_total, 0, 1, s.executions_total) reads_per_execution,
                 s.disk_reads_total,
                 s.direct_writes_total / 1024,
                 s.buffer_gets_total / 1204,
                 s.rows_processed_total,
                 s.elapsed_time_total / 1000000,
                 s.apwait_total / 1000000,
                 s.ccwait_total / 1000000,
                 s.plsexec_time_total / 1000000,
                 s.javexec_time_total / 1000000
            from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT h, v$sqlarea a
           where s.parsing_schema_name = 'ST'
             and s.executions_total != 0
             and s.snap_id = h.snap_id
             and a.SQL_ID = s.sql_id
             and h.begin_interval_time > '03-NOV-11 09.30.00.000 AM'
             and h.end_interval_time < ''03-NOV-11 12.30.59.999 PM'
             and rownum <= 5
           order by 15 desc;I assume that above query will give me top 5 sql or pl/sql queries which are consuming most resource or time. Please correct me if am wrong with the query.
    The surprising fact is that I got the below query as the top most resource consuming query :-
    SELECT REF_SEQ.NEXTVAL AS VAL FROM DUALI searched for all the code in the database and I was not able to find this line in any code. The fact is that this query should not take more than 1 second as we know that sequence nextval from dual table is very fast so, how can i get this as resource consuming query.
    The output is as follows :- ( I have modified the output to show all the facts in detail. Here you can see that it shows the execution time as 10.002467 Seconds. In real this will get execute in less than a second.)
    MODULE NAME := Banking
    TOTAL CPU TIME := 8.299744 Seconds.
    TOTAL IO WAIT TIME := .915287 Seconds.
    TOTAL RECORDS FETCHED := 41128 Rows.
    SORT OPERATION(S) := 0
    TOTAL NO. OF EXECUTION(s) := 41128 Times.
    TOTAL NO. OF TIME(S) OBJECT/QUERY LOADED/RELOADED := 5
    DATA READ PER EXECUTION := .002139661544446605718731764248200739155806 KB.
    TOTAL DISK READS := 88 KB.
    TOTAL DISK WRITES := 0 KB.
    TOTAL BUFFER READS := 4.92441860465116279069767441860465116279 KB.
    TOTAL NO. OF ROW(S) PROCESSED := 41128
    TOTAL EXECUTION TIME FOR ONE TRANSACTION := 10.002467 Seconds.
    APPLICATION WAIT TIME := 0 Seconds.
    CONCURRENCY WAIT TIME := .344575 Seconds.
    PL/SQL EXECUTION TIME := 0 Seconds.
    JAVA EXECUTION TIME := 0 Seconds.Please guide me for this method. How to understand the presence of this sequence.nextval query here.
    The base requirement is I want a query which will give me top 5 resource/time consuming queries. I have took the help of AWR views in my logic. If you have any better idea let me know.
    Thanks in advance.

    Try this
    select *
    from
    select a.SQL_FULLTEXT,
                 s.module,
                 s.cpu_time_total / 1000000,
                 s.iowait_total / 1000000,
                 s.fetches_total,
                 s.sorts_total,
                 s.executions_total,
                 s.loads_total,
                 s.disk_reads_total /
                 DECODE(s.executions_total, 0, 1, s.executions_total) reads_per_execution,
                 s.disk_reads_total,
                 s.direct_writes_total / 1024,
                 s.buffer_gets_total / 1204,
                 s.rows_processed_total,
                 s.elapsed_time_total / 1000000,
                 s.apwait_total / 1000000,
                 s.ccwait_total / 1000000,
                 s.plsexec_time_total / 1000000,
                 s.javexec_time_total / 1000000
            from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT h, v$sqlarea a
           where s.parsing_schema_name = 'ST'
             and s.executions_total != 0
             and s.snap_id = h.snap_id
             and a.SQL_ID = s.sql_id
             and h.begin_interval_time > '03-NOV-11 09.30.00.000 AM'
             and h.end_interval_time < '03-NOV-11 12.30.59.999 PM'
             order by 15 desc
    )where rownum <= 5

  • Sequence nextval reset at every month with 1

    I want to change Sequence Nextval = 1 at every month
    I m using this sequence
    create sequence VoucherNo
    minvalue 1
    maxvalue 9999999
    start with 1
    increment by 1
    Order;i want then when start next month sequence nextval should be 1 .
    reset with 1.

    Dont't recreate the sequence! You would invalidate all independent objects and lose all privileges granted for the sequences.
    Instead try this:SQL>CREATE SEQUENCE SEQ_TEST
      2   START WITH  1
      3   INCREMENT BY  1
      4   MINVALUE  1
      5   MAXVALUE  9999999;
    Sequence created.
    SQL>
    SQL>SELECT SEQ_TEST.NEXTVAL
      2    FROM all_objects WHERE ROWNUM < =10;
       NEXTVAL
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.
    SQL>
    SQL>DECLARE
      2     Val   NUMBER;
      3  BEGIN
      4     SELECT SEQ_TEST.CURRVAL
      5       INTO Val
      6       FROM DUAL;
      7
      8     EXECUTE IMMEDIATE 'ALTER SEQUENCE SEQ_TEST INCREMENT BY ' || TO_CHAR(1 - Val);
      9
    10     SELECT SEQ_TEST.NEXTVAL
    11       INTO Val
    12       FROM DUAL;
    13
    14     EXECUTE IMMEDIATE 'ALTER SEQUENCE SEQ_TEST INCREMENT BY 1';
    15
    16     DBMS_OUTPUT.put_line('New value of SEQ_TEST is ' || TO_CHAR(Val));
    17  END;
    18  /
    New value of SEQ_TEST is 1hth, Urs

  • Sequence nextval jumps by 20

    Always wondered about this. Why does a sequence nextval sometimes jump by 20 from the previous val when the increment is 1? Ever see this before?

    Technically, I cannot think of one. The locking implications would be really unfortunate. Often, this is put in as a "requirement" to fulfill some perceived legal or accounting issue (i.e. all Purchase Order numbers accounted for) but it's usually possible & appropriate for the technical folks to push back-- 99% of the time there are other technical options that are far friendlier and more scalable that solve the underlying issue.
    Justin

  • Create a public synonym for a db link - "Connection desccriptor not found".

    I want to create a public synonym for a db link.
    The existing db link name is tst.world ( which is in db links table and is working fine).
    I created the following db link using the following command:
    create public synonym "syn.world" for "tst.world";
    It created the synonym successfully.
    If I try the following, it throws error "Connection desccriptor not found".
    select * from [email protected];
    It says "Connection desccriptor not found".
    Any suggestions.
    Thanks in Advance.

    Well then, lookup the Documentation on the CREATE SYNONYM statement in the SQL Language Reference manual.
    The documentation lists the types of objects which you can create synonyms for.
    You can create synonyms for objects referenced across DBLinks.
    You cannot create synonyms for DBLinks.
    Hemant K Chitale

  • Error while running Re-create grants and synonyms for APPS schema

    Hi,
    I have upgraded customer's Oracle Apps 11i (11.5.10) database to Oracle 10g R2. While executing '+Re-create grants and synonyms+ ' as given in Note: 362203.1, I am gettng error:
    plus80 -s APPS/***** @E:\EBSTEST\ebstestappl\ad\11.5.0\admin\sql\adappsgs.pls &systempwd 1 INV APPLSYS APPS TRUE FALSE TRUE
    Error:
    Program exited with status 3
    Cause: The program terminated, returning status code 3.
    Action: Check your installation manual for the meaning of this code on this operating system.Connected.
    old 2: ad_apps_private.create_grants_and_synonyms(&2,'&3','&4','&5','FALSE');
    new 2: ad_apps_private.create_grants_and_synonyms(1,'INV','APPLSYS','APPS','FALSE');
    begin
    *+
    ERROR at line 1:
    ORA-20000: ORA-00955: name is already used by an existing
    object:create_grants_and_synonyms(1,INV,APPLSYS,APPS): create_base_gs(INV,APPS): In Synonyms
    Loop:create_synonym(INV,MTL_ONHAND_DISCREPANCY,APPS,MTL_ONHAND_DISCREPANCY):
    do_apps_ddl(APPS,CREATE SYNONYM "MTL_ONHAND_DISCREPANCY" FOR INV."MTL_ONHAND_DISCREPANCY"):
    ORA-06512: at line 5
    MTL_ONHAND_DISCREPANCIES
    I checked the database and there isn't MTL_ONHAND_DISCREPANCY synonym. But there is MTL_ONHAND_DISCREPANCIES synonym.
    This is an upgraded instance from 11.0.3 and first time I am running Re-create grants and synonyms for APPS schema.
    Plz let me know if anyone of you faced this issue.
    Rgds,
    Thiru

    Hi,
    there is no such table MTL_ONHAND_DISCREPANCY or synonym in Applications 11.5.10.2. Is that custom table created in your db?
    After dropping this table from APPS schema 'Re-create grants and synonyms for APPS schema' went thru fine.Its correct
    This table does not exist in INV schema in 11.5.10.2.
    Could be possible that the consultant could have created this table in INV and APPS schema by mistake or whatever.Yes, with the same name, there might be table in APPS SCHEMA. When you run recreate grants and synonyms, adadmin tries to create synonym for that table in APPS schema. since there is object available with the same name in apps chema, you got that error.

  • Creating SYNONYM for all tables who don't have one at once!

    Hello to all,
    I'm trying to create synonyms for every table who's missing one at the moment. I'm trying this code:
    declare
    cursor cur_objects is
    select obj.object_name , obj.owner
    from all_objects obj
    where owner = '&&SCHEMA_OWNER'
    AND NOT EXISTS (SELECT *
    FROM all_synonyms syn
    WHERE obj.object_name = syn.table_name)
    AND obj.object_type = 'TABLE'
    AND obj.object_name LIKE 'CI_%';
    begin
    for rec_objects in cur_objects loop
    begin
    dbms_output.put_line(rec_objects.object_name);
    execute immediate('create public synonym ' || rec_objects.object_name || ' for '
    || rec_objects.owner ||'.'||rec_objects.object_name )
    exception when others then
    null;
    end;
    end loop;
    end;
    I'm getting this error:
    ORA-06550: line 10, column 37:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    begin function package pragma procedure subtype type use
    <een ID>
    <een scheidingsteken-ID tussen dubbele aanhalingstekens> form
    current cursor
    I'm still pretty new at PL/SQL and can't get it to work. Does anyone got any tips ?
    Thnx already

    Ok now I got this error:
    RA-06550: line 17, column 1:
    PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
    * & = - + ; < / > at in is mod remainder not rem return
    returning <een exponent (**)> <> or != or ~= >= <= <> and or
    like LIKE2_ LIKE4_ LIKEC_ between into overlaps using ||
    multiset bulk year DAY_ member SUBMULTISET_
    The symbol ";" was substituted for "EXCEPTION" to continue.

  • Script to create grants and synonyms for objects in database

    Hello,
    We are building a patch to be applied to the production environment. I want to create a script/sql query that builds a list of grants and synonyms for all the objects created after august 09.
    for ex:
    create or replace synonym abc for schema_name.abc;
    Grant execute on abc to user_xyz;
    How can I use Oracle's data dictionary to do this?
    thankz

    Hi,
    You'll probably want to use these views:
    user_objects - includes created (DATE) column.
    user_synonyms
    user_tab_privs - not just tables (e.g., includes EXECUTE privileges on functions).
    Data dictionary views beginning with 'user_' cover objects owned by the current user only.
    Almost all of the data dictionary views (and all of the three mentioned above) also have 'all_' and 'dba_' versions.
    For example:
    all_objects inculdes everything in user_objects, plus objects in other schemas on which the current user has privileges.
    dba_objects include every object in the database. (Not everyone is allowed to see the dba_ views.)
    Here's one of many possible ways to use these views:
    SELECT     'GRANT '
    ||     privilege
    ||     ' ON "'
    ||     table_name
    ||     '" TO '
    ||     grantee
    ||     CASE
              WHEN  grantable = 'YES'
              THEN  ' WITH GRANT OPTION;'
              ELSE  ';'
         END
    FROM     user_tab_privs
    WHERE     table_name  IN (          -- Only interested in objects created after August 9
                     SELECT  object_name
                     FROM    all_objects
                     WHERE   created >= TO_DATE ( '10-Aug-2009'
                                                           , 'DD-Mon-YYYY'
    ;

  • View + stored function + synonym for other user

    Dear All!
    I've got a quite strange problem which I cannot decide whether it's caused by my lack of knowledge on the appropriate topic or by an Oracle bug. I'm already after some heavy googling on the topic and I was unable to track any valuable answers neither in forums nor in the Oracle documentation. I'll try to be as short and specific as possible.
    Database: Oracle 10g
    Result of "SELECT BANNER FROM V$VERSION":
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    "CORE     10.2.0.4.0     Production"
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    I have two users in the database for a single Web application: UAPP01, which is the owner of application DB objects and UAPP02 which is the application user connecting to the DB. The application runs for quite many years by now and DB structure layout has always been following a simple logic: for each DB object used by the app. (tables, views, packages and stored procedures/functions) and found in the UAPP01 there exists a synonym in the UAPP02 schema. For the privileges to be set correctly a role is created: RL_MY_APPL which is granted the necessary privileges on objects of UAPP01 (CRUD on tables, SELECT on views, EXECUTE on procedures, etc..). This role is granted to UAPP02.
    In the previous days I was about to extend the DB with a view that invokes a stored function. This pattern has already occured in the DB previously so I kept following existing conventions: I've created the stored function and the view in the UAPP01 schema, granted SELECT on the view to RL_MY_APPL and created the synonym for it in the UAPP02 schema. This is where the entire functionality began to act strange. I'll try to explain with a simplified example that was sufficient to reproduce the problem:
    REM ========================================
    REM Execute below code as UAPP01 user.
    REM ========================================
    REM Test function.
    CREATE OR REPLACE FUNCTION testfunction(p_param NUMBER) RETURN NUMBER IS
    BEGIN
    RETURN p_param *2;
    END;
    REM Testview version 1. causing trouble.
    CREATE OR REPLACE VIEW testview AS
    WITH testdata AS
    SELECT /*+ materialize*/ LEVEL AS d
    FROM dual CONNECT BY LEVEL <= 100
    SELECT a, b, c, SUM(d) AS sum_d
    FROM
    SELECT FLOOR(dbms_random.VALUE(1, 100)) a, FLOOR(dbms_random.VALUE(1, 100)) b, FLOOR(dbms_random.VALUE(1, 100)) c, testfunction(d) AS d
    FROM testdata
    GROUP BY CUBE(a, b, c)
    REM Testview version 2. not causing trouble.
    CREATE OR REPLACE VIEW testview AS
    SELECT a, b, c, SUM(d) AS sum_d
    FROM
    SELECT FLOOR(dbms_random.VALUE(1, 100)) a, FLOOR(dbms_random.VALUE(1, 100)) b, FLOOR(dbms_random.VALUE(1, 100)) c, testfunction(d) AS d
    FROM
    SELECT LEVEL AS d FROM dual CONNECT BY LEVEL <= 100
    GROUP BY (a, b, c)
    REM Synonym.
    CREATE OR REPLACE SYNONYM UAPP02.testview FOR UAPP01.testview;
    REM Grants.
    GRANT SELECT ON testview TO RL_MY_APPL;
    When creating TESTVIEW with the 1 ^st^ version I cannot query it using the UAPP02 user, I'm constantly getting the error: ORA-00904: : invalid identifier. However, when I use the 2 ^nd^ version everything runs perfectly. What is common in the two cases is that both versions use the TESTFUNCTION function. I have not granted the EXECUTE rights on TESTFUNCTION to the RL_MY_APPL since it was never needed previously (for other views using stored functions) and as far as I know it's not necessary (as both the view and the function are owned by UAPP01). The strange thing in the above behaviour is that the function is used by both versions, however only one of them fails. This is where I thought it's not a granting issue, otherwise neither of the versions would have worked and I think I would have received a different error stating that UAPP02 lacks the necessary privileges on underlying objects of the view.
    As I further digged into the problem by examining the EXPLAIN PLAN output for the two versions I found that version 1. leads to a TEMP TABLE TRANSFORMATION and to MULTI TABLE INSERTs, whereas version 2. simply executes the query without doing such things. In my setup I presume the MULTI TABLE INSERTs were caused by the GROUP BY CUBE. When I simply removed the CUBE and used only GROUP BY the TEMP TABLE TRANSFORMATION remained in place but the MULTI TABLE INSERTs disappeared. As a result of this small modification the view again began to work when I executed it through the synonym and using the UAPP02 user.
    With the original DB objects of our application the behaviour is even more strange: the error comes up if I select from the view and filter for a column that is grouped in the query whereas it works correctly if I filter for the aggregated columns. However, I couldn't reproduce this with the above simplified example.
    No problem occurs with any of the versions if I query the view using the UAPP01 user.
    This hectic behaviour made me suspect that the TEMP TABLE TRANSFORMATION + MULTI TABLE INSERT + synonym + stored function combo appears to bring a strange Oracle bug to the surface...
    As a final note: when executing GRANT EXECUTE ON TESTFUNCTION TO RL_MY_APPL everything works fine in all cases. I know I could simply live with this but I'd really like to get to the bottom of this. Although this extra GRANT appears to solve the problem I don't really trust it. I'd really like to avoid the bug emerging again in Production in case this extra GRANT were not sufficient due to some unknown misteries.
    Excuse me, the post has become a bit lengthy. Thanks in advance for anyone who's willing to read through and answer it!
    Regards,
    Krisztian Balazs Szaniszlo

    The error is thrown at run-time and only for the UAPP02 (second) user.
    The problem is that the appearance of errors is independent of whether the query contains the call to the stored function or not.
    So far I thought that if I use a stored function indirectly, like in this setup: UAPP02.synonym -> UAPP01.view -> UAPP01.stored function, then I don't need the grant. Of course, I understand that if I had used it directly, like :UAPP02.synonym -> UAPP01.stored function then I'd need the GRANT EXECUTE.
    Shall I just ignore the strange behaviour and go on by adding GRANT EXECUTE privilege on all the functions used indirectly through views? It seems to solve the problem, but this behaviour is disturbing me quite and I fear the real root cause of the problem can emerge later in a different fashion.

  • Script to create synonyms for the tables of Oracle Applications

    Team,
    For Oracle Applications 11i on W2K, where might I find a script to create synonyms for all of the application tables? I would think there would be a standard script somewhere in one of the directories created during the install or on the CDs.
    Thanks,
    Luther

    John, it is ssome sort of a bleed, but in this case it's not the part that 'might be cut off' that matters; it's the part that still needs to be on the page. Yes, I meant it to be (virtually) not-noticeable for the casual reader. Of course you can make it part of the page design, that ought to ease up matters.
    The amount pages shift horizontally because of binding is called "creep", and this depends on the type of binding and the thickness of the paper. You cannot adjust for creep unless you know exactly how much this is and how your book is going to be printed and bound.
    Airkite:
    But the book that you printed worked out alright? Was it done with a different method?
    This was a simple outlined text, not an image. Through the inaccuracies of printing and binding combined, there were no straight edges *anywhere* but fortunately the lines were thick enough to let you mentally connect them
    This was done (I'm sure) with the method you proposed.
    There is an alternative way, but it's way more expensive (on the other hand, the result is impressive): after the entire process of printing, binding, and cutting, books are put in a clamp one at a time and fed through a silk screen printer, fore edge on top, and printed with whatever you like.
    I know of the existance of this technique but I haven't seen a book done like this in years and have no clue at all of the costs involved (writing that down in one sentence makes me realize those two might be connected).

Maybe you are looking for

  • FIX for EPSON Print CD V2.02 - EPSON Stylus Photo R200 - MAC OS 10.5.9

    I thought I'd post this ridiculously long info sheet on what finally got my R200 to work with EPSON Print CD and 10.5.8 just in case it might help someone else BEFORE they spend days searching for a solution. Check the printer driver information in S

  • Need web browser plug in

    I need the quicktime browers plug in?

  • Mobile Phone to PC via Bluetooth

    I am investigating the posibility for a certain function for an application on a mobile phone. An Single Sign-On (SSO) application. This application is going to transmit its authentication data to the PC and cause the Web browser to open and log in t

  • Fluid layout question.

    I am working on a flash site with many scenes with movie clips, different clips but same size and same position. I just set up the layout using fluid with this function sizeListener.onResize = function() { centered._x = Stage.width/2 centered._y = St

  • Does adding V-Card to signature cause problems for Outlook (Windows) users?

    Hi - I want to add a V-Card to my signature in Apple Mail (by drag and drop from address book to signature pane in Mail>Preferences).  I have read that, in the past, this can caused problems for some recipients who use Windows Outlook. Is this still