1 Reply Latest reply: Jun 14, 2010 1:19 AM by SumitSharma RSS

    Usage of  Foreign Key

    526357
      Dear Members,

      I have developed a new OAF Page. In this page, I've the below tables:

      *1/ Table Name: Headers*
      +(Columns: Header_Id, Description,Status)+

      *2/ Table Name: Lines*
      +(Columns: Header_Id,Line_Id,Remarks)+

      While creating the above tables in database I have created the Lines table using the foreign key and linked it to the Headers table.

      In OAF as well I can see the foreign key defined.

      Now I'm running the page and tried to enter the data. I've got an error while saving the record saying cannot insert null into the header_id column of Lines table.

      Then I used the below code in my controller:

      String hdrId=am.getSequenceValue("SEQUENCE_HEADER_ID").toString();+

      headers_vo.getCurrentRow().setAttribute("HeaderId",hdrId);+

      lines_vo.getCurrentRow().setAttribute("HeaderId",hdrId);+

      The above code has resolved the problem.

      Here my doubt is when there is a foreign key why the header_id value is not getting copied automatically to the Lines Table. In forms 6i If we have a foreign key defined it gets copied automatically. In OAF is this feature not available?

      If it is available can any one please guide me.

      Many thanks in advance.

      Best Regards,
      Arun Reddy D.
        • 1. Re: Usage of  Foreign Key
          SumitSharma
          Hi Arun,

          I see your perspective, but OAF is built on a separate architecture than forms and handling of many functionalities are different here. As far as I understand in OA Framework, whenever a row is created you need to write code to set the Primary Key (may be in Create method of EO or something else). Hope that clarifies.

          Regards
          Sumit