How to insert data from APEX form into two tables

Hi,
I'm running APEX 4.1 with Oracle XE 11g, having two tables CERTIFICATES and USER_FILES. Some of the (useless) fields are cut to reduce information:
CREATE TABLE CERTIFICATES
CERT_ID NUMBER NOT NULL ,
CERT_OWNER NUMBER NOT NULL ,
CERT_VENDOR NUMBER NOT NULL ,
CERT_NAME VARCHAR2 (128) ,
CERT_FILE NUMBER NOT NULL ,
) TABLESPACE CP_DATA
LOGGING;
ALTER TABLE CERTIFICATES
ADD CONSTRAINT CERTIFICATES_PK PRIMARY KEY ( CERT_ID ) ;
CREATE TABLE USER_FILES
FILE_ID NUMBER NOT NULL ,
FILENAME VARCHAR2 (128) ,
BLOB_CONTENT BLOB ,
MIMETYPE VARCHAR2 (32) ,
LAST_UPDATE_DATE DATE
) TABLESPACE CP_FILES
LOGGING
LOB ( BLOB_CONTENT ) STORE AS SECUREFILE
TABLESPACE CP_FILES
STORAGE (
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS UNLIMITED
FREELISTS 1
BUFFER_POOL DEFAULT
RETENTION
ENABLE STORAGE IN ROW
NOCACHE
ALTER TABLE USER_FILES
ADD CONSTRAINT CERT_FILES_PK PRIMARY KEY ( FILE_ID ) ;
ALTER TABLE CERTIFICATES
ADD CONSTRAINT CERTIFICATES_USER_FILES_FK FOREIGN KEY
CERT_FILE
REFERENCES USER_FILES
FILE_ID
NOT DEFERRABLE
What I'm trying to do is to allow users to fill out all the certificate data and upload a file in an APEX form. Once submitted the file should be uploaded in the USER_FILES table and all the fields along with CERT_ID, which is the foreign key pointing to the file in the USER_FILES table to be populated to the CERTIFICATES table. APEX wizard forms are based on one table and I'm unable to build form on both tables.
That's why I've created a view (V_CERT_FILES) on both tables and using INSTEAD OF trigger to insert/update both tables. I've done this before and updating this kind of views works perfect. Here is where the problem comes, if I'm updating the view all the data is updated correctly, but if I'm inserting into the view all the fields are populated at CERTIFICATES table, but for USER_FILES only the fields FILE_ID and LAST_UPDATE_DATE are populated. The rest three regarding the LOB are missing: BLOB_CONTENT, FILENAME, MIMETYPE. There are no errors when running this from APEX, but If I try to insert into the view from SQLDeveloper, I got this error:
ORA-22816: unsupported feature with RETURNING clause
ORA-06512: at line 1
As far as I know RETURNING clause in not supported in INSTEAD of triggers, although I didn't have any RETURNING clauses in my trigger (body is below).
Now the interesting stuff, after long tracing I found why this is happening:
First, insert is executed and the BLOB along with all its properties are uploaded to wwv_flow_file_objects$.
Then the following insert is executed to populate all the fields except the BLOB and it's properties, rowid is RETURNED, but as we know RETURNING clause is not supported in INSTEAD OF triggers, that's why I got error:
PARSE ERROR #1918608720:len=266 dep=3 uid=48 oct=2 lid=48 tim=1324569863593494 err=22816
INSERT INTO "SVE". "V_CERT_FILES" ( "CERT_ID", "CERT_OWNER", "CERT_VENDOR", "CERT_NAME", "BLOB_CONTENT") VALUES (:B1 ,:B2 ,:B3 ,:B4, ,EMPTY_BLOB()) RETURNING ROWID INTO :O0
CLOSE #1918608720:c=0,e=11,dep=3,type=0,tim=1324569863593909
EXEC #1820672032:c=3000,e=3168,p=0,cr=2,cu=4,mis=0,r=0,dep=2,og=1,plh=0,tim=1324569863593969
ERROR #43:err=22816 tim=1324569863593993
CLOSE #1820672032:c=0,e=43,dep=2,type=1,tim=1324569863594167
Next my trigger gets in action, sequences are generated, CERTIFICATES table is populated and then USER_FILES, but only the FILE_ID and LAST_UPDATE_DATE.
Finally update is fired against my view (V_CERT_FILES), reading data from wwv_flow_files it populates BLOB_CONTENT, MIMETYPE and FILENAME fields at the specific rowid in V_CERT_FILES, the one returned from the insert at the beginning. Last, file is deleted from wwv_flow_files.
I'm using sequences for the primary keys, this is only the body of the INSTEAD OF trigger:
select user_files_seq.nextval into l_file_id from dual;
select certificates_seq.nextval into l_cert_id from dual;
insert into user_files (file_id, filename, blob_content, mimetype, last_update_date) values (l_file_id, :n.filename, :n.blob_content, :n.mimetype, sysdate);
insert into certificates (cert_id, cert_owner, cert_vendor, cert_name, cert_file) values (l_cert_id, :n.cert_owner, :n.cert_vendor, :n.cert_name, l_file_id);
I'm surprised that I wasn't able to find a valuable source of information regarding this problem, only MOS note about running SQLoader against view with CLOB column and INSTEAD OF trigger. The solution would be to ran it against base table, MOS ID 795956.1.
Maybe I'm missing something and that's why I decided to share my problem here. So my question is how do you create this kind of architecture, insert into two tables with a relation between them in APEX ? I read a lot in the Internet, some advices were for creating custom form with APEX API, create a custom ARP, create two ARP or create a PL/SQL procedure for handing the DML?
Thanks in advance.
Regards,
Sve

Thank you however I was wondering if there was an example available which uses EJB and persistence.

Similar Messages

  • Inserting data from jsp form to multiple tables !

    Hi,
    I want to insert data from jsp form to two tables
    tables are
    (1) Form
    formId (PK)
    deptName
    (2) Data
    formId (FK)
    sNo
    description
    itemCode
    and the problem is that i want to save information form a jsp form to above two tables and i have only one form.
    so how do i insert data from a jsp form to multiple tables.

    You already know what your form in the jsp will be and what fields they are. You also already know what your database looks like. Using one form, you should be able to break the data down, and give it certain ids and/or names, so that when the form is submitted, you retrieve the correct values corresponding to a specific field and insert it.
    Unless there is something else I am not catching, this seems pretty straight forward.

  • *Urgent*How to insert data from MS SQL to the table that create at the adobe form?

    Hi,
    I'm using Adobe life cycle designer 8 to do my interactive form. I would like to ask how to insert data from MS SQL to the table that i have created in my adobe interactive form?
    I really need the information ASAP as i need to hand in my project by next week... i really appreciate any one who reply this post.
    Thanks

    Tou need to do a couple of things
    1. On the Essbase server, set up an odbc system connection to your MySQL database
    2. In the load rule , go to the file menu and select open SQL data source and in the data source put in your SQL statement . A couple of hints. Where it says Select, don't put in the word select and where it say from don't put in from. The system adds them for you. The easiest way ti enter a SQL statement is to do it all in the select area So if your SQL would normanlly say select * from mytable just enter the code as * from mytable in the select area
    The click ol/retrieve and enter in your connection info. Itshould bring data back into the load rule. Save the load rule and use it

  • Exporting data from interactive form into a table

    Hi,
    I have designed an interactive adobe form in Web Dynpro Java where a user can fill in his address into corresponding fileds like postcode, city etc.
    Now I want to export these address data via button on the form into a table in our R/3 System.
    Which possiblities do I have to handle this? Web Service? Does anyone has a How-to-Guide for me?
    Thanks a lot in advance!!!
    Regards
    Sven

    hi,
    in the livecycle designer under libary tab u have webdynpro tab--->choose  submit to sap button  and place it in the adobe form ur designing. u can use this button to trigger the code that u have written in webdynpro java.
    for eg if  u have
    a value node details
    and under that two  value attr fname,lname
    import the model (Insertdata---it has two import param fname and lname)u need for updating the data to r3 system.
    in the ctrller have a method submit.Here write the code to insert fname and lname into the db.
    IPrivateMyForm.IDetailsElement elem = wdContext.nodeDetails().currentDetailsElement();
    Insertdata_Input input = new Insertdata_Input();
    wdContext.nodeInsertdata_Input().bind(input);
    input.setFname(elem.getFname());
    input.setLname(elem.getLname());
    try
    wdContext.currentInsertdata_InputElement().modelObject().execute();
        wdContext.nodeOutput().invalidate();
        catch (Exception ex)
        {     ex.printStackTrace();}
    ul bind details to the datasource.
    when u edit ur interactive ui element these attr(fname and lname) vl be visible under dataview tab u can drag and drop them to the form
    now add submit to sap button in ur form.
    this button  correspond to the onactionSubmit dat u have written in the ctrller.
    so wen u click this the data vl be inserted
    Regards
    Jay

  • How to transfer data from excel files into z-tables

    Please help me with a code which transfers data from excel file to z-table.
    Thanks in advance
    Shuvir

    Hi Daniel,
    Export Data
    Purpose
    Use this procedure to export SAP data to a local file such as Microsoft Excel.
    Menu Path
    Use the following menu path to begin this process:
    ·         SystemèListèSaveèLocal File
    Helpful Hints
    When reviewing fields, R = Required,  O = Optional and C = Conditional.
    Procedure
    1.       Start the transaction using the menu path or transaction code.
          Whatever Data You Want to Export
    2.       Select SystemèListèSaveèLocal File.  This works well for any data in SAP.  This is the only option for the top-level (first page) of a report. 
    In a drill-down view within a report the Local File button  on the toolbar may be used and has the same options.
          Choose File Format
    3.       Click  .
    4.       Click  to continue.  If prompted for a format after choosing Spreadsheet, select Excel Table to get an Excel file that can be modified more easily.
          Choose File Save Location Step 1
    5.       Click  to the right of the Directory field to choose a different location.
          Choose File Save Location Step 2
    6.       Click  or browse your computer to locate the directory where you want to save your file.
    7.       Complete the following field:
    ·         File name:
        You must add the proper file extension to the name of your file (.xls for Excel, .rtf for Rich Text, .html for HTML).  The file extension tells your computer what program to open the file with.  If you do not have the file extension at the end, you may not be able to open it.
    8.       Click  to continue.
          Generate File in Location and Format Selected
    9.       Click  to create the file in the location and format selected.  In this example the file was named "example.xls" and saved on the desktop.
    Result
    You have completed the export process.
    thanks
    karthik

  • How to insert data from multiple forms

    Hi
    I want to insert 180 field record in a table.
    so suppose i split it with say 90 fields in two forms each.
    now the problem here is that suppose all the 180 fields are compulsory then when i travel from the first page to the next page then it will insert the first 90 columns in the table and doing this it gives constraint errors for other 90 fields as they are all not null.
    please suggest a solution for these.
    also how do i pass on the primary key value to the next form.
    please help me out.
    thanks
    ameya

    If you do it like that, you will lose the benefit of constraint checking, and you can end up with invalid data in your table.
    There are a few other approaches:
    1. Use the wizard wizard to create a series of pages which do not update the table, but save the data items. On the last page of the wizard, have a button that inserts the record using handwritten SQL.
    2. Create one page with all the fields (possibly hidden, to avoid alarming the users). Then create a wizard as above, with fields linked to the same data items as the large page. When the user has completed the wizard pages, navigate to the large page and use the DML process there to insert the record.

  • How to insert values from different region into one table

    Hi everyone
    I have created a page which contains 4 html regions like region1,region 2 ...region 4
    in region 1 i created 2 text items like (emp_name,emp_id).
    in region 2 i created 2 date fields (start_date,end_date).
    In region3 i created a tabular form which contains(job , hire_date).
    in region 4 i created a textfield (%of Hike)
    So i want to create a button(submit) .when i press the button it will insert all the informations provided by the user in different regions will be inserted to a table called employee_information.
    Can i do this?
    If it is possible please tell me how to do this
    if not then tell me any alternative solution.
    Thanks,
    Regards,
    Sabyasachi

    Sabyasachi wrote:
    Hi fac586
    Can you please tell me step by step how to do it or can you please make an example in apex.oracle.com and give me the credentials so that i can know clarify my doubts.1. Create a Form using a Wizard. This will create the items and processes necessary to retrieve data from, and perform DML on, the table. The items will be contained in a single default region.
    2. Create custom HTML regions on page.
    3. Move items and buttons from the default region created by the Form Wizard by changing the Region value in the "Displayed" section of the item attributes page, or Page Items page; or reassign items to regions using the Reassign Region Items page.

  • Insert date from YUI calendar into mysql table

    Is there a way to insert the date selected from the YUI calendar into a mysql table?

    I have been in trouble since last 2 days... I have tried all possible and explored any related topics.. Still I cannot address the problem.
    Problem 1:
    I have a simple jsp form which passed a bengali word.
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <form action="Test2.jsp" method="post" >
    <input type="text" value="&#2453;&#2494;&#2453;&#2494;" name="word">
    <input type="submit" value="Next">
    </form>
    </body>
    </html>
    When this page is post, a java program( TestWord) is called by the Test2.jsp. TestWord insert the passed bengali word into a MySQL table. Then it retrieves again the inserted bengali word and display in Test2.jsp.
    Test2.jsp:----
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <jsp:useBean id="get2" class="dictionary.TestWord" scope="session"/>
    <jsp:setProperty name="get2" property="*"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <form action="" method="post">
    <%
    String s=get2.getWord();
    out.write("Before converion onversion = "+s);
    s = new String(s.getBytes("ISO-8859-1"),"UTF-8");
    out.write(" After conversion = "+s);
    %>
    </form>
    </body>
    </html>
    It gives the output something like:
    Before conversion = &#65533;?&#2494;&#65533;?&#2494; After conversion = ??????
    Problem 2:
    The record in mysql table is inserted in bengali font (eg. &#2453;&#2494;&#2453;&#2494;). When I retrieve the record and display in a jsp page, I can see the bengali word (&#2453;&#2494;&#2453;&#2494;) properly. But if I insert the bengali word again in MySql table, then I see some string like "&#65533;?&#2494;&#65533;?&#2494;" storing in the table.
    Please help me out..
    Thanks in advance.

  • Insert data from one form to another table

    I have a form which of course insert data into table1, i created a process within this form and include a sql statement to achieve this for me. My thoughts are this will take whatever is the value from the form and insert it into table2.
    INSERT INTO ML_LIST (ML_TITLE,ML_LASTNAME)
    VALUES
    (P20_SSR_TITLE, P20_SSR_LASTNAME);
    My error is column not allowed here
    Any suggestions

    I used the following
    Begin
    INSERT INTO ML_LIST (ML_TITLE,ML_LASTNAME)
    VALUES
    (:P20_SSR_TITLE,:P20_SSR_LASTNAME);
    End;

  • How to get data from maintaince view into internal table

    Hi,
    I want to get the all data from v_t179 (maintanence view) into intrenal table.
    if i write select stmt , it is giving error.
    I want all data into internal table.
    regards,
    Ajay

    I think this is what you want:
    TABLES: t179, t179t.
    DATA: v_t179_int TYPE TABLE OF v_t179.
    SELECT * FROM t179
      JOIN t179t ON
        t179~prodh = t179t~prodh
      INTO CORRESPONDING FIELDS OF TABLE v_t179_int.
    Rob

  • How to insert data from webdypro form to ztable

    hi all,
    i have created one webdynpro form and i have created one ztable in sap system.
    when ever i have to give information in input fields in webdypro page, at that time the information should go to ztable in sap system.
    i am developing in webdynpro in abap.
    i am using sap ecc6.0 version, please help in this area.
    please help me how to link from webdypro page and ztable.
    how many ways to update the data into ztable thru web dypro abap system.
    thanks and regards,
    sai siva kumar

    I should think it would be possible to update the ztable using a BAPI, called from the ABAP webdynpro.
    The Web Dynpro ABAP might be able to help you better.
    Hope this helps.
    Sudha

  • How to import data from CSV file into a table by using oracle forms

    Hi,
    I have a CSV file and i want to insert in oracle database in a table by using a button in oracle forms.
    the user can select CSV file by using open dialog .
    can any one help me to find method to make import and select file from the client machine ?
    thx.

    1. create table blob
    CREATE TABLE IB_LOVE
      DOC          BLOB,
      CONTRACT_NO  VARCHAR2(20 BYTE)                NOT NULL
    )2. use the code below to insert:
           INSERT INTO ordmgmt.ib_love
                       (contract_no, doc
                VALUES (:control.contract_no_input, NULL
           lb$result :=
             webutil_file_transfer.client_to_db (:b2.file_name, v_file_blob_name, v_col_blob_name,
                                                 'CONTRACT_NO = ' || :control.contract_no_input);
           :SYSTEM.message_level := 25;
           COMMIT;
           :SYSTEM.message_level := 0;3. use the code below to download
         if :control.CONTRACT_NO_INPUT is not null then
              vboolean :=   webutil_file_transfer.DB_To_Client_With_Progress(
                               vfilename,  --filename                       
                              'IB_LOVE', ---table of Blob item                       
                              'DOC',  --Blob column name                       
                              'CONTRACT_NO = ' || :CONTROL.CONTRACT_NO_INPUT, ---where clause to retrieve the record                       
                              'Downloading from Database', --Progress Bar title                       
                              'Wait to Complete'); --Progress bar subtitle  client_host('cmd /c start '||vfilename);
              client_host('cmd /c start '||vfilename);                 
         else
              errmsg('Please choose contract no');
         end if;4. use the code below to open file dialog
    x:= WEBUTIL_FILE.FILE_OPEN_DIALOG ( 'c:\', '*.gif', '|*.gif|*.gif|', 'My Open Window' ) ;
    :b2.FILE_NAME:=X;

  • How to insert data from the form to the database problematically

    Hi,
    Please anyone can help me with a code to insert a new record in database using code.
    i have dragged and dropped createInsert operation and on their action calling insert() method in backing bean.
    But wat i m suppose to write code so that data will be inserted as well as committed?

    Hi,
    Always mention your JDev version and technologies used.
    Have you tried executing the commit method as well (inside your insert() method)?
    -Arun

  • How to pass Data from one form to the other

    Hi all
    Can any one suggest me how to pass data from one form to the other form, which i zoomed from the original one?
    I tried to do this by passing parameter in Event Procedure but i am getting error msg when i am opening the zoomed form.
    If any one of u have any idea, give me a reply
    Thank you
    Suhasini

    If you choose the second alternative you should erase these global variables after the second form is opened
    You can erase the global variable using:
    erase('global_var')
    Greetings,
    Sim

  • How to extract data from info cube into an internal table using ABAP code

    HI
    Can Anyone plz suggest me
    How to extract data from info cube into an internal table using ABAP code like BAPI's or function modules.
    Thankx in advance
    regds
    AJAY

    HI Dinesh,
    Thankq for ur reply
    but i ahve already tried to use the function module.
    When I try to Use the function module RSDRI_INFOPOV_READ
    I get an information message "ERROR GENERATION TEST FRAME".
    can U plz tell me what could be the problem
    Bye
    AJAY

Maybe you are looking for

  • Speeding up the use of Pen Tool in connection with Audio Keyframes

    I remember that one of the editing systems that I used to work on (either Premiere, Avid, or DPS) had this nifty little button that automatically generated three audio keyframes with the middle keyframe at -inf dB. It was great for getting rid of mic

  • Problem creating Network ACL for a ROLE in Oracle 11gR2

    According to Oracle Documentation when you create a new Network ACL you can add privileges to a user or role.  I need to create a new ACL for the UTL_SMTP package for a specific role, but when I granted it the users who have that role are still getti

  • Editing a PNG palette in AWT

    I am loading a PNG using ImageIO.read(new File(IMG_LOC)); and storing the BufferedImage returned. Now I want to take that BufferedImage and modify the palette. The palette must first be read, analyzed, and then re-written. Basically, I am using the p

  • Upload File in servlet

    hi , i upload a file in jsp and in the servlet i want to read the contents of the file not store it. can u provide me with a simple basic code to do this. i dont want to use any 3rd party classes for this purpose. THanks

  • Utilization of excise duty j2iun

    hi, our last utilization date was 2010. now we want to do  utiliziation( j2iun). what is the process.