Primary key and change indicator

So I was creating an employee and then I committed the records and then I tried to delete a record from the same table. I encountered an error like below:
"Another user has changed the row with primary key"
So I searched the solution of this problem, and then I read this article https://blogs.oracle.com/onesizedoesntfitall/entry/the_case_of_the_phantom
This is the solution according to the above article:
Alternatively you can set the Change Indicator on one of the attributes.  This will work as long as the relating column for the attribute in the database itself isn't inadvertently updated.  In turn you're possibly just masking the issue rather than solving it, because if another developer turns the Change Indicator back on the original issue will return.*
Well, then set the Change Indicator of the EmployeeID attribute (which happens to be the primary key of the table). Now its working fine.
But my question is: Is this okay if I am setting the Change Indicator of a primary key attribute to be True?

>
Sonull wrote:
I have set the Type property of employeeID as DBSequence. So when the system creates a row, the values displayed for the employee ID is in the form of negative numbers (-1, -2, -3). Only after committing the rows does the trigger gets fired, and the next number in the sequence is generated, and the row is saved in the database.
>
I don't understand you? are you asking a question or provide information?
When set the type of an attribute to DBSequence, by default Jdeveloper sets the Refresh on Insert property.
What I want to say is that the problem is not in the EmployeeId attribute.

Similar Messages

  • Primary keys and foreign keys

    Hi,
    is there a script available for changing the value of a primary key which automaticly
    detect all foreigs keys refering to this primary key and change them as well?
    William Oorschot

    I don't have the script now. but you can make a procedure of ur own.
    using a join on user_constraints, and user_cons_columns you can find out all the columns in all the tables which are referencing the particular primary key. once you have the table and the referencing columns, you can change the value of those columns with the new value.
    you'll have to call this procedure from a before row level trigger.
    HTH
    Naveen

  • Difference between primary key and primary index

    Dear All,
             Hi... .Could you pls tell me the difference between primary key and primary index.
    Thanks...

    Hi,
    Primary Key : It is one which makes an entry of the field unique.No two distinct rows in a table can have the same value (or combination of values) in those columns.
    Eg: first entry is 111, if you again enter value 111 , it doesnot allow 111 again. similarly for the strings or characters or numc etc. Remember that for char or numc or string 'NAME' is not equal to 'name'.
    Primary Index: this is related to the performance .A database index is a data structure that improves the speed of operations in a table. Indices can be created using one or more columns, providing the basis for both rapid random lookups and efficient ordering of access to records. The disk space required to store the index is typically less than the storage of the table (since indices usually contain only the key-fields according to which the table is to be arranged, and excludes all the other details in the table), yielding the possibility to store indices into memory from tables that would not fit into it. In a relational database an index is a copy of part of a table. Some databases extend the power of indexing by allowing indices to be created on functions or expressions. For example, an index could be created on upper(last_name), which would only store the uppercase versions of the last_name field in the index.
    In a database , we may have a large number of records. At the time of retrieving data from the database based on a condition , it is a burden to the db server. so whenever we create a primary key , a primary index is automatically created by the system.
    If you want to maintain indices on other fields which are frequently used in where condition then you can create secondary indices.
    Reward points if helpful.
    Thanks,
    Sirisha..

  • Update a primary key and Fk

    Hello
    I have to update a primary key (PK) which is referenced by many foreign keys (FK).
    The primary key columns cannot be updated as this would orphan the dependant tables,
    and the dependant tables cannot be updated prior to the parent table as this would also make them orphans.
    I think this problem was solved by disabling the foreign key constraints or deleting the original records and recreating them.
    Since neither of these solutions is particularly satisfactory for me I read about 'deferred constraints'.
    My question is:
    Can I use(modify to) 'INITIALLY DEFERRED' keyword on constraints's table already created with The default, INITIALLY IMMEDIATE ,
    that is, update my primary key and foreign keys, and then re-set to
    'INITIALLY IMMEDIATE'? Or another trick exists ?
    Thanks in advance for your attention

    It is very popular the idea that the updates on primary key columns are a very bad thing.
    Oracle supports this idea and that's why they don't give the "on update cascade" clause on foreign keys.
    So in this case I suggest you to define a master table like this.
    create table master_table (
         key_id number primary key,
         your_primary_key varchar2 not null unique
    /Then you must use that key_id column as foreign key in place of your original primary key. In this way don't even need to update referencing rows when updating the original primary key because the foreign key value doesn't change and everything is always fine as before.
    So instead to lose time implementing some strange sort of cascade triggers plain to do something like this on your schema.
    insert into master_table (id_key,primary_key) (
         select rownum,primary_key
         from your_main_table
    alter table your_main_table add (
         id_key number,
    update your_main_table a
    set id_key = (
              select b.id_key
              from master_table
              where b.primary_key=a.primary_key
         Drops foreign keys
    alter table your_main_table drop primary key cascade
    alter table your_main_table add constraint pk
         primary key(id_key)
    alter table your_main_table add constraint fk
         foreign key(id_key) references master_table
    alter table your_main_table drop (
         your_primary_key
    alter table a_referencing_table add (
         id_key number,
    update a_referencing_table a
    set id_key = (
              select b.id_key
              from master_table
              where b.primary_key=a.primary_key
    alter table a_referencing_table add constraint fk_2
         foreign key(id_key) references master_table
    alter table a_referencing_table drop (
         your_primary_key
    /If you have many objects referencing those tables I suggest you to rename the tables and to create views with the original name of the renamed tables that show data as it was before with a join on master_table. in this way you don't need to change the code of the application referencing them but you just need to recompile invalidated objects.
    Bye Alessandro

  • Can primary key be changed?

    Hi all,
    I found that if primary key is changed, the SQL statement generated is strange. For example, I have an object A, with primary key = 12345. In the UoW, I update the primary key to 1000. The SQL statement generated would be something like "UPDATE A SET PK = 1000 WHERE (PK = 1000)". Is it the expected behaviour of toplink?
    Thanks and regards,
    William.
    PS: Proxy in direction is for object A. Would it tbe cause of the strange behaviour?

    Primary keys cannot be changed.
    Primary keys are used to maintain the identity of objects. Changing the primary key would change the identity.
    If you need to change a primary key field, the best thing to do is delete the original object and insert a new object with a new primary key and other fields copied as appropriate.

  • Diff b/w primary key and unique key?

    what is the diff b/w primary key and unique key?

    Hi,
    With respect to functionality both are same.
    But in ABAP we only have Primary key for the Database tables declared in the Data Dictionary.
    Unique is generally is the term used with declaring key's for internal tables.
    Both primary and Unique keys can identify one record of a table.
    Regards,
    Sesh

  • Access path difference between Primary Key and Unique Index

    Hi All,
    Is there any specific way the oracle optimizer treats Primary key and Unique index differently?
    Oracle Version
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> Sample test data for Normal Index
    SQL> create table t_test_tab(col1 number, col2 number, col3 varchar2(12));
    Table created.
    SQL> create sequence seq_t_test_tab start with 1 increment by 1 ;
    Sequence created.
    SQL>  insert into t_test_tab select seq_t_test_tab.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(USER_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
            259  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> create index idx_t_test_tab on t_test_tab(col1);
    Index created.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> Sample test data when using Primary Key
    SQL> create table t_test_tab1(col1 number, col2 number, col3 varchar2(12));
    Table created.
    SQL> create sequence seq_t_test_tab1 start with 1 increment by 1 ;
    Sequence created.
    SQL> insert into t_test_tab1 select seq_t_test_tab1.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB1',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab1;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1727568366
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |             | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB1 | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6915  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> alter table t_test_tab1 add constraint pk_t_test_tab1 primary key (col1);
    Table altered.
    SQL> exec dbms_stats.gather_table_stats('USER_OWNER','T_TEST_TAB1',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> select col1 from t_test_tab1;
    99999 rows selected.
    Execution Plan
    Plan hash value: 2995826579
    | Id  | Operation            | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |                | 99999 |   488K|    59   (2)| 00:00:01 |
    |   1 |  INDEX FAST FULL SCAN| PK_T_TEST_TAB1 | 99999 |   488K|    59   (2)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6867  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL> If you see here the even though statistics were gathered,
         * In the 1st table T_TEST_TAB, the table is still using FULL table access after creation of index.
         * And in the 2nd table T_TEST_TAB1, table is using PRIMARY KEY as expected.
    Any comments ??
    Regards,
    BPat

    Thanks.
    Yes, ignored the NOT NULL part.Did a test and now it is working as expected
    SQL>  create table t_test_tab(col1 number not null, col2 number, col3 varchar2(12));
    Table created.
    SQL>
    create sequence seq_t_test_tab start with 1 increment by 1 ;SQL>
    Sequence created.
    SQL> insert into t_test_tab select seq_t_test_tab.nextval, round(dbms_random.value(1,999)) , 'B'||round(dbms_random.value(1,50))||'A' from dual connect by level < 100000;
    99999 rows created.
    SQL> commit;
    Commit complete.
    SQL>  exec dbms_stats.gather_table_stats('GREP_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL>  set autotrace traceonly
    SQL>  select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 1565504962
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            | 99999 |   488K|    74   (3)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| T_TEST_TAB | 99999 |   488K|    74   (3)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6912  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL>  create index idx_t_test_tab on t_test_tab(col1);
    Index created.
    SQL>  exec dbms_stats.gather_table_stats('GREP_OWNER','T_TEST_TAB',cascade => true);
    PL/SQL procedure successfully completed.
    SQL>  select col1 from t_test_tab;
    99999 rows selected.
    Execution Plan
    Plan hash value: 4115006285
    | Id  | Operation            | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |                | 99999 |   488K|    63   (2)| 00:00:01 |
    |   1 |  INDEX FAST FULL SCAN| IDX_T_TEST_TAB | 99999 |   488K|    63   (2)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
           6881  consistent gets
              0  physical reads
              0  redo size
        1829388  bytes sent via SQL*Net to client
          73850  bytes received via SQL*Net from client
           6668  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
          99999  rows processed
    SQL>

  • Is their a difference between primary key and unique key with not null valu

    What is the difference in having a column as primary key and having unique key with not null for the column.
    vinodh

    SBH wrote:
    For quick review, below is the link
    http://www.dba-oracle.com/data_warehouse/clustered_index.htm
    You appear to have stumbled on a site that is a mine of disinformation about Oracle.
    >
    It would be helpful, if you explain it too..thnx !!
    The site is wrong and makes up its own terminology as it goes along.
    If the value for clustering factor approaches the number of blocks in the base table, then the index is said to be clustered. http://www.oracle.com/pls/db112/search?remark=quick_search&word=clustered+index
    There is no create clustered index in Oracle.
    - Clustering factor affects the efficiency of an index.
    - There can be clustered tables that you can create indexes on.
    - An Index Organized table is a similar concept to the Microsoft SQL Server clustered index, but it isn't the same thing at all.

  • Difference between PRIMARY KEY and UNIQUE KEY with NOT NULL

    What is the difference between PRIMARY KEY and UNIQUE KEY with NOT NULL constraint?
    Message was edited by:
    Nilesh Hole

    Answer for the master!!!
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8743855576462
    Thanks,
    Karthick

  • Primary keys and store generated pattern

    Hi,
    in my database first application (Firebird), the primary keys are not set to identity by default !
    any ideas why this ?

    Solved !
    put #PK_GEN# as comment for your primary key and now EF import primary keys columns as identity like expeted :)
    btw, fb 3.0 and up support identity columns .

  • Primary keys and constraints are gone....

    Hi Experts,
    I had a schema SchemaD with all primary keys and referential constraints. And i am a TOAD user. I had one more source schema SchemaS.
    In my destination schema all the tables has 2 extra columns for data warehouse purpose.
    I disabled all the constraints and i used toad utility "Copy Data to Another Schema" and i selected all the tables from Source SchemaS.
    After the completion of data copy i tried to enable all the constraints in SchemaD. But i found that there are no primary keys and referential integrates in that schema.
    Please help me in this issue.
    Thanks...
    Ray

    Check in the views "DBA_CONSTRAINTS" or ALL_CONSTRAINTS" with the condition owner='your_schema_name'
    If you are using toad to view the constraints, chances are high that there is a filter in the toad view and it is filtering the constraints...
    Edited by: Suchit on Feb 25, 2009 5:19 PM
    Edited by: Suchit on Feb 25, 2009 5:20 PM

  • How to modify Find and Change indicator?

    I use Find and Change in Applewors 6. At present, this operation finds what is specified but the indicator is colored green and is open, and hard to locate on a page when looking for a single letter. I changed it from its original pale orange to what it is now but now I would like to change it back to something easier to find. But I forgot how I did it and did not make a note. Would appreciate info on how to change this indicator. Thanks

    Neil--
    Thanks for info. I found it under System preferences>Personal>Appearance. You get a lot of choices in color and intensity. I was hoping to change the Find and Change indicator to solid but maybe this is not possible.

  • Primary Key and Foreign Key Constraints

    Hi All,
    I would like to know PRIMARY KEY and FOREIGN KEY constraints on existing oracle tables. Could any one suggest me how to find out.
    Thanks,
    RED

    You can query DBA_CONSTRAINTS to get a list of all the constraints on table A and/or table B. The documentation I linked to gives a full list of the data you can see in DBA_CONSTRAINTS, but it includes things like the referenced table name and referenced constraint name for a foreign key constraint. If A is a parent of B or B is a parent of A, you could match up the parent's primary key constraint to the child's foreign key constraint.
    More generally, though, if you don't know that one of the tables is a parent of the other, figuring out how to join the two tables is probably not something that can be done using just the Oracle data dictionary. You would probably need an understanding of the data model being used to figure out what intermediate table(s) needed to be joined in order to relate rows in A to rows in B.
    Justin

  • Primary key and WHO columns on EO

    We are trying to create a EO based on a database view. We do not have primary key and standard OA WHO columns but the OA framework is forcing us the have these columns. How do we go about this issue? Any suggestion will be appreciated.

    Oracle Apps mandates that you should have the Audit columns in the Applications tables.
    So you must have the 5 columns defined.
    I have created new tables for my application and need to populate them whenever user creates or modifies any row
    Jdeveloper/BC4J handles direct updates/inserts through default EO implementation, it would insert/update/delete from the base table via the EO, what is your qeustion then ? do you want to know how to perform DMLs in OA or something else ?
    Thanks
    Tapash

  • Primary key and Foreign key on same column

    Hi, I am able to create below tables , primary and foreign keys as below.
    But Is this valid design? Can I define a column (ckey2 in table "child") as
    primary key and as well as foreign key?
    CREATE TABLE parent (
    col1 NUMBER,
    col2 NUMBER
    CREATE TABLE child (
    ckey1 NUMBER,
    ckey2 NUMBER,
    ckey3 NUMBER
    alter table parent add constraint parent_pk primary key( col1 );
    alter table child add constraint child_pk primary key( ckey2 );
    alter table child add constraint child_fk foreign key( ckey2 ) references parent( col1);
    Thanks.

    Can I define a column (ckey2 in table "child") as primary key and as well as foreign key?You mean you want to define a one-to-one relationship between parent and child tables.. why would you want to do that ? You might as well merge the 2 tables into one.

Maybe you are looking for

  • Stored Proc running twice using DBMS_Scheduler

    Hello all, I have a vb front end that calls a main stored proc which submits scheduler jobs to execute several stored procs asynchronously. Everything is working, except the part that the several stored procs are running twice. In the troubleshooting

  • How to know the specific size of a field in oracle table

    Hello, oracle 11.2.0.3 on redhat i have three tables with same structure, table0, table50, table100: create table table0 (id number, shipment RAW(2000), options RAW(2000)); i inserted 10000 rows in each but with some differences: table0 has 10000 id,

  • F110 payment postings individual invoices

    Hi, When executing the paymentrun (Direct debits), the payment program generates 1 payment posting (clearing document) per customer in which several open items/invoices are processed. Now we want to have a payment document (clearing document) for eac

  • Ios 7 - no longer able to open .wwf e-mail attachment

    I have some .wwf e-mail attachments that I was able to read prior to upgrading ios. (ipad mini and ipad4) (.wwf is a non-printable pdf) "Open In" does not give me enough options. I have Adobe installed.

  • Should I Upgrade to VoIP, or use PBX

    We now use an Alcatel PBX, 15 years old, with Lucent 8410d digital phones. We have 200 users at one site, and 100 users at three remote sites, with data T-1s connecting them. Is VoIP absolutely the best way to go, or should I look at mid-range PBX so