APEX don't allow modify rows in columns which are Primary Key ?

I have tables:
http://img508.imageshack.us/my.php?image=21269582oe8.jpg
book(id_book - "Primary Key", title, year); book_author(id_book - "Primary Key", id_author - "Primary Key"); author(id_author - "Primary Key", name)
I have created a new page -> Form -> Tabular Form for table 'author' because I would like to add new authors, modify and delete. During creating this page I have choosen column 'id_author' as 'primary key column 1' and everything is OK (I can't modify column 'id_author' - this column is autoincrement and I can modify column 'name').
BUT I have also created a new page -> Form -> Tabular for table 'book_author' because I would like to write numbers as id_book and id_author, modify and delete them (so add relations between tables: book, book_author and author). During creating this page I have choosen column 'id_book' as 'primary key column 1' and 'id_author' as 'primary key column 2'. And on website I can't modify (edit) these fields. And I can't also add new row because I see in each column in new row: (null).
http://img444.imageshack.us/my.php?image=11324615yk9.jpg
APEX don't allow modify rows in columns which are Primary Key ? This is stupid....... What can I do ?
Edited by: user10731158 on 2008-12-20 11:40

Single-column and non-meaningful so you never want to update them. In the case of your example, you would need to add an ID column to the book_author intersection table. Honestly, I was so blown away (and pleasantly surprised) by the lack of rebuttal and the "thx" that I went ahead and put together an example of how I would define the book_author table:
create table  book_author
   (id varchar2(32),
    book_id varchar2(32),
     author_id varchar2(32),
     modified_on     date,
     modified_by varchar2(255),
     constraint book_author_pk primary key (id),
     constraint book_auth_book_fk foreign key (book_id) references books(id),
     constraint book_auth_author_fk foreign key (author_id) references authors(id)
create unique index book_author_uq on book_author (book_id,author_id)
create or replace trigger  biu_book_author before insert or update on book_author
for each row
begin     
     if inserting then
          :new.id := sys_guid();
     end if;
     modified_on := sysdate;
     modified_by := nvl(v('APP_USER'),user);
end;
/Good luck,
Tyler

Similar Messages

  • Delete Rows from T1 which are Not in T2

    Hi
    I've 2 Tables like below
    T1
    N1
    N2
    2
    11
    2
    22
    3
    33
    8
    44
    8
    88
    T2
    N1
    N2
    2
    22
    8
    88
    If I Run Delete query, I must delete Rows from T1 which are Not in T2
    For example, I must delete Rows 1,3,4 from T1
    So how to write that delete query? Please advice

    Delete from T1
    Where not Exists (select * from T2 Where t1.N1=t2.N1 and t1.N2=t2.N2)
    --or
    Delete t
    From t1 t
    left JOIN t2 m
    ON m.N1=t.N1 and m.N2=t.N2
    WHERE m.N1 is null and m.N2 is null
    --Or
    ;With mycte as
    select N1,N2 from T1
    Except
    select N1,N2 from T2
    Delete t
    From t1 t
    INNER JOIN mycte m
    ON m.N1=t.N1 and m.N2=t.N2

  • Trying to use 2 different Dimension tables and make a hierarchy on some columns which are split into these dimensions .. how do I do that

    Trying to use 2 different Dimension tables and make a hierarchy on some columns which are split into these dimensions .. how do I do that

    If you need to make a hierarchy in an Attribute view you need to have all relevant fields/columns in the same Dimension table..

  • How do you freeze a row or column which is not a header in Numbers '09?

    Just wondering if anyone has worked out how to freeze a chosen row or column? I know you can do it with header rows, but the row I want to freeze is row 4. I'm using Numbers '09.
    And is it right that you cannot link cells between different documents in Numbers, as I used to in Excel?
    All help much appreciated!

    Using Numbers you cannot reference a cell in another document.
    I do not think you can freeze non-header rows.  You can make up to 5 rows part of the header:
    Then freeze the headers.

  • How can I modify a column to a primary key column

    Hi,
    I've created a table with no primary key. How I can set the primary key column now? The datatype of the "primary key" column is Raw(35).
    Thanks,
    Mike

    Mike,
    Issue the following command:
    ALTER TABLE table_name
    ADD CONSTRAINT constraint_name PRIMARY KEY(column_name);
    NOTE: If you want to place the primary key data in a separate tablespace, then you can add the key word USING INDEX TABLESPACE after the column_name.
    Regards,
    John

  • Find columns which are null

    Hello all, I am currently developing a data warehouse that holds time-series values. In the 5-min interval fact table, there is a column for every 5-minute segment of a 12 hour period. So I have a few foreign keys which make up a composite primary key in the fact table, followed by generally-named columns m0,m5,m10...m1145,m1150,m1155 (m0 represents 00:00 [12:00] and m1155 represents 11:55). There is a flag in the row to denote AM or PM. This database collects various metrics from a Coherence environment for a live monitoring solution that also has a Historian to track trends, get a graphical historical overlay against the current values coming into the live environment, etc.
    So I have this table with aggregation at a 5 minute level and will need to roll this up to hourly and daily aggregation levels during an ETL process. I'd like to be able to pinpoint which data, if any, has holes in it IE the collectors hiccupped somewhere for whatever reason and did not report a 5 minute segment to me.
    Is there anyway to find rows which have null values and to report back which column names contain null values? A use case would be that I have a row in the 5 min fact table that contains a null value for column m455, which means that there is a gap in my time series at the 4:55 hour for that object. During ETL roll ups, I'd like to be able to record which time slot has "holes", or null values in them so that we can pinpoint why they occur to prevent them from occurring again during the development process of this solution.
    Thanks for anyone's help!!
    Regards,
    TimS

    TimS wrote:
    create table f_metric_5_min (
         metric_key number(10) not null,
         object_key number(19) not null,
         date_key number(5) not null,
         segment_id number(1) not null,
         m0 number(19,4),
         m5 number(19,4),
         m10 number(19,4),
         m15 number(19,4),
         m20 number(19,4),
         m25 number(19,4),
         m30 number(19,4),
         m35 number(19,4),
         m40 number(19,4),
         m45 number(19,4),
         m50 number(19,4),
         m55 number(19,4),
         m100 number(19,4),
         m105 number(19,4),
         m110 number(19,4),
         m115 number(19,4),
         m120 number(19,4),
         m125 number(19,4),
         m130 number(19,4),
         m135 number(19,4),
         m140 number(19,4),
         m145 number(19,4),
         m150 number(19,4),
         m155 number(19,4),
         m200 number(19,4),
         m205 number(19,4),
         m210 number(19,4),
         m215 number(19,4),
         m220 number(19,4),
         m225 number(19,4),
         m230 number(19,4),
         m235 number(19,4),
         m240 number(19,4),
         m245 number(19,4),
         m250 number(19,4),
         m255 number(19,4),
         m300 number(19,4),
         m305 number(19,4),
         m310 number(19,4),
         m315 number(19,4),
         m320 number(19,4),
         m325 number(19,4),
         m330 number(19,4),
         m335 number(19,4),
         m340 number(19,4),
         m345 number(19,4),
         m350 number(19,4),
         m355 number(19,4),
         m400 number(19,4),
         m405 number(19,4),
         m410 number(19,4),
         m415 number(19,4),
         m420 number(19,4),
         m425 number(19,4),
         m430 number(19,4),
         m435 number(19,4),
         m440 number(19,4),
         m445 number(19,4),
         m450 number(19,4),
         m455 number(19,4),
         m500 number(19,4),
         m505 number(19,4),
         m510 number(19,4),
         m515 number(19,4),
         m520 number(19,4),
         m525 number(19,4),
         m530 number(19,4),
         m535 number(19,4),
         m540 number(19,4),
         m545 number(19,4),
         m550 number(19,4),
         m555 number(19,4),
         m600 number(19,4),
         m605 number(19,4),
         m610 number(19,4),
         m615 number(19,4),
         m620 number(19,4),
         m625 number(19,4),
         m630 number(19,4),
         m635 number(19,4),
         m640 number(19,4),
         m645 number(19,4),
         m650 number(19,4),
         m655 number(19,4),
         m700 number(19,4),
         m705 number(19,4),
         m710 number(19,4),
         m715 number(19,4),
         m720 number(19,4),
         m725 number(19,4),
         m730 number(19,4),
         m735 number(19,4),
         m740 number(19,4),
         m745 number(19,4),
         m750 number(19,4),
         m755 number(19,4),
         m800 number(19,4),
         m805 number(19,4),
         m810 number(19,4),
         m815 number(19,4),
         m820 number(19,4),
         m825 number(19,4),
         m830 number(19,4),
         m835 number(19,4),
         m840 number(19,4),
         m845 number(19,4),
         m850 number(19,4),
         m855 number(19,4),
         m900 number(19,4),
         m905 number(19,4),
         m910 number(19,4),
         m915 number(19,4),
         m920 number(19,4),
         m925 number(19,4),
         m930 number(19,4),
         m935 number(19,4),
         m940 number(19,4),
         m945 number(19,4),
         m950 number(19,4),
         m955 number(19,4),
         m1000 number(19,4),
         m1005 number(19,4),
         m1010 number(19,4),
         m1015 number(19,4),
         m1020 number(19,4),
         m1025 number(19,4),
         m1030 number(19,4),
         m1035 number(19,4),
         m1040 number(19,4),
         m1045 number(19,4),
         m1050 number(19,4),
         m1055 number(19,4),
         m1100 number(19,4),
         m1105 number(19,4),
         m1110 number(19,4),
         m1115 number(19,4),
         m1120 number(19,4),
         m1125 number(19,4),
         m1130 number(19,4),
         m1135 number(19,4),
         m1140 number(19,4),
         m1145 number(19,4),
         m1150 number(19,4),
         m1155 number(19,4),
         constraint f_metric_5_min_pk primary key (metric_key, object_key, date_key, segment_id),
         constraint f_metric_5min_fk_metric_key foreign key (metric_key) references d_metric (metric_key),
         constraint f_metric_5min_fk_object_key foreign key (object_key) references d_object (object_key),
         constraint f_metric_5min_fk_date_key foreign key (date_key) references d_date (date_key)
    ) partition by range(date_key) (
         PARTITION def values less than (2558)
    ) tablespace FACT;The reason to define separate columns for time intervals is because need to see data coming from Coherence enviroment in 5 minute intervals, creating a row for each 5 min interval for each object (thousands) is too time-consuming. Using MERGE is much faster to update columns in the same row. And secondly, because my job tells me to go with this logical model :).
    I can understand the "job-tells-me" reason but not sure am convinced with the "time-consuming" issue,
    especially as it is a datawarehouse. But I assume you must have verified the same.:)
    The NULL-finding exercise will be done after the data is loaded into the 5 minute metric table and before the hourly roll-up ETL.
    Not sure what you mean in what format, I plan to build a list and place them into a form of auditing table within the database that will be queried in the future to determine where the gaps are and for what objects so that we can trace them back to a certain JVM and coherence collector and fix the issue from occuring again; hence the point of a monitoring tool.
    Storing time in a table can take up a lot of space and is harder to compute procedurally. In this model the database does not care about the time, only the data; the date and time is not a focal point for this database, the database is abstract, with the Java behind it controlling the purpose of its data. The reporting engine after-the-fact cares about dates and such which can be easily determined by referencing to dimension tables to determine which column represents which time in the 12 hour sequence.
    Going back to the "null-finder" do you think there is any way to do this? Thanks for your help!
    Regards,
    TimSDo you mean that you want to get only those columns where there is a NULL value, for a record-at-a-time ?
    In that case, the only option that I can think of is building a Dynamic SQL, based on checking whether each column has a NULL value or not. Although, I hope somebody can come up with a better way to achieve the same.
    (Else, your not considering "time-consuming" approach above becomes not much of advantage, isn't it ?) :)
    (Of course, only if "null-finding" is a MUST exercise...)

  • Creating a row trigger to populate the primary key

    to populate the primary key of a table automatically, i created a sequence named rule_id
    using the following statement:
    create sequence rule_id;
    and then i created a trigger to populate the primary key using the statements below:
    CREATE OR REPLACE
    TRIGGER RULE_ID BEFORE INSERT ON DOC_CATS_RULE_BASED_CLASS
    FOR EACH ROW
    BEGIN
    SELECT SEQ_RULE_BASED_CLASS.NEXTVAL
    INTO :new.id FROM DUAL;
    END;
    i took this from a books example. but it gives and error called:
    Error(3,8): PLS-00049: bad bind variable 'NEW.ID'
    What is wrong and what is the current way to do it?
    Please help!

    Hi ,
    The new denotes the new data values for the table relative column.....
    As regards the dual is a small table in the data dictionary that Oracle 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.
    Regards,
    Simon

  • What index is suitable for a table with no unique columns and no primary key

    alpha
    beta 
    gamma
    col1
    col2
    col3
    100
    1
    -1
    a
    b
    c
    100
    1
    -2
    d
    e
    f
    101
    1
    -2
    t
    t
    y
    102
    2
    1
    j
    k
    l
    Sample data above  and below is the dataype for each one of them
    alpha datatype- string 
    beta datatype-integer
    gamma datatype-integer
    col1,col2,col3 are all string datatypes. 
    Note:columns are not unique and we would be using alpha,beta,gamma to uniquely identify a record .Now as you see my sample data this is in a table which doesnt have index .I would like to have a index created covering these columns (alpha,beta,gamma) .I
    beleive that creating clustered index having covering columns will be better.
    What would you recommend the index type should be here in this case.Say data volume is 1 milion records and we always use the alpha,beta,gamma columns when we filiter or query records 
    what index is suitable for a table with no unique columns and primary key?
    col1
    col2
    col3
    Mudassar

    Many thanks for your explanation .
    When I tried querying using the below query on my heap table the sql server suggested to create NON CLUSTERED INDEX INCLUDING columns    ,[beta],[gamma] ,[col1] 
     ,[col2]     ,[col3]
    SELECT [alpha]
          ,[beta]
          ,[gamma]
          ,[col1]
          ,[col2]
          ,[col3]
      FROM [TEST].[dbo].[Test]
    where   [alpha]='10100'
    My question is why it didn't suggest Clustered INDEX and chose NON clustered index ?
    Mudassar

  • MERGE - WHEN MATCHED (for a table with 2 column that are the keys)

    Hi
    I am using merge to insert/update a table whenever new records come in.
    My question is if the table has 2 columns and both are a part of the primary key, do I need to have the merge statement "when matched" as well? Since both the columns are part of the key, when matched wont make sense here. I will only need when not matched, then insert.
    Please correct if I am wrong.
    Thx!

    You need to be matchning/not matching on the whole primary key. Matched and not matched are required before 10G.
    MERGE   INTO table1 loctab
           USING (SELECT colpk1,
                         colpk2,
                         col3,
                         col4
                  FROM   table2) remtab
              ON (loctab.colpk1 = remtab.colpk1 AND loctab.colpk2 = remtab.colpk2)
    WHEN MATCHED
    THEN
      UPDATE SET loctab.col3 = remtab.col3,
                        loctab.col4 = remtab.col4
    WHEN NOT MATCHED
    THEN
      INSERT          (loctab.colpk1,
                           loctab.colpk2,
                           loctab.col3,
                           loctab.col4
      VALUES   (remtab.colpk1,
                    remtab.colpk2,
                    remtab.col3,
                    remtab.col4
                   );

  • Add new Column to existing Primary Key

    Hi,
    I have a Primary key consisting of 6 columns. Now i want to add new 7th column to that existing key.
    Do i need to drop the existing primary key and then recreate agian with 7th field or is there any other way?
    Regards,
    Jayesh

    I think what Joel was really saying is that dropping/recreating a PK is the only way to change the PK column list in version 6 - 9. Who knows about in 10g? Though I doubt that this has changed.
    If the table only has one or two more columns that are not part of the key you might consider converting the table to being an IOT (indexed organized table).
    HTH -- Mark D Powell --

  • Maximum number of column in Composite Primary Key

    Hi
    I have read that composite primary key can contain maximum of 32 columns (Oracle 9i).
    However I am able to create a primary key on 33 columns. It fails to create primary key on 34 columns. Below are the queries.
    DROP TABLE XYZ;
    CREATE TABLE XYZ
    ( N1 NUMBER
    ,N2 NUMBER
    ,N3 NUMBER
    ,N4 NUMBER
    ,N5 NUMBER
    ,N6 NUMBER
    ,N7 NUMBER
    ,N8 NUMBER
    ,N9 NUMBER
    ,N10 NUMBER
    ,N11 NUMBER
    ,N12 NUMBER
    ,N13 NUMBER
    ,N14 NUMBER
    ,N15 NUMBER
    ,N16 NUMBER
    ,N17 NUMBER
    ,N18 NUMBER
    ,N19 NUMBER
    ,N20 NUMBER
    ,N21 NUMBER
    ,N22 NUMBER
    ,N23 NUMBER
    ,N24 NUMBER
    ,N25 NUMBER
    ,N26 NUMBER
    ,N27 NUMBER
    ,N28 NUMBER
    ,N29 NUMBER
    ,N30 NUMBER
    ,N31 NUMBER
    ,N32 NUMBER
    ,N33 NUMBER
    ,N34 NUMBER
    ,N35 NUMBER
    ,N36 NUMBER
    ,N37 NUMBER
    ,N38 NUMBER
    ,N39 NUMBER
    ,N40 NUMBER
    ,N41 NUMBER
    ,N42 NUMBER
    ,N43 NUMBER
    ,N44 NUMBER
    ,N45 NUMBER
    ,N46 NUMBER
    ,N47 NUMBER
    ,N48 NUMBER
    ,N49 NUMBER
    ,N50 NUMBER
    ALTER TABLE XYZ ADD CONSTRAINT XYZ_PK PRIMARY KEY
    ( N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14
    ,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26
    ,N27,N28,N29,N30,N31,N32,N33,N34);
    ALTER TABLE XYZ ADD CONSTRAINT XYZ_PK PRIMARY KEY
    ( N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14
    ,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26
    ,N27,N28,N29,N30,N31,N32,N33);
    Can someone let me know the lmit of maximum no. of columns in Primary Key?
    Regards
    Arun

    SQL> select * from v$version;
    BANNER                                                                         
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production                     
    PL/SQL Release 9.2.0.1.0 - Production                                          
    CORE     9.2.0.1.0     Production                                                      
    TNS for 32-bit Windows: Version 9.2.0.1.0 - Production                         
    NLSRTL Version 9.2.0.1.0 - Production                                          
    SQL> ALTER TABLE XYZ ADD CONSTRAINT XYZ_PK PRIMARY KEY
      2  ( N1,N2,N3,N4,N5,N6,N7,N8,N9,N10,N11,N12,N13,N14
      3  ,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26
      4  ,N27,N28,N29,N30,N31,N32,N33);
    Table altered.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • ForeignKey Referencing only one column of a primary key created on 2 column

    Let me explain the scenario
    Table1
    =====
    studentno
    identityno
    marks
    above table has primary key on - studentno and identityno
    Table2
    =====
    studentno
    remarks
    now, because 2nd table has just studentno and not identityno, we cant add foreign key studentno but the requirement is to have some kind of referential integrity constraint on studentno of table2, so that it checks if that is present in table1
    Is there any way to solve this ?

    Homework?
    Yes this is possible by adding an unique constraint on Table1.StudentNo. Also, since StudentNo will then be subject to two different unique constraints in Table1, inserting a row in Table1 would be a headache.
    Another alternative would be to have a trigger on Table2 which checks the integrity but that is re-inventing the wheel.
    but the requirement is to have some kind of referential integrity constraint on studentno of table2, so that it checks if that is present in table1I would rather re-design the table structure in this case. Current structure makes no sense to me.
    Message was edited by:
    Satish Kandi
    @Leo: Sorry I did not refresh before posting so did not see your response.

  • Vf01-should allow only those billing doc which are used

    Hai gurus,
           In Tcode VF01 for the field "Billing document" it displays all billing doucments which are in table TVFK(Billing doc types).
    My Requirement is that for the field "Billing doucment" only those billing documents should appear which we are using.
    How could this rqt be fulfilled?
    Thanks in advance

    I think this may not be possible in Std SAP. You migh have to write a code to do this.
    But what can be done is that for a set of users we can define certain screens with specific billing types and thus restrict them from using other billing types.
    This may be done using SHD0 t.code.
    Regards,
    Mani

  • I recently purchased a Macbook Pro w/Snow Leopard.  Subsequently I installed Microsoft Office v.X.  I am getting some unexpected results in Excel and Word.  For Excel the row and column headings are missing and I cannot print.  Work won't print.

    I guess the basic question is ... will Microsoft Office v.X work correctly with MAC OS X 10.6.8?

    m2quared wrote:
    will Microsoft Office v.X work correctly with MAC OS X 10.6.8?
    Since MS stopped supporting Office X a couple of years before SL's release, my guess is no.

  • How to create table with dynamic amount of columns which are nested columns

    M trying to fetch data and show in a javaFX table.
    My table displays the details of different items from ItemVO , where :
    public class ItemVO()
    String itemName;
    List<ItemTypeVO> type;
    and My ItemTypeVO has the following attributes :
    public class ItemTypeVO()
    String typeName;
    Integer quantity;
    Integer price;
    Now, i want to display the details of an item in a table in which the itemname and quantity will be displayed, the quantity column will have nested columns showing different types(typeName) as found from List<ItemTypeVO> inside ItemVO.
    This question is similar to this link but my not able to find how to link a list with itemVO for nested columns. :(
    Please help !!
    M still unable to find a solution..
    Edited by: abhinay_a on Jan 14, 2013 10:50 AM

    Hi Abhilash,
    Thanks for the quick reply.
    Actually the problem is with the image, as I am not able to rotate 270 degree. Crystal report cannot support the rotation of image.
    i have another problem, I have to create a report in which
    Lables are fixed on the left side of report and 3 columns per portrait page. Those columns are
    dynamically created and shown in the report.
    The format is like the above. Can you please help me in doing this report, as I tried it doing
    with CrossTab. I am really stuck to this report.

Maybe you are looking for