DUAL Table problem

As a quick way to grant privileges to almost all the objects in my schema to a role, i created a procedure (Courtesy of user CD from Oracle Forums). But when i executed the below mentioned procedure i got the error :
ORA-01720: grant option does not exist for 'SYS.DUAL'
To avoid granting privileges to sys.dual, I tried adding AND OBJECT_NAME < > 'SYS.DUAL' and AND OBJECT_NAME < > 'DUAL' to the query. But that this didn't help.
But when i query SELECT * FROM DUAL; i can see that DUAL table exists in my schema.
Any thoughts?
Here is what i did
CREATE ROLE newrole;
DECLARE
v_sql VARCHAR2(4000);
BEGIN
FOR obj IN (SELECT object_name
, object_type
, DECODE (OBJECT_TYPE,
'PROCEDURE','EXECUTE',
'FUNCTION' ,'EXECUTE',
'PACKAGE' ,'EXECUTE',
'SYNONYM' ,'SELECT' ,
'SEQUENCE' ,'SELECT' ,
'MATERIALIZED VIEW','SELECT',
'SELECT, INSERT, UPDATE, DELETE') rights
FROM user_objects where object_type IN
('FUNCTION','PROCEDURE','PACKAGE','SYNONYM','SEQUENCE','MATERIALIZED VIEW','TABLE','VIEW'))
LOOP
v_sql := 'GRANT ' || obj.rights || ' ON ' || obj.object_name || ' TO NEWROLE';
dbms_output.put_line(v_sql);
EXECUTE IMMEDIATE v_sql;
END LOOP;
END;
/

One of your views must reference DUAL, perhaps indirectly.
If this comes up again you can create an exception to catch the error inside the loop for the current item and continue. Not pretty, but it should work something like (untested)
  for record in cursor loop
    --block to catch exception
    declare
       my_error exception;
      --substitute proper error number for -000001 below
      pragma exception_init(-000001,my_error)
    begin
    exception
      when my_error then
        null;
    end;
    --continue processing with next loop item   
  end loop;

Similar Messages

  • PLSQL Dual table problem

    Were having strange problems using ther dual tables as below:-
    selecting sysdate from dual via a sql session the results are returned as expected, but when placing the select sysdate from dual within a PLSQL block we seem to get booted out of the system, and lose the connection to oracle.
    Tried re-booting the database, had no impact.
    any ideas out there?
    Thanks.
    null

    Hey this is a very strange problem. anyway what i would suggest is to use the direct references of the system variables and avoid using DUAL.
    for example :
    datefield := sysdate;
    U assign the sysdate to variable. Like this u can do for sequence etc...
    Vijay
    null

  • Avoid Hard Parsing for executing dynamic SQL using DUAL table Oracle

    I want to know if dynamic sql statements involving DUAL table can be modified to remove HARD PARSING.
    We have several SQL statements are stored in configuration table, here is sample example
    -- query 1 before replacing index values as stored in config table ---
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_3' IN ('K')
    AND (('REPLACE_VALUE_OF_INDEX_13' IN ('1053','1095','1199') ) OR ('REPLACE_VALUE_OF_INDEX_13' IN ('1200') ))
    AND 'REPLACE_VALUE_OF_INDEX_2' IN ('6')
    AND 'REPLACE_VALUE_OF_INDEX_15' IN ('870001305')
    -- query 1 after replacing index values--
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_10' IN ('K')
    AND (('1030' IN ('1053','1095','1199') ) OR ('1030' IN ('1200') ))
    AND '2' IN ('6')
    AND 'X' IN ('870001305')
    -- query 2 before replacing index values as stored in config table --
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_5' IN ('361A','362A')
    AND 'REPLACE_VALUE_OF_INDEX_22' BETWEEN '200707' AND '200806'
    -- query 2 after replacing index values--
    select count(*) from dual where  '3MAA' IN ('361A','362A') AND '201304' BETWEEN '200707' AND '200806'

    If I got it right you have some (maybe lots of) conditions stored in a table (be patient - it's my interpretation)
    create table eb_conditions as
    select 1 rid,q'{:5 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'}' cndtn from dual union all
    select 2,q'{:2 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'}' from dual union all
    select 3,q'{:1 IN ('K') AND ((:2 IN ('1053','1095','1199') ) OR (:4 IN ('1200') )) AND :3 IN ('6') AND :5 IN ('870001305')}' from dual
    RID
    CNDTN
    1
    :5 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'
    2
    :2 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'
    3
    :1 IN ('K') AND ((:2 IN ('1053','1095','1199') ) OR (:4 IN ('1200') )) AND :3 IN ('6') AND :5 IN ('870001305')
    and you have to check the conditions using values stored in an array
    I used a table instead: the vl at rid = 1 representing the value of bind variable :1 in eb_conditions table and so on ...
    create table eb_array as
    select 1 rid,'K' vl from dual union all
    select 2,'1199' from dual union all
    select 3,'200803' from dual union all
    select 4,'1000' from dual union all
    select 5,'870001305' from dual
    RID
    VL
    1
    K
    2
    1199
    3
    200803
    4
    1000
    5
    870001305
    You want to check the conditions using select count(*) from dual where <condition with binds substituted fron the array>
    Judging from the title Hard Parsing represents the major problem and you cannot avoid it since every condition to be verified is different from every other condition.
    I think your best bet is not to evaluate conditions row by row - context shift cannot be avoided and there might be more than one for each iteration.
    So try to do it in a single step:
    declare
    w_cndtn varchar2(4000);
    w_clob  clob;
    w_cursor sys_refcursor;
    one number;
    two number;
    begin
      dbms_lob.createtemporary(w_clob,false);
      for rw in (select rid,
                        max(cndtn) cndtn,
                        listagg(val,',') within group (order by rn)||',' usng
                   from (select c.rid,c.cndtn,c.rn,c.bind,
                                replace(rtrim(c.bind),':'||to_char(v.rid),''''||v.vl||'''') val
                           from (select rid,
                                        cndtn,
                                        regexp_substr(cndtn,':\d+ ',1,level) bind,
                                        level rn
                                   from eb_conditions
                                 connect by level <= regexp_count(cndtn,':')
                                        and prior rid = rid
                                        and prior sys_guid() is not null
                                ) c,
                                eb_array v
                          where instr(c.bind,':'||v.rid||' ') > 0
                  group by rid
      loop
        w_cndtn := rw.cndtn;
        while instr(w_cndtn,':') > 0
        loop
          w_cndtn := replace(w_cndtn,trim(regexp_substr(w_cndtn,':\d+ ',1,1)),substr(rw.usng,1,instr(rw.usng,',') - 1));
          rw.usng := substr(rw.usng,instr(rw.usng,',') + 1);
        end loop;
        w_cndtn := 'select '||to_char(rw.rid)||' cndtn_id,count(*) from dual where '||w_cndtn||' union all ';
        w_clob := w_clob ||' '||w_cndtn;
      end loop;
      w_clob := substr(w_clob,1,instr(w_clob,'union all',-1,1) - 1);
      open w_cursor for w_clob;
      loop
        fetch w_cursor into one,two;
        exit when w_cursor%notfound;
        dbms_output.put_line(to_char(one)||':'||to_char(two));
      end loop;
      dbms_lob.freetemporary(w_clob);
    end;
    1:0
    2:0
    3:0
    Statement processed.
    Regards
    Etbin

  • Dual table in 10g

    Hi!
    1 am using forms 6.
    my forms were running good but after i take my application to 10g, some forms have not been compiling.
    in every form where dual table has been referenced error has come, remaining forms run well
    like
    select sysdate
    into l_Date
    from dual
    if in form i use sys.dual then it works
    in sql plus i can select using select * from dual
    is this a bug or any other problem?
    thanx

    error has comeGive us a clue. What error? Please post error number and message or at least describe the behaviour.
    Also, this is primarily a database forum. As your queries run in SQL*Plus it strikes me this is most likely to be a problem with Forms, and so you may be better off trying the OTN > Products > Developer Suite > Forms forum. Unlike this forum, actual Oracle employees answer questions there, so it's definitely a better bet.
    Are you using Forms 6 or 6i? Forms 6 is de-supported and so may not play nicely with 10g. 6i is supported and either is or will be certified to run against 10g.
    Cheers, APC

  • Multiple records in DUAL table

    Hi all,
    I am having a cow trying to work out how some rogue records got inserted into DUAL - thus totally stuffing the database.
    I am nearly 100% convinced that the records did not get there from someone running an INSERT INTO dual etc, but can there be any other alternative?
    Has anyone come across any instances of DUAL getting corrupted, or something as equally strange (but explainable) happening where multple records end up in DUAL.
    Thanks in advance

    Hi,
    I got a problem at dual table some time in 2002. If I issue select count(1) from dual, we are getting two rows seleted.
    sys@ezra> select rowid,dummy from dual;
    ROWID D
    AAAADdAABAAAAIVAAA X
    sys@ezra> select count(1) from dual;
    COUNT(1)
    2
    sys@ezra> select count(*) from dual;
    COUNT(*)
    2
    sys@ezra> select rowid,dummy from dual;
    ROWID D
    AAAADdAABAAAAIVAAA X
    sys@ezra> set feedback on
    sys@ezra> l
    1* select rowid,dummy from dual
    sys@ezra> /
    ROWID D
    AAAADdAABAAAAIVAAA X
    1 row selected.
    But finally managed to delete a row from dual table. Then it works for me. But still I don't know, how it is inserted into dual table.
    Best regards
    shan

  • Another dual display problem - GeForce FX 5200

    I've seen lots of questions about dual display problem, situation when trying to connect two non-apple vga displays to your graphic card.
    I have GeForce FX 5200 graphic card, with 2 display output's. And two DELL 17" vga LCD displays.
    I manage to connect 1 display regulary with dvi to vga converter, but for other display I tried several difrent converters ADC to DVI to VGA, and it just did NOT work.
    G5 could see other display in display settings, in arrange option I coud see two identical displays, but I don't get anu picture (desktop) on other display???
    Is it problem with output's on my graphic card (Gforce FX 5200), could it be soloved with some ADC to VGA converter?
    P.S. Dr. Bott ADC VGA Extractor is not compatible with GeForce FX 5200????
    G5 dual 2.1Ghz   Mac OS X (10.3.4)  

    I've seen lots of questions about dual display
    problem, situation when trying to connect two
    non-apple vga displays to your graphic card.
    I have GeForce FX 5200 graphic card, with 2 display
    output's. And two DELL 17" vga LCD displays.
    I manage to connect 1 display regulary with dvi to
    vga converter, but for other display I tried several
    difrent converters ADC to DVI to VGA, and it just did
    NOT work.
    This won't work if the ADC to DVI adapter is not passing through the analog signals needed for VGA.
    G5 could see other display in display settings, in
    arrange option I coud see two identical displays, but
    I don't get anu picture (desktop) on other
    display???
    Is it problem with output's on my graphic card
    (Gforce FX 5200), could it be soloved with some ADC
    to VGA converter?
    Yes.
    P.S. Dr. Bott ADC VGA Extractor is not compatible
    with GeForce FX 5200????
    It should work. On Dr. Botts web-site it says:
    "VGA Extractor is compatible with any video card with an ADC port in a PowerMac G5"

  • How to return number range from sql (dual table)

    in sql plus
    I need to display values (numbers)1 to 52 from dual
    eg,
    1
    2
    3
    4
    5
    etc...
    Is this possible, can you display a range of numbers from an sql statment without creating atble holding the required numbers.
    I am trying to display 1 to 52 (week numbers) but I need to do this from the dual table.
    Creating a table with values 1 to 52 looks like a waste?
    Thanks in anticipation.
    SD.

    If you're running on 9i you may find the solution I posted Re: List all days of a month in single SQL to be useful. Otherwise the general discussion will provide some illumination.
    Cheers, APC

  • Doubt in DUAL TABLE

    Hi,
    below is one query
    SQL> select * from dual;
    D
    XNow from the below Query I came to know that there is one field in the dual table DUMMY which is having VARCHAR2(1)
    SQL> desc dual;
    Name                                                  Null?    Type
    DUMMY                                                          VARCHAR2(1)now my doubt is when I run the below query how it is displaying text more than 1 character
    SQL> select 'how are you' from dual;
    'HOWAREYOU'
    how are youplease explain
    thanks in advance.

    Hi,
    What you are SELECTing here nas no relation to any column in the table.
    There's nothing special about the dual table regarding literals. Try
    SELECT  'Hello'
    FROM    scott.dept;Notice that scott.dept does not have any 5-character columns, yet a query on scott.dept is producing a 5-character column.
    When you query a table, you don't have to SELECT all of the columns in the table. In fact, you don't have to SELECT any of the columns in the table, as you demonstrated.
    The query you posted, like the query above, does not refer to any columns in its base table; it's not surprising that the output doesn't resemble any column in the base table. In the case of the query above, which is based on a table that has 3 columns, the one column that we are SELECTing can't have the characteristics of all 3 columns in the table. Which column do you think the output should resemble, and why? 'Hello' is the first column of output; does that mean it has to resemble the first column in the table, which happens to be defined as NUMBER (2)? 'Hello' is also the last column of output; does that mean it has to resemble the last column of the table? 'Hello' is directly in the center of the output; does that mean it has to resemble the column that happens to be in the middle of the table? Of course not!
    Once agian, it is perfectly legal, and sometimes extremely useful, to have columns in a result set that have no connection at all to any column in the table.

  • Select multiple rows from dual table

    Is it possible to select multiple rows from dual table using a single select statement.
    i.e., i want the out put to be
    column_name
    1
    2
    3
    4
    Edited by: vidya.ramachandra on Dec 14, 2009 8:24 AM

    Aside from the fact you're responding to an old thread...
    1002424 wrote:
    While using CONNECT BY, I see it always leave behind one row.
    Suppose I have a condition based on which I have to generate constant rows like
    SELECT 1 FROM DUAL WHERE ROWNUM < N;
    Here if N = 0, still it gives out single row.... you are obviously doing something wrong in your code elsewhere, because that SQL statement does not always return a single row...
    SQL> SELECT 1 FROM DUAL WHERE ROWNUM < 0;
    no rows selected
    SQL>

  • Sql query and dual table

    Hi,
    1. Do dual table take any physical space in the database or it is only logically present?
    2. Suppose a table contains 100 rows. Write a query to return 42,43,44 rows.
    Thanks,
    Mrinmoy

    user3001930 wrote:
    Hi,
    1. Do dual table take any physical space in the database or it is only logically present?Dual table is physically stored. But starting from 10g (I guess) they indroduced the FAST DUAL access path. Which means if you use the DUAL table not to get the value from the table and only to select a constant value then it will not hit the actually table.
    2. Suppose a table contains 100 rows. Write a query to return 42,43,44 rows.You can use the analytic function ROW_NUMBER for this purpose.

  • Autonomous Trigger / Mutating Table Problem

    We have a specific problem in one of our applications being developed where by the database needs to enforce a specific business requirement.
    We need to use a database trigger to enforce some data integrity which involves more than one table as such cannot use standard constraint. The integrity has to be maintained in the database as the DML statements may be coming from a Java application or PL/SQL code as such we need the logic all in one place.
    The problem being that within the trigger we need to examine the state of the table the trigger is associated with as well as one other table. Obviously using a trigger on a table that is being affected by DML statements causes the dreaded mutating table problem.
    One suggested solution to this was to make the trigger or the code the trigger called autonomous. This allows the trigger to execute by only showing the trigger the original state of the table before any of the DML statements have affected it.
    The problem is this seems to work for single row DML statements but not for multi row DML statements. In multi row the trigger only sees the original state of the table, not the state of the table plus the changes made by any other actions in the same DML statement.
    Below I have shown an example of what I'm seeing.
    I have grossly simplified the example code below to only refer to a single table and use stupidly simple logic
    I do realise i appear to be implementing uniqueness in my own PL/SQL code, this is purely for the example.
    CREATE TABLE mutate_test
    id INTEGER NOT NULL,
    value VARCHAR2(255) NOT NULL
    ALTER TABLE mutate_test ADD CONSTRAINT pk_mutate_test PRIMARY KEY(id);
    ALTER TABLE mutate_test ADD CONSTRAINT ck_mutate_test CHECK (value = UPPER(value));
    CREATE OR REPLACE FUNCTION duplicate_found(in_value IN mutate_test.value%TYPE) RETURN BOOLEAN IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    v_value_found INTEGER;
    BEGIN
    SELECT COUNT(*)
    INTO v_value_found
    FROM mutate_test
    WHERE value = in_value;
    IF v_value_found > 0 THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END IF;
    END;
    CREATE OR REPLACE TRIGGER tr_mutate_test BEFORE INSERT OR UPDATE ON mutate_test
    FOR EACH ROW
    BEGIN
    IF duplicate_found(:new.value) = TRUE THEN
    RAISE_APPLICATION_ERROR(-20000,'Duplicate value found');
    END IF;
    END;
    INSERT INTO mutate_test (id,value) VALUES (1,'CLIFF');
    INSERT INTO mutate_test (id,value) VALUES (2,'SULA');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Should fail as row 1 already has a value of CLIFF
    INSERT INTO mutate_test (id,value) VALUES (3,'CLIFF');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Should fail as row 1 is already set to CLIFF
    UPDATE mutate_test SET value = 'CLIFF' WHERE id = 2;
    COMMIT;
    SELECT * FROM mutate_test;
    UPDATE mutate_test SET value = 'CLIFFORD' WHERE id = 1;
    COMMIT;
    SELECT * FROM mutate_test;
    INSERT INTO mutate_test (id,value) VALUES (3,'RONNY');
    INSERT INTO mutate_test (id,value) VALUES (4,'TIM');
    INSERT INTO mutate_test (id,value) VALUES (5,'MONIQUE');
    COMMIT;
    SELECT * FROM mutate_test;
    -- Wanted result would be row 1 would be updated from CLIFFORD to CLIFF
    -- and the others raise errors, or all of them raise errors.
    UPDATE mutate_test SET value = 'CLIFF' WHERE id IN (1,3,4);
    COMMIT;
    SELECT * FROM mutate_test;

    This is all from a University application that deals with eLearning.
    Shell = Mapping from the system to an external eLearning application, ie: unique id of the Blackboard course shell, or WebBoard board.
    Term = Academic term
    Sector = University sector, ie: Higher Education, TAFE, etc..
    Resource = eLearning tool, ie: Blackboard, WebBoard, etc..
    Resource Level = Whether the resource is being offered at a Course or Program level
    Resource Mapping = Association of a resource to shell
    What we are trying to achieve is that shells cannot be used across sector boundaries.
    The real table structure is (grossly simplified again)
    CREATE TABLE sector (sector_pk INTEGER PRIMARY KEY);
    CREATE TABLE sector_pattern (sector_pk INTEGER REFERENCES sector(sector_pk), pattern CHAR(2) NOT NULL UNIQUE CHECK (pattern = UPPER(pattern)));
    CREATE TABLE term (term_pk INTEGER PRIMARY KEY, term CHAR(4) NOT NULL UNIQUE CHECK (term = UPPER(term)));
    CREATE TABLE resource_level (resource_level_pk INTEGER PRIMARY KEY, term_pk INTEGER REFERENCES term(term_pk));
    CREATE TABLE shell_detail (shell_detail_pk INTEGER PRIMARY KEY);
    CREATE TABLE resource_mapping (resource_mapping INTEGER PRIMARY KEY, resource_level_pk INTEGER REFERENCES resource_level(resource_level_pk), shell_detail_pk INTEGER REFERENCES shell_detail(shell_detail_pk));
    Based on the Ask Tom article linked I'd liked to use a MATERIALIZED VIEW on the following query
    SELECT DISTINCT rm.shell_detail_pk,sp.sector_pk
    FROM resource_mapping rm, resource_level rl, term t, sector_pattern sp
    WHERE rm.resource_level_pk = rl.resource_level_pk
    AND rl.term_pk = t.term_pk
    AND SUBSTR(t.term,3,2) = sp.pattern;
    Then apply a UNIQUE constraint on that VIEW.
    But I'm receiving a
    SQL Error: ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
    I'm not sure how to create the MATERIALIZED VIEW LOG entries for the above VIEW.
    Any ideas anyone? ;)
    Need to do some more reading and research but as Tom says
    "I'm asking around about the future of "SQL" as far as enhancments go like that
    (will update when I get some feedback), but -- you are not limited to triggers
    (in fact, I would avoid triggers as it is virtually IMPOSSIBLE to implement
    cross row/cross object constraints with them!!!! at least correctly)"
    So I think i'll give up on the TRIGGER approach as it doesn't meet our requirements.

  • How to generate multiple records on a single sql from dual table

    I wanted to generate ten sequence nos in a single sql statement from dual table.
    Is there any way to use that.
    I think somebody can help me on this by using level clause

    I'm not 100% sure if I understand your requirement: Do you really want to use an Oracle Sequence, as Alex already demonstrated?
    Or just a 'one-time-bunch-of-sequential-numbers'.
    In the latter case you can just select level:
    SQL> select level
      2  from   dual
      3  connect by level <= 10;
         LEVEL
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.

  • Use of addImageTheme method with dual table in query

    Is it possible to specify a query using the dual table that specifies a BLOB type? I'm trying to specify a image theme dynamically using the bean API. My image is a JPEG.

    Hi Jen,
    if you create a table with a BLOB to store the image, plus a geometry column with the image MBR, then you can easily build the dynamic image theme using the API. Your SQL on the image theme would be something like: select mbr, image from image_table.
    I'm not sure if there is a direct function at the SQL level that takes an image file and generates a BLOB. Maybe someone has done something similar. If this function exists, then you may be able to create an image theme issuing a SQL with dual table.
    Joao

  • Silly question on dual table

    Hello gurus
    This dual table is a dummy table with varchar2(1)....my question is how it can select many psedocolumns from dual doesn't it exceed the allowed space of varchar2(1)
    Edited by: 964145 on Oct 9, 2012 5:35 PM

    >
    it cannot be a real table
    >
    Not sure why you say that.
    The DDL for it is in the dcore.bsq file (11.2) in the rdbms/admin folder
    create table dual    /* pl/sql's standard pckg requires dual. */
      (dummy varchar2(1))    /* note, the optimizer knows sys.dual is single row */
      storage (initial 1)
    insert into dual values ('X')
    /See the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/queries009.htm#SQLRF20036
    >
    Selecting from the DUAL Table
    DUAL is a table automatically created by Oracle Database along with the data dictionary. DUAL is in the schema of the user SYS but is accessible by the name DUAL to all users. It has one column, DUMMY, defined to be VARCHAR2(1), and contains one row with a value X. Selecting from the DUAL table is useful for computing a constant expression with the SELECT statement. Because DUAL has only one row, the constant is returned only once. Alternatively, you can select a constant, pseudocolumn, or expression from any table, but the value will be returned as many times as there are rows in the table. Refer to "About SQL Functions" for many examples of selecting a constant value from DUAL.
    >
    And the Database Concepts doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28318/datadict.htm
    >
    The DUAL Table
    The table named DUAL is a small table in the data dictionary that Oracle Database and user-written programs can reference to guarantee a known result. This table has one column called DUMMY and one row containing the value X.
    >
    And those pseudo-columns you ask about
    >
    select sysdate,UID,rowid from dual;
    >
    You can query those from any table but as the doc quote above says you will get as many values as there are rows in the table.

  • Question on dual table..

    after i insert another row into dual table,
    SQL*PLUS still returns only one row. But PL/SQL Developer returns 2 rows.
    What does SQL*PLUS do to return only one row no matter many rows exist in DUAL table?

    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1562813956388

Maybe you are looking for