Flashback table problem

i want to implement flashback table.
for doing this i have tried with the following:
alter system set undo_retention=90000 scope=both;
ALTER TABLESPACE UNDOTBS1 RETENTION GUARANTEE;
FLASHBACK TABLE test TO TIMESTAMP (NOV-05-2006, 12:04:00);
it returns:
SQL> FLASHBACK TABLE test TO TIMESTAMP (NOV-05-2006, 12:04:00);
SP2-0552: Bind variable "04" not declared.
what is the problem?
thanks.

try this
sql>alter session set nls_date_format = 'dd-mon-yyyy hh24:mi:ss';

Similar Messages

  • Flashback tables

    Can anyone please tell me; what is the difference between Flashback being enabled and Flashback logging? Flashback Logging has something to do with point in time recovery? I tried a flashback (from Enterprise Manager; in 10g), on particular tables, and at the end it told me that "the selected tables ...have been flashed back", but the data warehouse team member tells me the rows are not there. . . .
    Additionally, from what I understand, because flashback is enabled, and UNDO_AUTO_RETENTION is set to 900, the limit of flashback is the undo recovery period (for me on the undo advisor graph - 143953 minutes {best possible}, or 5760 {auto tuned}); how do I know how long Flashback may last 'back till'.
    If I have to perform a Whole Database Recovery; can I do it for only certain tables to a point in time? Thanks for any help, DW

    You should check the Oracle Concept
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/high_av.htm#i36677
    Overview of Oracle Flashback Features
    If a major error occurs, such as a batch job being run twice in succession, the database administrator can request a Flashback operation that quickly recovers the entire database to a previous point in time, eliminating the need to restore backups and do a point-in-time recovery. In addition to Flashback operations at the database level, it is also possible to flash back an entire table. Similarly, the database can recover tables that have been inadvertently dropped by a user.
    Oracle Flashback Database lets you quickly bring your database to a prior point in time by undoing all the changes that have taken place since that time. This operation is fast, because you do not need to restore the backups. This in turn results in much less downtime following data corruption or human error.
    Oracle Flashback Table lets you quickly recover a table to a point in time in the past without restoring a backup.
    Oracle Flashback Drop provides a way to restore accidentally dropped tables.
    Oracle Flashback Query lets you view data at a point-in-time in the past. This can be used to view and reconstruct lost data that was deleted or changed by accident. Developers can use this feature to build self-service error correction into their applications, empowering end-users to undo and correct their errors.
    Oracle Flashback Version Query uses undo data stored in the database to view the changes to one or more rows along with all the metadata of the changes.
    Oracle Flashback Transaction Query lets you examine changes to the database at the transaction level. As a result, you can diagnose problems, perform analysis, and audit transactions.

  • 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.

  • Flashback table after shrink

    Situation:
    we deleted all rows from table, then alter table <> shrink space, that worked without any errors.
    Now we decided to flasback that table to a timestamp before delete happend and of course before shrink too.
    Flashback table <> to timestamp....... ended without any errors messages.
    BUT only a few rows are now in table. Timestamp definitly has been correctly set to a point before delete happend:
    WHAT MISTAKE DID WE MAKE??????
    I NEED not to know how to get those rows back i only want to know if anyone has a clue why flashback didn't work correctly.
    Tanks to all
    Joachim Kreimes

    There are two table Flashback technologies in Oracle:cFlashback to SCN or Timestamp is Flashback Table using Undo. Flashback to before drop uses the Recyclebin.
    The following DDL operations change the structure of a table, so that you cannot subsequently use the TO SCN or TO TIMESTAMP clause to flash the table back to a time preceding the operation: upgrading, moving, or truncating a table; adding a constraint to a table, adding a table to a cluster; modifying or dropping a column; adding, dropping, merging, splitting, coalescing, or truncating a partition or subpartition (with the exception of adding a range partition).

  • Errors during Flashback Table

    Hi All,
    We are in Oracle 10.2 and have 2 instances.
    I am using Flash back feature using the query on instance 1:
    flashback table tax to scn 1324411234
    Then it throws thse errors:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-12801: error signaled in parallel query server P000, instance dd20bserver:T1DM2 (2)
    ORA-01555: snapshot too old: rollback segment number 3 with name "_SYSSMU3$" too small
    I executed the same on instance 2. But then also the same error came.
    We have undo tblspace of 5GB which is enough.
    How to get rid of these errors?
    Thanks,
    Kishore

    We are in Oracle 10.2 and have 2 instances.Is this a RAC environment? Why do you say these are two instances?
    I am using Flash back feature using the query on
    instance 1:
    flashback table tax to scn 1324411234
    When in time is located this scn? Is is relatively recent so undo segment can build up the consistent image it requires?. Check the value of UNDO_RETENTION to verify this.
    I executed the same on instance 2. But then also the
    same error came.It is valid to execute this query if you are talking about the same database.
    ~ Madrid

  • Flashback questions - particularly flashback table

    Hi,
    Oracle 10GR2
    The docs state that flashback must be turned on in order to enable the functionality. Subsequently, a flashback logfile is started where designated. Now, for flashback table the docs also state that data comes from the UNDO iin order to restore. My first question is: What is kept in the flashback log and how does it fit in (given that the restore is done via UNDO)? The docs also state that if a flashback database is done that you should perform a resetlogs, but nothing is specified with respect to after a flashback table is done. I could see why you wouldn't want to but still wonder about the table that was flashed back and if it is in a vulnerable state.
    I'm also interested in understanding the significance of flashback retention time vs undo_retention.
    I guess I see some overlap here between the UNDO and FLASHBACK and want to understand the difference.
    Thanks

    Know that Flashback logs are not the only thing
    stored in Flashback Recovery Area. Archived redo logs
    and RMAN backups are also stored and they are used
    for Flashback Table, Flashback Drop, Flashback
    Versions Query, and Flashback Transaction Query
    features.Hmm....this is news to me. Are you are sure about this????? Archived logs, backups are stored in the FRA, but it doesn't mean that they are used for Flashback table, Flashback drop, and FBQ or FTQ....
    So yes, I would say, you need flashback on to
    flashback a table.Again, NO, this is not required. You may like to review the facts associated with these technologies once again.
    Thanks
    Chandra

  • Flashback table not responding

    hi,
    i am using oracle 10g R2 on linux X86. i have flashback feature set to true. one of my table was accidently truncated.
    now i want it back.other tables are brought back with flashback technology.
    but this one is generating error that "the table definition has been changed" i dont made any changes to table definition.
    what might be the issue? even though i have backup,but still would like to know,and recover it with the help of flashback.
    flashback retention target has been set to 900. and table was droped much before that.
    plz help
    thanks and regards
    VD

    Vikrant,
    Why would I mind explaining?
    Anyways, see below a small code.
    SQL> create table aman_t (a number);
    Table created.
    SQL> desc dba_extents;
    Name                                      Null?    Type
    OWNER                                              VARCHAR2(30)
    SEGMENT_NAME                                       VARCHAR2(81)
    PARTITION_NAME                                     VARCHAR2(30)
    SEGMENT_TYPE                                       VARCHAR2(18)
    TABLESPACE_NAME                                    VARCHAR2(30)
    EXTENT_ID                                          NUMBER
    FILE_ID                                            NUMBER
    BLOCK_ID                                           NUMBER
    BYTES                                              NUMBER
    BLOCKS                                             NUMBER
    RELATIVE_FNO                                       NUMBER
    SQL> select segment_name,extent_id,blocks from dba_extents where segment_name='AMAN_T';
    SEGMENT_NAME
    EXTENT_ID     BLOCKS
    AMAN_T
             0          8
    SQL> begin
      2  for i in 1..10000 loop
      3  insert into aman_t values(i);
      4  end loop;
      5  commit;
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL> select segment_name,extent_id,blocks from dba_extents where segment_name='AMAN_T';
    SEGMENT_NAME
    EXTENT_ID     BLOCKS
    AMAN_T
             0          8
    AMAN_T
             1          8
    AMAN_T
             2          8
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(user,'AMAN_T');
    PL/SQL procedure successfully completed.
    SQL> select segment_name,extent_id,blocks from dba_extents where segment_name='AMAN_T';
    SEGMENT_NAME
    EXTENT_ID     BLOCKS
    AMAN_T
             0          8
    AMAN_T
             1          8
    AMAN_T
             2          8
    SQL> delete from aman_t;
    10000 rows deleted.
    SQL> exec dbms_stats.gather_table_stats(user,'AMAN_T');
    PL/SQL procedure successfully completed.
    SQL> select segment_name,extent_id,blocks from dba_extents where segment_name='AMAN_T';
    SEGMENT_NAME
    EXTENT_ID     BLOCKS
    AMAN_T
             0          8
    AMAN_T
             1          8
    AMAN_T
             2          8
    SQL> truncate table aman_t;
    Table truncated.
    SQL> exec dbms_stats.gather_table_stats(user,'AMAN_T');
    PL/SQL procedure successfully completed.
    SQL> select segment_name,extent_id,blocks from dba_extents where segment_name='AMAN_T';
    SEGMENT_NAME
    EXTENT_ID     BLOCKS
    AMAN_T
             0          8
    SQL>You should be able to see that when I issued a delete command, the number of allocated extents are the same.Which does mean that though the blocks are empty but the HWM is still pointing towards those blocks.I gathered stats just to ensure that you won't come back and say that aafter gathering them,things would be different.
    When I gave truncate, you can see that oracle came back to the initially allocated first extent only. This is table definition change and this did happen with my last demo and with your original scenerio as well.
    Now just to confuse you a little more, even gathering of stats would be called as definition change. See below,
    SQL> drop table aman_t purge;
    Table dropped.
    SQL> create table amna_t( a char);
    Table created.
    SQL> exec dbms_stats.gather_table_stats(user,'AMNA_T');
    PL/SQL procedure successfully completed.
    SQL> alter table amna_t enable row movement;
    Table altered.
    SQL> flashback table amna_T to timestamp(sysdate - 1/24/60);
    flashback table amna_T to timestamp(sysdate - 1/24/60)
    ERROR at line 1:
    ORA-01466: unable to read data - table definition has changed
    SQL>So I hope you should be clear now that you can't get back the data with Flashback as this relies over the Undo data and can only get back the logical changes , not the structural changes over the object.
    HTH
    Aman....

  • Doubt about FLASHBACK TABLE

    Dear Members,
    I am doing FLASHBACK TABLE as sys user. I know that FLASHBACK TABLE can not be used for user SYS ,
    still I successfully execute this command with to before drop clouse and
    when i execute this command with to timestamp clouse , I get error.
    Can some one please tell me why this is happening ?
    ORACLE : 11gR2
    OS : FEDORA 14
    $ sqlplus / as sysdba
    SQL> insert into t11 values('k');
    1 row created.
    SQL> !date;
    Wed May 30 15:45:13 IST 2012
    SQL> insert into t11 values('z');
    1 row created.
    SQL> drop table t11;
    Table dropped.
    SQL> select * from dba_recyclebin;
    OWNER               OBJECT_NAME          ORIGINAL_NAME          OPERATION TYPE               TS_NAME               CREATETIME     DROPTIME          DROPSCN PARTITION_NAME          CAN CAN     RELATED BASE_OBJECT PURGE_OBJECT SPACE
    SYS               BIN$wT5v1Gw96zbgQGSsOaoM4g==$0 T11               DROP     TABLE               NISHANT               2012-05-30:14:47:37 2012-05-30:15:45:36 17728226                    YES YES     85115 85115     85115     8
    SQL> flashback table "BIN$wT5v1Gw96zbgQGSsOaoM4g==$0" to timestamp to_time('30/05/2012 15:45:13','dd/mm/yyyy hh24:mi:ss');
    flashback table "BIN$wT5v1Gw96zbgQGSsOaoM4g==$0" to timestamp to_time('30/05/2012 15:45:13','dd/mm/yyyy hh24:mi:ss')
    ERROR at line 1:
    ORA-08185: Flashback not supported for user SYS
    SQL> flashback table "BIN$wT5v1Gw96zbgQGSsOaoM4g==$0" to before drop;
    Flashback complete.

    Hi,
    As far as i know, recyclebin doesn't work for SYS schema. The same i have tested on my 11.2.0.3 test database -
    18:12:22 SQL> select * from dba_recyclebin;
    no rows selected
    18:12:23 SQL> show user
    USER is "SYS"
    18:12:27 SQL>
    18:12:28 SQL> create table a (x number);
    Table created.
    18:12:35 SQL> insert into a values (1);
    1 row created.
    18:12:36 SQL> insert into a values (2);
    1 row created.
    18:12:36 SQL> insert into a values (3);
    1 row created.
    18:12:37 SQL> select * from a;
             X
             1
             2
             3
    18:12:38 SQL> commit;
    Commit complete.
    18:12:39 SQL> drop table a;
    Table dropped.
    18:12:46 SQL> select * from recyclebin;
    no rows selected
    18:12:48 SQL> select * from dba_recyclebin;
    no rows selected
    18:13:00 SQL>Can you please check back again.
    Edited by: Anand.. on May 30, 2012 6:19 PM --> Update --> It was my mistake, didn;t check the ts_name column. The object is created in non-system tablespace.

  • Flashback Table

    All dependent objects are retrieved when you perform a Flashback Drop, just as the objects are all added to the Recycle Bin when the base table is dropped.
    Emp is dependent on dept table , here i go
    SQL> drop table dept cascade constraints
      2  /
    Table dropped.
    SQL> flashback table dept to before drop
      2  /
    Flashback complete.
    SQL> select * from dept
      2  /
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> insert into emp values (7935,'JERRY','DBA',7782,sysdate,8000,null,50)
      2  /
    1 row created.Above insertion is not validating its parent key why? I dropped the dept table and then flashbacked.The PK should also be flashbacked and it is..
    SQL> alter table dept add primary key (deptno)
      2  /
    alter table dept add primary key (deptno)
    ERROR at line 1:
    ORA-02260: table can have only one primary keySo whats wrong , dropping and flashbacking parent table can cause to dependent table references?
    SQL> alter table emp add foreign key (deptno) references dept
      2  /
    alter table emp add foreign key (deptno) references dept
    ERROR at line 1:
    ORA-02298: cannot validate (SCOTT.SYS_C005461) - parent keys not foundFlashingback to parentes table mess up the PK and FK.

    This is expected behaviour. Your CASCADE CONSTRAINTS dropped the constraint on EMP before dropping the table DEPT. They are implemented as separate operations, and the drop of the constraint is not protected by flashback. Then dropping DEPT renamed the table and all its dependent objects including the primary key (remember what is going on here: from 10.x, DROP is re-implemented as a RENAME), and the flashback recovered them.
    If you think about it, this is good behaviour: it would be absurd to have a constraint based on a relationship with a dropped table.

  • Mutating table problem help required

    Hi. I am rather hoping someone will be able to help me with this problem.
    I have two tables, sa and mv. Create script below:
    create table mv (
    moduleId Char(2) CONSTRAINT ck_moduleId CHECK(moduleId in ('M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8')),
    credits Number(2) CONSTRAINT ck_credits CHECK(credits in (10, 20, 40)),
    constraint pk_mv primary key(moduleId)
    create table sa (
    stuId Char(2) CONSTRAINT ck_stuId CHECK(stuId in ('S1', 'S2', 'S3', 'S4', 'S5')),
    moduleId Char(2),
    constraint pk_sa primary key(stuId, moduleId),
    constraint fk_moduleid foreign key(moduleId) references mv(moduleId)
    And the scripts below is to insert data into both:
    insert into mv VALUES('M1', 20)
    insert into mv VALUES('M2', 20)
    insert into mv VALUES('M3', 20)
    insert into mv VALUES('M4', 20)
    insert into mv VALUES('M5', 40)
    insert into mv VALUES('M6', 10)
    insert into mv VALUES('M7', 10)
    insert into mv VALUES('M8', 20)
    insert into sa VALUES('S1', 'M1')
    insert into sa VALUES('S1', 'M2')
    insert into sa VALUES('S1', 'M3')
    insert into sa VALUES('S2', 'M2')
    insert into sa VALUES('S2', 'M4')
    insert into sa VALUES('S2', 'M5')
    insert into sa VALUES('S3', 'M1')
    insert into sa VALUES('S3', 'M6')
    Now for the actual problems.
    Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
    Just one or the other. I have created a single trigger, but if fails because of the mutating table problem.
    The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table.
    Many thanks in advance for any assistance.

    Use a statement level trigger:
    Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
    SQL> create or replace trigger sa_trg
      2  after insert or update on sa
      3  declare
      4  c number;
      5  begin
      6    select count(distinct moduleId) into c
      7    from sa
      8    where stuid = 'S1'
      9    and moduleId in ('M5','M6');
    10    if c > 1 then
    11       raise_application_error(-20001,'S1 on both M5 and M6!!');
    12    end if;
    13  end;
    14  /
    Trigger created.
    SQL> select * from sa;
    ST MO
    S1 M1
    S1 M2
    S1 M3
    S2 M2
    S2 M4
    S2 M5
    S3 M1
    S3 M6
    8 rows selected.
    SQL> insert into sa values ('S1','M5');
    1 row created.
    SQL> insert into sa values ('S1','M6');
    insert into sa values ('S1','M6')
    ERROR at line 1:
    ORA-20001: S1 on both M5 and M6!!
    ORA-06512: at "SCOTT.SA_TRG", line 9
    ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'
    The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table
    SQL> create or replace trigger sa_trg
      2  after insert or update on sa
      3  declare
      4  c number;
      5  begin
      6    select count(distinct moduleId) into c
      7    from sa
      8    where stuid = 'S1'
      9    and moduleId in ('M5','M6');
    10    if c > 1 then
    11       raise_application_error(-20001,'S1 on both M5 and M6!!');
    12    end if;
    13 
    14    select count(*) into c from (
    15    select stuid
    16    from mv, sa
    17    where sa.moduleid=mv.moduleid
    18    group by stuid
    19    having sum(credits)>120);
    20 
    21    if c > 0 then
    22       raise_application_error(-20002,'A student cannot have more than 120 credits!!');
    23    end if;
    24 
    25  end;
    26  /
    Trigger created.
    SQL>   select stuid, sum(credits)
      2  from mv, sa
      3  where sa.moduleid=mv.moduleid
      4  group by stuid;
    ST SUM(CREDITS)
    S3           30
    S2           80
    S1          100
    SQL> insert into sa
      2  values ('S1','M4');
    1 row created.
    SQL>   select stuid, sum(credits)
      2  from mv, sa
      3  where sa.moduleid=mv.moduleid
      4  group by stuid;
    ST SUM(CREDITS)
    S3           30
    S2           80
    S1          120
    SQL> insert into sa
      2  values ('S1','M7');
    insert into sa
    ERROR at line 1:
    ORA-20002: A student cannot have more than 120 credits!!
    ORA-06512: at "SCOTT.SA_TRG", line 20
    ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'Max
    http://oracleitalia.wordpress.com

  • Flashback table does not work in 10.2?

    I thought that you can undo a drop and recover any table with FLASHBACK TABLE feature which comes with 10.2 by default (i.e. not special setting up is required). But I get this error when I try to do it.
    ORA-00439: feature not enabled: Flashback Table
    I used FLASHBACK TABLE <table name> BEFORE DROP;

    Ahmer Mansoor wrote:
    Dear Channa,
    Please make sure that the parameter recyclebin is on, if not then do the following.
    SQL> ALTER SYSTEM SET RECYCLEBIN=ON SCOPE=BOTH;
    Well, you must check before posting a statement that whether its working or not. Your reply is actually wrong in every manner. First, the parameter is a static parameter and can't be changed by the option BOTH. It has to be spfile and will be requiring a restart of the db. Please see below,
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> alter system set recyclebin=off;
    alter system set recyclebin=off
    ERROR at line 1:
    ORA-02096: specified initialization parameter is not modifiable with this
    option
    SQL> alter system set recyclebin=off scope=both;
    alter system set recyclebin=off scope=both
    ERROR at line 1:
    ORA-02096: specified initialization parameter is not modifiable with this
    option
    SQL> alter system set recyclebin=off scope=spfile;
    System altered.
    SQL> startup force
    ORACLE instance started.
    Total System Global Area  263639040 bytes
    Fixed Size                  1373964 bytes
    Variable Size             205523188 bytes
    Database Buffers           50331648 bytes
    Redo Buffers                6410240 bytes
    Database mounted.
    Database opened.
    SQL> show parameter recyclebin
    NAME                                 TYPE        VALUE
    recyclebin                           string      OFF
    SQL>Second, there is no relation between the parameter's value being OFF/On and the message that the OP is receiving. If the parameter is set to OFF, this would be the message,
    SQL> conn aman/aman
    Connected.
    SQL> create table test_tab(a number);
    Table created.
    SQL> drop table test_tab;
    Table dropped.
    SQL> flashback table test_tab to before drop;
    flashback table test_tab to before drop
    ERROR at line 1:
    ORA-38305: object not in RECYCLE BIN
    SQL> show parameter recyclebin
    NAME                                 TYPE        VALUE
    recyclebin                           string      OFF
    SQL> select * from V$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL>HTH
    Aman....

  • Oracle 10 OEM, flashback table

    Hi:
    This is my first time to do the flashback table in OEM. I had updated wrong information to the table now I want to flashback. I did the first step of 7 steps which is pick a table. Now I don't understand what I should do for 'Choose Columns' and 'Blind the Row Value'. Would some one help me?
    Many thanks in advance.

    QAQA wrote:
    Hi:
    This is my first time to do the flashback table in OEM. I had updated wrong information to the table now I want to flashback. I did the first step of 7 steps which is pick a table. Now I don't understand what I should do for 'Choose Columns' and 'Blind the Row Value'. Would some one help me?I never used EM for the flashback of a table as likementioned by another poster. I use the Flashback command from the sql prompt. I just tried to the flashback of a table using EM for your question based on SCN and time. I was not asked anything that you have mentioned. All I did was , choose the table, pick the Flashback Table option, chose SCN based flasback ( the same happened with time also) , and I was at the submit button to submit it. That's all! From where you are getting these options?
    HTH
    Aman....

  • EMERGENCY: Need to flashback table, how to find SCN for a time before update happened?

    Hi all,
    I've got a new database 11G, I've not used flashback before, but my retention time is a day...I have a time that the developer did a massive update to a table to corrupt it.
    How do I find the SCN for that time so I can attempt to flashback that table?
    Thank you,
    cayenne

    Thank you..I also found this works:
    SQL> select timestamp_to_scn(to_timestamp('20140103152000','YYYYMMDDHH24MISS')) scn from dual;
           SCN
      98344246
    Well that might NOT work all of the time. But that is just what Oracle does when you give it a timestamp to flashback to: it converts the timestamp to an SCN and then restores data based on that SCN.
    See Flashback Table in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9012.htm
    TO TIMESTAMP Clause
    Specify a timestamp value corresponding to the point in time to which you want to return the table. The expr must evaluate to a valid timestamp in the past. The table will be flashed back to a time within approximately 3 seconds of the specified timestamp.
    That 'approximately 3 seconds' accuracy is due to that conversion to SCN - Oracle uses its internal table.
    SCN is accurate if you know it but you usually don't.
    Read, and heed, these warnings in the advanced app dev guide
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_flashback.htm
    Guidelines for Oracle Flashback Query
      If a possible 3-second error (maximum) is important to Oracle Flashback Query in your application, use an SCN instead of a timestamp. See General Guidelines for Oracle Flashback Technology.
    General Guidelines for Oracle Flashback Table
      To query past data at a precise time, use an SCN. If you use a timestamp, the actual time queried might be up to 3 seconds earlier than the time you specify. Oracle Database uses SCNs internally and maps them to timestamps at a granularity of 3 seconds.
         For example, suppose that the SCN values 1000 and 1005 are mapped to the timestamps 8:41 AM and 8:46 AM, respectively. A query for a time between      8:41:00 and 8:45:59 AM is mapped to SCN 1000; an Oracle Flashback Query for 8:46 AM is mapped to SCN 1005.
         Due to this time-to-SCN mapping, if you specify a time that is slightly after a DDL operation (such as a table creation) Oracle Database might use an SCN      that is just before the DDL operation, causing error ORA-1466.

  • Flash back table problem

    Dear all,
    10g r2 p4 on solaris
    ALTER TABLE employee ENABLE ROW MOVEMENT;
    FLASHBACK TABLE employee TO TIMESTAMP TO_TIMESTAMP('18-JAN-2009 18:25:58','DD-MON-YYYY HH24:MI:SS');
    am getting the error
    ORA-08180 no snapshot found
    undo_retention integer
    900
    If I increase the undo retnetion parameter , can I able to retrieve the data. or data recovery is not possible ?
    Please guide?
    Kai
    Edited by: KaiS on Jan 18, 2010 12:40 PM

    Thanks P.Forstmann,
    select begin_time, end_time, tuned_undoretention from v$undostat;
    returned for the required period
    BEGIN_TIME     END_TIME     TUNED_UNDORETENTION
    01/18/2010 18:59:57     01/18/2010 19:09:57     900
    01/18/2010 18:49:57     01/18/2010 18:59:57     900
    01/18/2010 18:39:57     01/18/2010 18:49:57     900
    01/18/2010 18:29:57     01/18/2010 18:39:57     900
    Thanks
    Kai

  • Interactively changing values to table problem: indicator and control table, and why it does not work after a while...?

    I have been producing a VI that loads a set of data and displays it in a table: A table control is initialised with an empty variable, the loaded data takes the place of the variable and fills the table, while some headers are added. That table feeds an intensity graph to give a pictorial impression of the data.
    With this scheme, a user can change any value of the table, and the changes are interactively reflected on the graph.
    Problem: after few saving of the VI, the access to the table doesn't work anymore. It is the same with all my numerical controls in the VI where it should be possible to enter a value.
    If anybody has an idea on the potential
    causes of these problem, I would be really grateful as it is very useful...when it works !
    Regards,
    Elie Allouis

    I can not image what is causing the error. Would you be willing to post some code to see if we can reproduce the problem?
    Jeremy7

Maybe you are looking for

  • I can no longer delete my yahoo mail in iOS 8

    Ever since updating to iOS 8, I cannot delete the mail in my Yahoo inbox. I get a popup telling me the message can't be deleted. Settings were the same as my iPad running iOS 7, so it's got to be something with 8. Any fixes out there yet?

  • Keyboard shortcuts not working in Illustrator CC for Mac

    I'm having a lot of problems using keyboard shortcuts in Illustrator CC for Mac. They'll will work intermittently. No keyboard issues anywhere else. Is this a bug, or something I can remedy on my end?

  • Query running sometimes slow and sometimes fast on both prod and dev. Help

    We are running a job that is behaving so inconsistently that I am ready to jump off the 19th floor. :-) This query that goes against one table, was just coming to halt in production. After 4 days of investigation we thought it was the resource on pro

  • PSE9 thumbnail problem

    PSE9 generates thumbnails of old photos but not recently loaded or edited ones. Help please?

  • Revoke access to Business Areas while loading data

    Hi, What is the best practive to restrict access to business areas (or entire EUL) while data is being loaded? Currently users could use Discoverer to query the tables being loaded. What would be an efficient way to make sure they are not able to que