Read-Only Primary Key

Hi All,
I am trying to figure out a way to keep my primary keys from being edited. I created a primary key constraint but did not know how to set it as read-only.
Each time I create a new record, commit, and change its primary key, Oracle allows me.
Can someone please shed a light to this?
THanks!

I was actually thinking of that update trigger but I thought maybe there was a direct declaration or attribute that I could simply set to my primary key constraint as read-only. No there is nothing like that as far as i know.
In regards to allowing update on primary key, that is my issue I don't know how to set it to read-only. I don't allow it. It's default. If I go to my table and start typing on the primary field, it'll replace it without throwing an exception. Its not a rule of thumb that the primary key should not be updated. And hence such a thing is not set by oracle. But as far as best practice is concern its good not to update a primary key.
I just thought maybe there was a direct solution. I guess I have to just apply another step to my process. Thanks! The best way is to Design your application in such a way that it does not allow any updation on the primary key.

Similar Messages

  • [SOLVED] Show only primary key columns in database diagrams

    Hi,
    I'd like to create a database diagram with some tables hiding all the columns that aren't primary key or foreign key.
    Currently the only way that I've found is right click on the column's name (in the table body visualized into the diagram) --> Hide selected shape
    I've found the option that permits to visualize the constraint name and (optionally) the relative fields on the same row but what I'd like is something like:
    <Table name>
    <column_name> PK
    <column_name> PK
    <column_name> FK1
    <column_name> FK2
    Do you know a way to do this?
    Many thanks
    Best regards
    Message was edited by:
    Tranen

    Hi Tranen,
    you can view the constraints and respective columns by setting the
    Table Shape Properties in the Property Inspector.
    Select (all) the tables on the Diagram you want
    In the Property Inspector,under Constraints -Set the 'Show Constraint Columns' to 'True',
    Set 'Show Constraints' to 'True' .
    Constraints (PK,UK,FK,Check)
    Also Set the 'Show Columns' option to 'False' .This will be under display options in the Property inspector.
    This should modify the Table shape in the diagram as follows:
    <Table name>
    <PK> PKName:Column1,Column2
    <UK>UKName:Column3
    <FK>FKname:Column1
    are you looking for the same?
    Thanks.

  • How to make Select List Read only (Keep key Data)

    I'd like to make a select list read only when the screen is in maintenance mode because the select list value is part of the key.
    However, when I make the select list read only, the update fails because it appears making it disable lose's it's value.
    How can I make a select list read only and keep it's value for update.

    In HTML Header I have
    <script type="text/javascript">
    function Disable_List(pthis,hideitem)
    if ($x(hideitem).value == 'Y')
    {   $x(pthis).disabled = "disabled";
    </script>
    <script type="text/javascript">
    function Load_Start()
    Disable_Item('P5_SUBCODE','P5_XW_HAS_VALUE');
    Disable_List('P5_LTY','P5_XW_HAS_VALUE');
    </script>
    When I click apply changes, my Validation check that doesn't allow nulls in the "P5_LTY" fires saying the field can't be null. The select list is grayed out and I see the value, but the validation check thinks it's null.
    Edited by: spuchc on Jun 15, 2010 8:03 AM

  • FindByKey() finds only primary keys?

    I want to use the findByKey() method to check if a specific value is already in the database. I use the following code snippet to do this:
    String Nr = "SearchStringPart1";
    AttributeListImpl al = new AttributeListImpl();
    al.setAttribute("UniqueKeyPart1",new Number(1));
    al.setAttribute("UniqueKeyPart2",Nr);
    Key myKey = myViewObject.createKey(al);
    Row[] rows = myViewObject.findByKey(myKey,2);If I run this code snippet "rows[]" will be empty, even if the queried data does exist.
    UniqueKeyPart1 and UniqueKeyPart2 form together a unique key in the database and they are marked as "Keys" in the Attribute Settings of "myViewObject". However, they are no primary keys.
    If I change the code snippet to query the primary key I do get some results:
    AttributeListImpl al = new AttributeListImpl();
    al.setAttribute("PrimaryKey",new Number(13));
    Key myKey = myViewObject.createKey(al);
    Row[] rows = myViewObject.findByKey(myKey,2);Question:
    Is it possible, that "findByKey" can only find primary keys? This is not documented in the documentation.

    I try to keep away as far as possible the column names of the database from the clients.
    Unfortunately my column names are somewhat cryptic whereas the attribute names are readable. So if I write a where clause I have to use the cryptic names instead of the readable names which I hoped to be able to use with findByKey().
    So the difference is "WHERE CRYPTIC_COLUM_NAME = 123" to "findByKey(RevisionKey, 123)".
    However, I expect, that I'll not be able to hide the column names completely from the clients :-(You can hide the names if you use ViewCritiera rather then setup the where clause directly. See oracle.jbo.ViewCriteria and
    oracle.jbo.ViewObject.applyViewCriteria method
    If that's true, then when you set the VO key attribute for UniqueKeyPart1 and
    UniqueKeyPart2, the ViewObject key is a combination of
    PrimaryKey+UniqueKeyPart1+UniqueKeyPart2. That's surprising.
    PrimaryKey alway delivers one Row as the primary key is always unique. So what is the sense of appending other attributes checked as "Key Attributes" to the primary key. You will never get more than the one result specified by the primary key.
    Obviosly I didn't understand the purpose of the "Key Attribute" checkbox in the view object wizard. Maybe you can help me?Key attributes on ViewObject is used by the framework for the most part is to uniquely identify one row in that ViewObject.
    However, this might be an suggestion for an enhancement. I think, my idea to query different colums than the primary key with findByKey() is not so strange. And I think it should not be too difficult to implement this in one of the future releases.You should be able to use ViewCriteria on the ViewObject and not only provide matching values but use * or % to find a pattern as well.
    You can also use other QBE features. See the usage in findMode in JClient forms on how you could use ViewCriteria.
    Frank

  • Unable to create new entry in table that has no primary key

    Hi
       I have a table which is required to have no primary key (except mandt). After i generate table maintanance, when I go to create new entries, the table control to enter the new values does not appear. When I click on edit->new entries, it goes back to the fields tab of the table. Same when i check through SM30.
    If i maintain atleast one primary key, I am able to get the table control in new entries screen. However the requirement permits no primary keys except mandt. How can this be resolved?
    Thanks
    NM

    Hi,
    THE PROBLEM WITH UR TABLE IS
    YOU HAD DECLARED MANDT AS THE PRIMARY KEY AND THERE IS NO OTHER KEY IN UR TABLE
    iT'S NOT ALLOWING YOU TO ADD NEW ENTRIES BECAUSE MANDT IS THE ONLY PRIMARY KEY IN YOUR TABLE AND IT WILL HAVE A DEFAULT VALUE BASED ON THE CLIENT. SO  IT'S NOT SHOWING YOU THE CREATE NEW ENTRIES OPTION.
    SO TRY TO PUT ONE MORE FIELD AS THE PRIMARY KEY SO THAT YOUR PROBLEM WILL SOLVE VERY EASILY  ALSO MAKE SURE THAT TABLE IS ACTIVATED.
    REVERT IF U NEED SOME MORE HELP
    Thanks &Regards.
    Pavan.

  • In JDO, can a foreign key be part of a primary key?

    Hi, it's possible to have a foreing key a part of a primary key in JDO?
    The JDO checker is complaining about that. It says "Primary key field 'person' cannot declare relationship".
    For example, if I have an entity 'Person' (id, name) and and entity 'Pet' (name, age). Can I have the primary key of 'Person' (id) as a foreign key in 'Pet', and can I have a compound primary key in 'Pet' with 'name' and 'id' as the compound key?
    Thanks in advance.
    Rafael

    Hi Dino,
    First of all, thank you very much for your answer.
    I read the article, but the solution proposed isn’t clear to me. The theorical solution is: “You'll have to map the foreign key columns to individual simple fields in your class rather than a single related object. At runtime, you can use the values of these fields to construct an application identity instance, which you can then use to fetch the related object”
    I don’t understand the second sentence… how would I fecht the related object at runtime?
    Did you try it? Could you please send me an example? I change the type of my attributes to primitive types, and I left my .jdo and .map files as if those attributes were only primary keys… how would I specify the relation at runtime with the other table?
    My email is [email protected], I would really appreciate your help.
    Best regards,
    Isidro

  • ORA-02266: unique/primary keys - error while using Exchange Partition

    Hi All,
    While using EXCHANGE PARTITION statement as given below,
    ALTER TABLE SOURCE_TABLE EXCHANGE PARTITION PRT_EXCG_PRTN WITH TABLE TARGET_TABLE
    we are getting this error,
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    However, there are no tables have foreign keys referring this TARGET_TABLE, we checked this by referring
    USER_CONSTRAINTS table, it has only primary key and NOT NULL constraints.
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME like 'TARGET_TABLE';
    We are using the following version,
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    PL/SQL Release 9.2.0.6.0 - Production
    CORE     9.2.0.6.0     Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
    NLSRTL Version 9.2.0.6.0 - Production
    Is it due to any error in our end or it could be a bug in Oracle and should we go for any patch updation ?
    Please guide us to resolve this error as soon as possible, thank you.
    Regards,
    Deva

    *** Duplicate Post ***
    Please Ignore.

  • Problem with primary key field that needs updating on commit

    Taking on someone else's form and trying to tidy it up as it has no primary key on tha table.
    The only primary key i can apply is (invoice number, line number)
    This has to be displayed on the form as a provisional number when the user enters the form. So it need to show for example inv number 1000 with each line on the invoice being 1,2,3,4 etc.
    The form then has a linked table for the lines per invoice that inserts invnumber and line number into a seperate table on PRE INSERT trigger. This means that if they put on various lines i need to do a post.
    My problem comes because more than one person can use the form at the same time so user a will go into the form and see inv number 1000, user b will also see 1000. The original form was making these null and updating to correct number on commit but i wanted to add a primary key.
    Im jusat wodering the best way to do this as if user a does not save before user b. there is a potential for a lock to occur on the post. Also they must be updated to a new number if someone else saves before them

    either you create a sequence for this by create sequence command and populate the sequence value. but in this case if the form is cancelled the sequence is missed and the next sequence will appear. Another way to do is to generate the invoice number when the user press save button and then assign that value to text item. It is the best way to do. So the user will see invoice number only when they save and it happens in milli seconds so there is no question of overlapping invoice number.
    Hope this helps.

  • Batch processing problem: Seeing the primary key (id) in the test cases...

    Another problem we seem to be having is how to read the primary key into a base attribute of an entity.
    In batch processing, we may define the "id" as the primary key on the table. We need to get that id and the foreign key ids into the base attributes in the rule set...
    How do we go about doing that?

    Perhaps better, if you could give me a sample xml config with global and one entity. The only attribute in the entity should be the id... The id should be the primary key in both OPA and Oracle...
    The global table in oracle would contain a single column with the global id.
    The child table in oracle would contain 2 columns -> one for the global ref id and one for the child key...
    I think you will find problems.
    As a note we have duct-tape solved this by creating views and making column copies in the views of the child id and then mapping the id in oracle to the duplicate column in the view.
    So our child view contains the child table with the child id repeated twice so that we can map...

  • Select statement for primary keys

    Hi
    What is the syntax to select a statement from a table with only primary keys. there are 4 primary keys i have to select all the 4 primary keys is there any syntax difference???

    Hi,
    do u want those primary keys in the internal table or else will u have a where condition based on those all the primary key fields
    if u use all the four primary keys u can write like this remember one thing first u write the field just like in the table created order it is not mandatory to do like that but it increases the performance of the so query
    select single * from ztable into table t_tab where (mention all the four primary keys here ) it increases the performance we are using this single because u r giving all the primary keys in the select query so obvously one record will be there so it increases the query performance..
    if wont give those primary keys then write like this select * from ztable into table t_tab.
    as normal as ordinary
    i hope u got cleared
    plzz reward if it is helpful..
    plzz dont forget to reward...

  • Specify maintenance status 'read only'. View /TDM/9_... could not be activa

    I believe I run across a TDMS-related issue. I have been rolling out ERP SPS 9 to all ERP systems. I am now down to the final system, our training system. While importing the support packs, I get the following errors:
    Field ARCH_XHOME-ROWID does not exist
    Key field ARCH_XHOME-FILENAME missing. Specify maintenance status 'read only'.
    Field BWFS_SETTINGS_0D-ROWID does not exist
    Key field BWFS_SETTINGS_0D-INFOSOURCE missing. Specify maintenance status 'read only'.
    Field HRP1008-ROWID does not exist
    Key field HRP1008-BEGDA missing. Specify maintenance status 'read only'.
    Key field HRP1008-ENDDA missing. Specify maintenance status 'read only'.
    Key field HRP1008-ISTAT missing. Specify maintenance status 'read only'.
    Key field HRP1008-OBJID missing. Specify maintenance status 'read only'.
    Key field HRP1008-OTYPE missing. Specify maintenance status 'read only'.
    Key field HRP1008-PLVAR missing. Specify maintenance status 'read only'.
    Key field HRP1008-SEQNR missing. Specify maintenance status 'read only'.
    Key field HRP1008-SUBTY missing. Specify maintenance status 'read only'.
    Key field HRP1008-VARYF missing. Specify maintenance status 'read only'.
    View /TDM/9_200C00643 could not be activated
    View /TDM/9_200C00644 could not be activated
    View /TDM/9_200C00645 could not be activated
    View /TDM/9_200C00798 could not be activated
    View /TDM/9_200C00965 could not be activated
    View /TDM/9_200C01701 could not be activated
    View /TDM/9_200C01846 could not be activated
    View /TDM/9_200C01848 could not be activated
    View /TDM/9_200C02737 could not be activated
    View /TDM/9_200C03032 could not be activated
    View /TDM/9_200C04033 could not be activated
    View /TDM/9_200C04041 could not be activated
    After some looking through SDN and OSS messages, I found a relevant posting (DDIC ACTIVATION ERROR) but no solution. I have submitted a message to SAP but since I'm under a time limit, I need to use all available resources to resolve.
    I suspect these issues are a result of TDMS. Client 200 is the target of a TDMS copy. We have dropped this client for now just to see if that resolves the issue, but it did not as we expected. I suspect there is something in the TDMS controller that we need to do to "release" this system as a target but we're just now evaluating TDMS and are not experts. Any suggestions?

    Hi,
    To resolve the mentioned problem please follow the instructions
    given in following SAP note :
    1020887 - Generated views in receiver system not deleted correctly.
    Follow the instructions as mentioned in the note properly.
    Thanks,
    Rupam

  • How to commit primary key in a multi level form

    Hi ,
    I am using Jdeveloper 10.1.2.3. ADF - Struts jsp application.
    I have an application that has multiple levels before it finally commits, say:
    Level 1 - enter name , address, etc details -- Master Table Employee
    Level 2 - Add Education details -- Detail Table Education
    Level 3 - Experience -- Detail Table Experience.
    Level 4 - adding a Approver -- Detail Table ApplicationApproval
    In all this from Level 1 I generate a document number which is the primary key that links all these tables.
    Now if User A starts Level 1 and moves to level 2,he gets document no = 100 and then User B starts Level 1 and also gets document no = 100 because no commit is executed.
    Now I have noticed that system crashes if User B calls a vo.validate().
    How can I handle this case as Doc no is the only primary key.

    Hi,
    This is what my department has been doing even before I joined and its been working for our multi user environment for these many years.
    We have a table called DOC_SRNO which will hold a row for our start docno , next number in running sequence. the final number. We have this procedure that returns next num to calling application and increments the next num by 1 in the table. and final commit on the application commits all this.
    I am not sure how this was working so far but each of those applications were for different employees. I am assuming this is how it worked.
    Now in the application that I am working on, has no distinct value. So two users could generate the same docno and proceed.
    I will try the DB sequence but here is what I tried. I call the next num from DOC_SRNO and I commit this table update and then proceed with this docno so at a time both gets different docno's.
    But my running session crashes when I go to next level to insert into the detail table of my multi level form. Here when I try to get the current row from the vo which is in context, it crashes.
    Here's the steps.
    Three tables : voMainTable1 and voDetailTable1 and voDetailTable2.
    voMainTable1 on create row1- I generate new docno - post changes
    voMainTable1 on create row2- I genrate another docno - post changes
    set voMainTable1 in context
    Now I call voDetailTable1 and to get the docno to join master detail, I try to get voMainTable1.getCurrentRow. Here it crashes.
    How can I avoid this

  • FillSchema picks too many primary key columns

    I don't know whether this is an ODP.NET error or a Microsoft error.
    Oracle9i Release 9.2.0.1.0
    ODP.NET 9.2.0.4
    .NET Framework 1.1
    Create a table with one primary key column and one unique column and name the primary key column like the unique column with the suffix "_ID":
    CREATE TABLE t_bib_uebertrag_kap(
    &nbsp kapazitaet_id NUMBER(8) NOT NULL
    &nbsp&nbsp CONSTRAINT pk_kapa primary key,
    &nbsp kapazitaet VARCHAR2(15) NOT NULL
    &nbsp&nbsp CONSTRAINT a_un_kapa unique,
    &nbsp geschwindigkeit NUMBER(12) NOT NULL,
    &nbsp bemerkung VARCHAR2(255)
    After calling FillSchema on this table the PrimaryKey property of the DataTable contains 2 columns: KAPAZITAET_ID and KAPAZITAET.
    The same happens with other tables and similar column names
    R. Lüthke

    Tony, I'm gonna find time to try this because I was thinking it probably would be a double check.
    BUT... Oracle is written in C, and I imagine the extra check as a simple if comparison for the new value versus a constant NULL value. Kind of like checking for end of string. It's already doing things like checking datatypes and that as it inserts data, and I don't think this additional check (if it even exists) would add any significant overhead.
    But unless I find a much larger performance hit than I expect, I'm gonna stick with creating the NOT NULL's explicitly. Good data modelling trumps small performance tricks for me.
    My main worry is if/when somebody removes the primary key constraint (such as the example above where they might do a CREATE TABLE x AS SELECT * FROM y). Or if the data model gets updated to where the primary key becomes just a unique key, then the NOT NULL goes away when it shouldn't. I don't like basic table and column properties changing.
    Okay.. test done. Ran about 31,000 records from dba_tables through an insert into two tables, both with primary keys and one with explicit NOT NULLs. No measurable difference in stats detected.
    With NOT NULL and PRIMARY KEY:
    call count cpu elapsed disk query current rows
    Parse 1 0.35 0.35 0 0 0 0
    Execute 1 1.88 1.83 0 24792 35887 30954
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 2.24 2.18 0 24792 35887 30954
    Now with only PRIMARY KEY.
    call count cpu elapsed disk query current rows
    Parse 1 0.37 0.36 0 0 0 0
    Execute 1 1.87 1.83 0 24792 35887 30954
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 2.24 2.19 0 24792 35887 30954

  • How to set two attributes as  a primary key in database ?

    how to set two attributes as a primary key?
    Take COffeesbreak as an example ,
    let's suppose that there are cof_name ,sup_id,price and so on;
    the same cof_name may be suplied by more sup_ids,
    and one sup_id may suply more cof_names.
    so the Primary key should be set the cof_name and sup_id ,
    how to set ?
    (of course that i konw if I set a cof_id,the problem will be easy work out
    but now there are those like above)
    I set that as following:
    create table coffees (cof_name VARCHAR(32) PRIMARY KEY,sup_id INTEGER, PRIMARY KEY,PRICE INTEGER )
    THE database print error :cant add more primary keys!
    thanks in advance

    You can only use the PRIMARY KEY declaration on a column if it is the only Primary Key column.
    Use the PRIMARY KEY constraint statement instead.
    create table coffees (
      cof_name VARCHAR(32),
      sup_id INTEGER,  
      PRICE INTEGER,
      PRIMARY KEY ( cof_name ,sup_id )
    )Dave

  • Primary Key for Read Only Entity Beans In EJB 3.0

    Hi,
    I have checked the spec for ejb 3.0 which mentions that, there is no common standard for the vendor to implement the Read only Entity Beans.
    My question over here is how it is implemented in OC4J??
    Do we need to specify a primary key attribute in the read-only entity bean?
    w.r.t BC4J(ADF) i remember, we used to create a read-only View Object with out specifying a primary key.
    Just want to check is that the way it works in EJB 3.0 (Implemented by OC4J).
    Thanks for your help in advance.
    Shiva

    Hi,
    Try using the JBoss embedded container:
    http://docs.codehaus.org/display/MAVENUSER/How+to+use+the+JBoss+Embedded+EJB3+Container+for+Unit+testing
    /klejs

Maybe you are looking for

  • How do I get Discoverer 3.1 to read data from Paradox 8.0?

    The on-line manual for version 3.1.36.06 of the Discoverer Admin product suggests that you can read in data from non-Oracle databases. The following steps are from the on-line manual instructions about creating a new business area: 1. From the File m

  • DVD not showing up

    At some point, my TiBook just gave up the ghost of CDs/DVDs, it played them fine then suddenly, it would accept them but not show them on the hard drive. Any thoughts on whether this is a software issue or a hardware issue?

  • Clearing Google Search Results.

    Hello, Does anyone know if it is possible to clear the results for previous searched google items when they automatically pop up in safari? Thanks!

  • BB Z10 not being recognized as usb device in W8

    I just upgraded to the Z10 from my 9800 and used BB Link to transfer all the details to the new phone. I also have a new Dell AIO with w8. After downloading all the data from the 9800 and plugged in the Z10, the Dell didn't recognise that a new usb d

  • KKS2 can't calculate the variance in the production order

    We have some simi-finished product orders.  All these simi-finished products  were produced in previous period and got receipted into the warehouse. However, for some reason we don't know, there are still some cost balance remain in the orders themse