Null value in detail table's primary key

I use Business Components Data Form to define a master-detail java panel.
I don't display the primary key column in the detail grid control.
Then I click on "+" to add a row, enter a value (the 2nd part of the detail table's primary key) and click commit.
I get an error saying that the primary key column that's not displayed is null and the row cann't be committed.
How do I fix this error?

My fields are varchar2's.
-- simplified to protect the guilty:
-- (made up from memory, so sql keywords may --be misspelled, but you get the idea)
create table proj (
proj varchar2(10) not null,
constraint proj_pk
primary key(proj)
insert into proj values ('abc');
commit;
-- this table has legal values for -- the master.legal field.
-- in master, legal was changed to a -- ComboBoxControl control from -- TextFieldControl that the wizard -- generated.
create table legal_values (
proj varchar2(10) not null,
legal varchar2(10) not null,
display_order integer not null,
constraint legal_values_pk
primary key (proj, legal)
insert into legal_values
values ('abc', 'one', 1);
insert into legal_values
values ('abc', 'two', 2);
insert into legal_values
values ('abc', 'three', 3);
commit;
create table master (
proj varchar2(10) not null,
masterKey varchar2(15) not null,
legal varchar2(10) not null,
constraint master_pk
primary key (proj, masterKey)
create table detail (
proj varchar(10) not null,
masterKey varchar(15) not null,
detailkey varchar(10) not null,
display_order integer not null,
status varchar2(12) not null, -- user can only update this field
constraint detail_pk
primary key(proj, masterkey, detailkey)
-- legal rows for detail table
create table detail_values (
proj varchar2(10) not null,
detailkey varchar2(10) not null,
display_order integer not null,
constraint detail_values_pk
primary key(proj, detailkey)
insert into detail_values values
('abc', 'status a', 1);
insert into detail_values values
('abc', 'status b', 2);
commit;
-- if their is a foriegn key on details back
-- to master, then you get the
-- "mutating table" error when trigger
-- occurs.
create or replace trigger master_tr
after insert on master
for each row
begin
insert into detail
(masterKey, detailKey, status, display_order, status)
select :new.masterkey, detail_key, display_order, ' '
from detail_values;
end;
-- detail.status is a comboboxControl getting --its values of of another db table too.
-- there's also "after update" triggers on master and detail tables that copy the record to master_history and "detail_history" tables if the corresponding table is modified. Thus we have a history of the changes made to the records. The 2 history tables have 2 additional fields than their parents, "modified_date date default sysdate not null" and "modified_by varchar2(30) default user not null" that record when and who made the change. There's also a change type field that records where the change is an insert, delete or update (there 3 triggers per table , so we can correctly record change type as being insert, delete or update into the change_type field).
If you want to make it more real to life, the status value is initially blank, then can be changed to a legal status value (complete or not complete), but can not be changed back to blank.
***P.S. I have to have this ready for production by monday.****
P.P.S After you reply and change to ComboBoxControls in 2 places, try changing the table names and/or the column names (say to follow the DBA's naming convention) or add another field to the composite primary key (and unstated foriegn key) (using drop table/create table). Now try getting the existing code to run. No writing down the old/new table (or column) name pair names. Just run the code and try to fix the code based on the error messages. Are the error messages giving you adequate information to find the problem?

Similar Messages

  • How to add a new data element for existing table filed(Primary key field)

    Hi Experts,
    How to add a new data element for existing table field(Primary key field)
    For this filed ther is no foreign key relation ships and even check table.
    while activating table it is giving message like below.
    can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
    Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)           
    Primary key change not permitted for value table /TC/VENDOR
    Check on table  /TC/VENDOR resulted in errors              
    Thanks
    Ravi

    Hi,
    Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
    You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
    Maybe there are other ways, but this works.
    Success,
    Rob

  • Table and Primary Key Case Sensitive in Automated Row Fetch

    Why are the table and primary key fields case sensitive in the Automated Row Fetch process? I'm debugging an error in this process and I'm not sure what the case should be.

    Russ - It's a defect of sorts. Use upper case in the process definition. I don't think these processes will work with tables or columns whose names are not known to the database as upper-case values, i.e., defined using double-quoted non-upper case.
    Scott

  • How to delete null values in a table

    hi all,
    tell me please any one how to delete null values in a table
    example:
    in emp table is there
    empno ename job mgr sal deptno
    7900 scott 7902 2000 10
    7499 clerk 7900 20
    7834 james manager 3000 30
    like this in the above emp table there are some null values are there
    so how to delete the null values in emp table
    thanks,
    regards.
    Edited by: user9195968 on Feb 25, 2010 6:30 AM

    not too sure what you mean, perhaps you could supply a table description and some sample data
    but, consider
    delete from table_1 where column_1 is null
    commit
    /

  • Every table need primary key in toplink mapping to fetch the data

    Hi everyone,
    we are working on toplink mapping , it neccessary every table needs primary key. if yes, gave me example.

    Hi everyone,
    Alterations in database will not be automatically reflected in toplink so, there is any alternative
    with regards
    abusufian

  • Dynamic SQL Joining between tables and Primary keys being configured within master tables

    Team , Thanks for your help in advance !
    I'm looking out to code a dynamic SQL which should refer Master tables for table names and Primary keys and then Join for insertion into target tables .
    EG:
    INSERT INTO HUB.dbo.lp_order
    SELECT *
    FROM del.dbo.lp_order t1
    where not exists ( select *
    from hub.dbo.lp_order tw
    where t1.order_id = t2.order_id )
    SET @rows = @@ROWCOUNT
    PRINT 'Table: lp_order; Inserted Records: '+ Cast(@rows AS VARCHAR)
    -- Please note Databse names are going to remain the same but table names and join conditions on keys
    -- should vary for each table(s) being configured in master tables
    Sample of Master configuration tables with table info and PK Info :
    Table Info         
    Table_info_ID    Table_Name    
    1        lp_order    
    7        lp__transition_record    
    Table_PK_Info        
    Table_PK_Info_ID    Table_info_ID    PK_Column_Name
    2                1    order_id
    8                7    transition_record_id
    There can be more than one join condition for each table
    Thanks you !
    Rajkumar Yelugu

    Hi Rajkumar,
    It is glad to hear that you figured the question out by yourself.
    There's a flaw with your while loop in your sample code, just in case you hadn't noticed that, please see below.
    --In this case, it goes to infinite loop
    DECLARE @T TABLE(ID INT)
    INSERT INTO @T VALUES(1),(3),(2)
    DECLARE @ID INT
    SELECT @ID = MIN(ID) FROM @T
    WHILE @ID IS NOT NULL
    PRINT @ID
    SELECT @ID =ID FROM @T WHERE ID > @ID
    So a cursor would be the appropriate option in your case, please reference below.
    DECLARE @Table_Info TABLE
    Table_info_ID INT,
    Table_Name VARCHAR(99)
    INSERT INTO @Table_Info VALUES(1,'lp_order'),(7,'lp__transition_record');
    DECLARE @Table_PK_Info TABLE
    Table_PK_Info_ID INT,
    Table_info_ID INT,
    PK_Column_Name VARCHAR(99)
    INSERT INTO @Table_PK_Info VALUES(2,1,'order_id'),(8,7,'transition_record_id'),(3,1,'order_id2')
    DECLARE @SQL NVarchar(MAX),
    @ID INT,
    @Table_Name VARCHAR(20),
    @whereCondition VARCHAR(99)
    DECLARE cur_Tabel_Info CURSOR
    FOR SELECT Table_info_ID,Table_Name FROM @Table_Info
    OPEN cur_Tabel_Info
    FETCH NEXT FROM cur_Tabel_Info
    INTO @ID, @Table_Name
    WHILE @@FETCH_STATUS = 0
    BEGIN
    SELECT @whereCondition =ISNULL(@whereCondition+' AND ','') +'t1.'+PK_Column_Name+'='+'t2.'+PK_Column_Name FROM @Table_PK_Info WHERE Table_info_ID=@ID
    SET @SQL = 'INSERT INTO hub.dbo.'+@Table_Name+'
    SELECT * FROM del.dbo.'+@Table_Name+' AS T1
    WHERE NOT EXISTS (
    SELECT *
    FROM hub.dbo.'+@Table_Name+' AS T2
    WHERE '+@whereCondition+')'
    SELECT @SQL
    --EXEC(@SQL)
    SET @whereCondition = NULL
    FETCH NEXT FROM cur_Tabel_Info
    INTO @ID, @Table_Name
    END
    Supposing you had noticed and fixed the flaw, your answer sharing is always welcome.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Inserting duplicate values when only MANDT is primary key

    Hello experts,
    I have 4 fields in my UDT(user defined table) namely MANDT, ZEVENT, ZRECIPIENT and ZEMAIL.
    Now, Only MANDT is the primary key. My question is, how can I insert duplicate values
    via SM30?
    Again, thank you guys and take care!

    Hi again,
    1. open the Layout of that screen
    2. using drag&drop
       just REMOVE the field from the table control.
    3. Also
    4. In the flow logic of that screen,
       remove the line / commen it
       which has been put in CHAIN
      for eg.
       FIELD YHRT_FUNMST-FUNSORT .
    5. Activate everything
    6. try again via sm30 in new session.
    7. NOW IT WILL WORK. I JUST TRIED IT.
    regards,
    amit m.

  • Insert into table returning primary key (auto number) in resultset

    Hi,
    I'm connecting to Oracle 10g via JDBC (ojdbc14.jar).
    My SQL statement is as follows:
    INSERT into Student (studentName, phone, email, address) values ('Jason', '12345678', 'test', 'test');
    SELECT Student_studentId_SEQ.NEXTVAL FROM DUAL;
    Fyi -The Student table has a trigger to support the generation of a primary key (integer) based on a sequence when a new record is inserted.
    What the above will do (from the Java app point of view) is to create a Student record and automatically select the student ID so that the student ID can be accessed via the resultset in Java.
    I'm getting error "ORA-00911: invalid character". Can you please help?
    Regards,
    Jason
    Edited by: user10394130 on Oct 13, 2008 2:40 AM

    Yes, I'm referring to the studentId, which is generated via the Student table trigger on insert of a new record.
    I've now verified that the following SQL works and it is "printing" the correct studentId.
    DECLARE seqNbr_studentId NUMBER(12) := 0;
    BEGIN
    INSERT into Student (studentName, phone, email, address) values ('Jason', '12345678', 'test', 'test')
    RETURNING studentId INTO seqNbr_studentId;
    dbms_output.put_line(seqNbr_studentId);
    END;
    --> This prints the correct value of seqNbr_studentId that has been generated by the trigger. This is good.
    However, I would like the studentId to be in a resultset (so that I can access this via Java Resultset.getInt(1) ), for example:
    DECLARE seqNbr_studentId NUMBER(12) := 0;
    BEGIN
    INSERT into Student (studentName, phone, email, address) values ('Jason', '12345678', 'test', 'test')
    RETURNING studentId INTO seqNbr_studentId;
    SELECT seqNbr_studentId FROM DUMMYTABLE;
    END;
    Is this possible?
    What I'm trying to do is to achieve the effect in SQL Server where I can simply do an SQL command "SELECT @@IDENTITY" where it returns the auto number from the newly inserted record.
    Regards,
    Jason
    Edited by: user10394130 on Oct 13, 2008 2:08 AM
    Edited by: user10394130 on Oct 13, 2008 2:56 AM

  • Does ADF Business Components  work well with tables without primary Key?

    We have tables using unique index without primary key. Can ADF Business Components relate business objects based on the unique index columns of the tables?

    Hi,
    Regarding my question about the XML syntax for custom properties:
    It turned out to be another problem in the Entity object definition that caused the JDeveloper error. Other entities let me add the custom property without problems. However should anybody ever need that XML syntax, here's how you add a custom property to an entity definition in the XML code:
      <Attribute
        Name="Id"
        IsNotNull="true"
        Precision="10"
        Scale="0"
        ColumnName="ID"
        Type="oracle.jbo.domain.Number"
        ColumnType="NUMBER"
        SQLType="NUMERIC"
        TableName="TABLE"
        PrimaryKey="true">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="22"/>
        </DesignTime>
        <Properties>
          <CustomProperties>
            <Property
              Name="SequenceName"
              Value="SEQ1"/>
          </CustomProperties>
        </Properties>   
      </Attribute>Best regards,
    Bart Kummel
    Edited by: Bart Kummel on Sep 8, 2009 1:14 PM

  • Table Creation & Primary Keys

    Hi there
    I have a table with the 1st 3 fields as primary keys. I now need to change this to other fields.. But these fields are in the middle of the table. Apparently the primary keys must be the first fields in the table so I have to move the fields I need up. The problem is it will influence my XI/PI development cause Im using substrings to get the correct fields and If I change the order of the fields my interfaces will not work anymore.. I there a way to set the primary keys without changing the order of the fields?
    Thanks,
    Jan

    Hi Jan,
         I think there is no other way to do it. All the primary keys should be declared in continuation at the begining of the table. Try to change your XI/PI development according to these entries.
    Regards,
    Swapna.

  • How to replace NULL values from main table

    Dear all,
    I like to remove the NULL values from a main table field. Or the question is how to replace any part of the string field in MDM repository main table field.
    e.g.   I have a middle name field partly the value is NULL in some hundreds of records, I like to replace NULL values with Space
    any recommendation.
    Regards,
    Naeem

    Hi Naeem,
    You can try using Workflows for automatically replacing NULLs with any specific value.
    What you can do is: Create a workflow and set trigger action as Record Import, Record Create and Record Update. So, that whenever any change will occur in the repository; that workflow will trigger.
    Now create an assignment expression for replacing NULLs with any specific value and use that assignment expression in your workflow by using Assign Step in workflow.
    For exiting records, you will have to replace NULLs manually using the process given by Preethi else you can export those records in an Excel spreadsheet which have NULLs and then replace all NULLs with any string value and then reimport those records in your MDM repository.
    Hope this will solve your problem.
    Regards,
    Varun
    Edited by: Varun Agarwal on Dec 2, 2008 3:12 PM

  • Null value in Nested table of nested table for xml guru Steve Muench

    The procedure I am using takes xml document with nested levels and insert into single table using DBMS_XMLSave.insertXML.
    I am able to insert into table without any error message but when I am selecting row from table, it is showing null values in all the column of nested table's inner nested table.
    When I am removing nested table's nested table by replacing with object type, it is showing data of object type for the first occurance and ignoring the rest nested occurance.
    Help is greatly appreciated.
    Below is the sql I used to create objects and table:-
    Create or Replace Type addressType as Object
    Line_one     varchar2(40),
    Line_two     varchar2(40),
    City          Varchar2(30),
    State          Varchar2(2),
    zip          Varchar2(10)
    Create or Replace Type ce_reqType as Object
    Status               varchar2(25),
    Status_date          Date,
    type_code          Varchar2(25),
    review_begin_date     Date,
    assigned_review_date     date
    Create or Replace type ce_reqListType
    as table of ce_reqType;
    Create or Replace Type LicenseType as Object
    type_code          Varchar2(10),
    license_number          Varchar2(16),
    ce_requirements      ce_reqListType
    Create or Replace type LicenseListType
    as table of LicenseType;
    Create table IndividualType
    individual_id          Number(9),
    social_security_number Varchar2(9),
    Last_name          varchar2(40),
    First_name          Varchar2(40),
    Middle_name          Varchar2(40),
    Birth_date          Date,
    address          addressType,
    Licenses          LicenseListType
    nested table licenses store as licensestab
    (nested table ce_requirements store as lic_ce_reqtab);

    Maddy wrote:
    dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)Because instead of adding an element to bookset collectionto are assigning (ergo replacing) it a collection containing last fetched book. Use:
    declare
        bookset book_table;
        ln_cnt pls_integer;
    begin
        bookset := book_table(book_obj('madhu','kongara','sudhan'));
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
        bookset := book_table(); --> Assigning back to NULL.
        dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
        for rec in (select * from book) loop --> Now Looping two times.
          dbms_output.put_line(' name > '||rec.name);
          bookset.extend;
          bookset(bookset.count) := book_obj(rec.name, rec.author, rec.abstract);
        end loop;
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
    end;
    The count is 1
    The count is 0
    name > Harry Potter
    name > Ramayana
    The count is 2
    PL/SQL procedure successfully completed.
    SQL> Or better use bulk collect:
    declare
        bookset book_table;
        ln_cnt pls_integer;
    begin
        bookset := book_table(book_obj('madhu','kongara','sudhan'));
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
        bookset := book_table(); --> Assigning back to NULL.
        dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
        select  book_obj(name,author,abstract)
          bulk collect
          into  bookset
          from  book;
        for i in 1..bookset.count loop --> Now Looping two times.
          dbms_output.put_line(' name > '||bookset(i).name);
        end loop;
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
    end;
    The count is 1
    The count is 0
    name > Harry Potter
    name > Ramayana
    The count is 2
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Null Values to internal tables

    I need to pass Null Value to couple of fields in Internal table and one of them is type i.
    Any way to do it?

    Here is the  sample code  of  it
    data :  begin of itab  occurs  0,
              field1(10)  type   c ,
              field2(10) type  i ,
              end of itab.
    itab-field1  =  ' '.
    itab-field2 = 0.0 .
    Append  itab .
    reward  points if it is usefull...
    Girish

  • Problem CREATE TABLE with PRIMARY KEY Still in Trouble ! Please Help!

    Hi there !
    I use the orcle 8i, and i don't know why i can't create table with any primary key EXample:
    SQL> CREATE TABLE O_caisses
    2 (No_caisse NUMBER(3) constraint caisses_pk PRIMARY KEY,
    3 NB_BILLETS NUMBER(5)
    4 )
    5 /
    CREATE TABLE O_caisses
    ERROR at line 1:
    ORA-18008: cannot find OUTLN schema
    ***********some Debuger show me this way: *********************
    Well there r certain point u got to notice when creating a table with constraints.
    1) U can create table with COLUMN level constraint.
    2) U can create table with TABLE level constraint.
    3) In COLUMN level constraint u can't give a constraint a name
    but only mention the type of constraint.
    4) In TABLE level constraint u can give a name to constraint.
    Following are the examples of both
    --COLUMN LEVEL
    CREATE TABLE O_caisses
    (No_caisse NUMBER(3) PRIMARY KEY,
    NB_BILLETS NUMBER(5));
    --TABLE LEVEL
    CREATE TABLE O_caisses
    (No_caisse NUMBER(3),
    NB_BILLETS NUMBER(5),
    constraint pk_caisse primary key (No_caisse));
    ********************And this is another one:*****************
    SQL>grant create any outline to username;
    BUT the problem is still present, i don't know what to do now !
    Please could some body help me !
    Thanks alot!
    Luong.

    The clue is in the error message: the OUTLN schema is missing.
    This is something Oracle 8i introduced to help manage the CBO (or soemthing equally geeky and internal). For some reason your database no longer has this user. It ought to be created automatically during installation (or upgrade) but catproct may not have completed probably or some over zealous admin type has dropped it.
    Solution is to re-install (or re-upgrade) as you cannot create this user on their own. Alas.
    HTH, APC

  • Problem on CREATING TABLES  with PRIMARY KEY

    Hi there !
    I use the orcle 8i, and i don't know why i can't create table with any primary key EXample:
    SQL> CREATE TABLE O_caisses
    2 (No_caisse NUMBER(3) constraint caisses_pk PRIMARY KEY,
    3 NB_BILLETS NUMBER(5)
    4 )
    5 /
    CREATE TABLE O_caisses
    ERROR at line 1:
    ORA-18008: cannot find OUTLN schema
    Please could some body help me !
    Thanks alot!
    Luong.

    Luong,
    Your syntax is fine. It looks like you don't have the correct database privileges to create the table. The error message you're getting suggests that you don't have CREATE ANY OUTLINE privileges. You should log in as a user than can grant these privileges and give yourself the correct privileges. I think the syntax is
    SQL>grant create any outline to username;
    Alison

Maybe you are looking for