Insert and update in database using apex tabular form

Hi All,
i have tabular form
category_ID
Day
Hours
Start Date
End Date
1001
2
3
01-jun-2013
Null
1002
1
4
02-jun-2013
Null
1003
2
5
03-jun-2013
null
if day or hour change/update then End date will be sysdate.
and new row insert in table
category_ID
Day
Hours
Start Date
End Date
Header 6
1001
1
3
01-jun-2013
04-jun-2013
Day change from 2 to 1
1002
1
4
02-jun-2013
Null
No change
1003
2
5
03-jun-2013
null
No change
1001
1
3
04-jun-2013
null
New record insert which is change/update
how to achieve it.
Thanks in advance,
Prashant

I usualy don't use the apex wizards to create forms when you need such custom functionality.
I just make the needed items, and when saving the form elements to the db i run my own written procedure en i submit the page with the request 'UPDATE' and i also set an id item with the newly created id for the inserted record.
So the page knows it should call the procedure that fills up all items with the values of the record i just saved. this also comes in handy when inserting a form in multiple tables.

Similar Messages

  • Insert data into oracle database using a PHP form

    I'm trying to enter data into my oracle database table using a php form. When I click submit no data is added. Could someone help me please. I'm new to php/oracle thing.
    NOTE: I don't have any problem connecting to the database using php.
    Here is the code I'm using:
    <?php
    // just print form asking for name if none was entered
    if( !isset($query)) {   
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Name: ";
    echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // insert client's name
    $query = "INSERT INTO client (name) VALUES ($data)";
    // connect to Oracle
    $username = "xxxx";
    $paswd = "yyyyyy";
    $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
    "(HOST=patriot.gmu.edu)(PORT=1521))".
    "(CONNECT_DATA=(SID=COSC)))";
    $db_conn = ocilogon($username, $paswd, $dbstring);
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>
    Thanks for your help. I will also appreciate a better was to do it.
    Tony

    resumption and jer,
    Sorry I cannot format the code for easy reading!
    The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
    <?php
    // connect to oracle
    $username = "xxxxx";
         $paswd = "yyyyy";
         $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
              "(HOST=patriot.gmu.edu)(PORT=1521))".
              "(CONNECT_DATA=(SID=COSC)))";
         $db_conn = ocilogon($username, $paswd, $dbstring);
    // username and password will be unset if they weren't passed,
    // or if they were wrong
    if( !isset($query)) {
    // just print form asking for account details
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Query: ";
    echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // remove unwanted slashes from the query
    $query = stripslashes($query);
    // run the query
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    // Open the HTML table.
    print '<table border="1" cellspacing="0" cellpadding="3">';
    // Read fetched headers.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
    print '</tr>';
    // Read fetched data.
    while (ocifetch($stmt))
    // Print open and close HTML row tags and columns data.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="v">'.ociresult($stmt,$i).'</td>';
    print '</tr>';
    // Close the HTML table.
    print '</table>';
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>

  • Re: Insert data into oracle database using a PHP form

    Hai its different for me, i want to display a data based on the input from php form. I see and trying your script but it didn't work.
    <?php
    // just print form asking for name if none was entered
    if( !isset($query)) {
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Name: ";
    echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    $data=$_POST;
    stripslashes($data);
    // Select statement
    $query = "SELECT * FROM animal WHERE skin=$data";
    // connect to Oracle
    $username = "xxxxxx";
    $paswd = "xxxxxx";
    $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
    "(HOST=yyyyyyyy)(PORT=1521))".
    "(CONNECT_DATA=(SID=COSC)))";
    $db_conn = ocilogon($username, $paswd, $dbstring);
    //$stmt = OCIParse($db_conn, $query);
    //OCIExecute($stmt, OCI_DEFAULT);
    //OCIFreeStatement($stmt);
    //OCILogoff($db_conn);
    $stmt = OCIParse ($db_conn, $sql);
    OCIBindByName ($stmt, ":name", &$data, -1);
    OCIExecute ($stmt);
    OCIFreeStatement($stmt);
    OCILogoff ($db_conn);
    ?>
    Could you please advice me ? whats wrong with that script ?

    What is the error you get? What solutions have you tried already?

  • Can we use both INSERT and UPDATE at the same time in JDBC Receiver

    Hi All,
    I would like to know is it possible to use both INSERT and UPDATE at the same time in one interface because I have a requirement in which I have to perform both the task.
    user send the file which contains both new and old record and I need to save those in MS SQL database.
    If the record exist then use UPDATE otherwise use INSERT.
    I looked on sdn but didn't find any blog which perform both the things at the same time.
    Interface Requirement
    FILE -
    > PI -
    > JDBC(INSERT & UPDATE)
    I am thinking to use JDBC Lookup but not sure if it good to use for bulk record.
    Can somebody please suggest me something or send me the link of any blog or anything to solve this problem.
    Thanks,

    Hi ,
              If I have understood properly the scenario properly,you are not performing insert and update together. As you posted
    "If the record exist then use UPDATE otherwise use INSERT."
    Thus you are performing either an insert or an update which depends on outcome of a search if the records already exist in database or not. Obviously to search the tables you need " select * from ...  where ...." query. If your query returns some results you proceed with update since this means there are some old records already in database. If your query returns no rows  you proceed with "insert into tablename....." since there are no old records present in database.
      Now perhaps the best method to do the searching, taking a decision to insert or update, and finally insert or update operation is to be done by a stored procedure in MS SQL database.  A stored procedure is a subroutine available to applications accessing a relational database system. Here the application is PI server.   If you need further help on how to write and call stored procedure in MS SQL you can look into these links
    http://www.daniweb.com/web-development/databases/ms-sql/threads/146829
    http://www.sqlteam.com/article/stored-procedures-parameters-inserts-and-updates
    [ This part you can ignore, Since its not sure that you will face this situation
        Still you might face some problems while your scenario runs. Lets consider this scenario, after the stored procedure searches the database it found no rows. Thus you proceed with an insert operation. If your database table is being accessed by multiple applications (or users) other than yours then it is very well possible that after the search operation completed with a null result, an insert/update operation has been performed by some other application with the same primary key. Now when you are trying to insert another row with same primary key you get an error message like "duplicate entry not possible for same primary key value". Thus you need to be careful in this respect. MS SQL has a feature called "exclusive locks ". Look into these links for more details on the subject
    http://msdn.microsoft.com/en-us/library/aa213039(v=sql.80).aspx
    http://www.mssqlcity.com/Articles/Adm/SQL70Locks.htm
    http://www.faqs.org/docs/ppbook/r27479.htm
    http://msdn.microsoft.com/en-US/library/ms187373.aspx
    http://msdn.microsoft.com/en-US/library/ms173763.aspx
    http://msdn.microsoft.com/en-us/library/e7z8d5hf(v=vs.80).aspx
    http://mssqlserver.wordpress.com/2006/11/08/locks-in-sql/
    http://www.mollerus.net/tom/blog/2008/03/using_mssqls_nolock_for_faster_queries.html
        There must be other methods to avoid this problem. But the point is you need to be sure that all access to database for insert/update operations are isolated.
    regards
    Anupam

  • Inserting and Updating records in ORACLE using WebDynpro Java

    Hi All
    I got connected to oracle backend (using my previous thread), but now i want to insert and update the records
    i have created views  for insert and update,
    Thanks in advance
    Sushma

    Hi shusma..
    chk this link..
    <b><u>Creating Connection</u></b>
    package com.sap.xirig;
    import javax.naming.*;
    import javax.sql.*;
    import java.sql.*;
    public class DBLookup {
    String Conn_Status = "Not Connected";
    String Language_Desc = "Empty";
    String Language_Cd = "Empty";
    Connection conn;
    Context ctx;
    DataSource ds;
    //Constructor for the DBLookup object
    public DBLookup {
    try {
    ctx = new InitialContext();
    if (ctx == null) {
    throw new Exception("Boom - No Context");
    // If JDBC 2.0 connection is used please create the DataSource object as below
    // ds = (DataSource) ctx.lookup("jdbc/ORACLEDATASOURCE");
    // If JDBC 1.0 connection is used please create the DataSource object as below
    // ds = (DataSource) ctx.lookup("jdbc/notx/ORACLEDATASOURCE");
    if (ds == null) {
    throw new Exception("Boom - No dataSource");
    catch (Exception e) {
    e.printStackTrace();
    public String getLanguageDesc(String v_str) {
    Statement stmt = null;
    ResultSet rst = null;
    try {
    if (ds != null) {
    conn = ds.getConnection();
    Conn_Status = "Could not get connection to
    datasource";
    if (conn != null) {
    Conn_Status = "Got Connection " +
    conn.toString();
    stmt = conn.createStatement();
    rst = stmt.executeQuery("SELECT
    LANGUAGE_DESC FROM LANGUAGETRANSLATION WHERE LANGUAGE_CD='" + v_str +
    if (rst.next()) {
    Language_Desc = rst.getString(1);
    conn.close();
    catch (Exception e) {
    e.printStackTrace();
    finally {
    if (rst != null) {
    try {
    rst.close();
    catch (Exception e) {
    e.printStackTrace();
    if (stmt != null) {
    try {
    stmt.close();
    catch (Exception e) {
    e.printStackTrace();
    if (conn != null) {
    try {
    conn.close();
    catch (Exception e) {
    e.printStackTrace();
    return Language_Desc;
    http://e-docs.bea.com/wls/docs81/oracle/API_joci.html
    Hope this will help u..
    URs GS

  • Oracle forms 10g,multiple insert and update problem

    Hi,
    I have tabular form(4 records displayed) with one datablock(based on a view).
    After querying the form could not update all the records but only first record value can select from LOV.
    I called a procedure in in-insert and on-update
    The query is lik this
    PACKAGE BODY MAPPING IS
         PROCEDURE INSERT_ROW(EVENT_NAME IN VARCHAR2)
         IS
         BEGIN
              IF (EVENT_NAME = 'ON-INSERT') THEN
                   INSERT INTO XX_REC_MAPPING
                   (BRANCH_CODE,COLLECTION_ID,PAY_MODE_ID,RECEIPT_METHOD,CREATED_BY,
                   CREATION_DATE,LAST_UPDATED_BY,LAST_UPDATE_DATE,LAST_UPDATE_LOGIN)
                   VALUES
                   (     :XX_REC_MAPPING.OFFICE_CODE,
                        :XX_REC_MAPPING.COLLECTION_ID,
                        :XX_REC_MAPPING.PAY_MODE_ID,
                        :XX_REC_MAPPING.RECEIPT_METHOD,
                        :XX_REC_MAPPING.CREATED_BY,
                        :XX_REC_MAPPING.CREATION_DATE,
                        :XX_REC_MAPPING.LAST_UPDATED_BY,
                        :XX_REC_MAPPING.LAST_UPDATE_DATE,
                        :XX_REC_MAPPING.LAST_UPDATE_LOGIN);     
              ELSIF (EVENT_NAME = 'ON-UPDATE') THEN          
              UPDATE     XX_REC_MAPPING
              SET BRANCH_CODE=:XX_REC_MAPPING.OFFICE_CODE,
                        COLLECTION_ID=:XX_REC_MAPPING.COLLECTION_ID,
                        PAY_MODE_ID=:XX_REC_MAPPING.PAY_MODE_ID,
                        RECEIPT_METHOD=:XX_REC_MAPPING.RECEIPT_METHOD,
                        LAST_UPDATED_BY=:XX_REC_MAPPING.LAST_UPDATED_BY,
                        LAST_UPDATE_DATE=:XX_REC_MAPPING.LAST_UPDATE_DATE,
                        LAST_UPDATE_LOGIN=:XX_REC_MAPPING.LAST_UPDATE_LOGIN
                        WHERE ROWID=:XX_REC_MAPPING.ROW_ID;
              END IF;
         END INSERT_ROW;
    END MAPPING;
    Whether the table gets looked or sholud i use some other trigger or loops ?
    someone suggest me how to edit this query for multiple update.
    Thanks
    sat33

    I called a procedure in in-insert and on-updateWhy are you writing this code in the first place? If you have a block based on an updatable view, just let Forms do the inserts and updates.
    If it's not an updatable view, use instead of triggers on the view.
    See this current thread too:
    INSTEAD of Trigger View for an Oracle EBS New form development

  • Find All INSERTs and UPDATEs

    Hi All;
    I want to find out all inserts and updates of a spesific table. For instance a package l,ke that
    CREATE OR REPLACE PACKAGE BODY param_test IS
      PROCEDURE ins_test IS
      BEGIN
    insert INTO parameter_value VALUES (2);
        INSERT INTO parameter_value VALUES (9);
        INSERT  INTO
        parameter_value VALUES (4);   
        insert INTO parameter_value VALUES (54);
      END ins_test;
    END param_test;I am querying user_source view. My query is below.
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    Connected as SYS
    SQL> SELECT us1.NAME, us1.line, us1.text
      2    FROM user_source us1,
      3         (SELECT us2.line, us2.NAME, us2.text
      4            FROM user_source us2
      5           WHERE regexp_like(upper(us2.text), '[[:space:]]*PARAMETER_VALUE[[:space:]]*')) us3
      6   WHERE us3.line - 1 = us1.line
      7     AND us1.NAME = us3.NAME
      8     AND regexp_like(upper(us1.text), '[[:space:]]*(INSERT[[:space:]]*INTO|UPDATE)[[:space:]]*')
      9  /
    NAME                                 LINE TEXT
    PARAM_TEST                              9 insert INTO parameter_value VALUES (2);
    PARAM_TEST                             12     INSERT  INTO
    SQL> My question is "Are tehre any solutions to overcome this situation?"
    Kindly Regards...

    You might be better off combining into your attack the use of user_dependencies. This will tell you what objects e.g., code is dependent on your table and then you can search the source of those modules for inserts and updates into the table. Even then you'll never be sure, especially if dynamic SQL is used as the statement may be pieced together from various bits if strings, as then user_dependencies won't contain the reference.

  • Connecting and Updating External Database from SAP

    Connecting and Updating External Database from SAP
    How can i connect SAP Database to External database?
    How can i update external databas from SAP withouting using BI/BW, Workflow or Net Weaver?
    If anyone know please let me inform.
    Thanks in Advance.
    Jahnavee Trivedi

    Steps
    1. Create an entry in tnsnames.ora for the remote oracle DB
    2. Test sqlplus user/pass@remote 
    3. create a synonym which points to a table at remote DB check docs.oracle.com
    4. user ABAP code execute SQL to insert data into local synonym which inturn updates the remote DB.
    I have done this in the past, it works great.
    It requries, DBA skills + ABAP programming
    -AJ

  • Updating different Databases Using XI

    Hello,
    I am having one requirement for updating different databases using XI.
    The scenario is that
    Data is coming from ERP to XI.
    This data should be inserted or updated in SQL server.
    Depending on certain conditions I need to update different SQL servers.
    Currently I am having one interface which updates one SQL server database.
    I want to change that interface for updating different SQL server databases depending on the data coming from ERP.
    Is it possible?
    How can I achieve this?
    Thanks in Advance
    Abhijit.

    Hi abi,
        For using more than one database server u can use the BPM.
        there in the design phase, while u making the layout of the picture type connection , there in the switch tool , u can put the condition and according to that
    it will connect to the database server.......
    if it is useful give the rewards
    Regards
    Sasi.........

  • Multiple rows insert and update form example

    I just want to share with you an example of a multiple rows insert and update form. You can access it HERE (http://tryapexnow.com/apex/f?p=12090:21)
    You will find on the same page the complete description of all elements used to buid it.
    I'm waiting for opinions, suggestions, and questions here in this thread.
    Thanks

    Hello Valentin,
    I got an error message when I clicked on the weblink. Here is the message
    Error ERR-7620 Could not determine workspace for application. Could you please take a look at this.
    Thanks,
    Karol

  • APEX - tabular form update

    Hey guys,
    as per client's request, we need to insert rows into db from tabular form even there is no change on the new row. db table is configured to have nullable fields.
    Currently, it won't allow me to do so. Is there any way to force the insert/update without checking if the information on the row is updated?
    Thanks a lot

    You can do it, using manular tabular form.
    When you use automated Tabular Forms, it checks inbuilt global variables, to see row is updated or any new row is created and all necessary fields are keyed in.
    If you don't update an existing row, that row will not be updated..
    If you create/add new empty row and don't key in values, that row will not be inserted as there is no data..
    If you want to do in that manner, make your MRU process on the page to never and write your own manual MRU

  • Not Properly Insert and Update in ODI interfaces

    Dear Brothers,
    The records are not inserting and updating even the CDC captured in the journal in one of my package. But, stopped and execute again then there is inserts and updates. I am not able to understand where the problem is. Can u suggest regarding the issue.

    Dear Bro,
    I am capturing CDC using consistent set. I am using (LKM SQL to DB2 UDB). While executing the package, the records are locked and extend window, but there is no inserts and updates into the database. It is throwing error as row index out of range while running the query. The query is running in Source Stage for ex. RTO_STAGE.JV$NUMGEN. query is triggering but records are not properly inserted and updated in the target.
    First time i saw in the CDC table, there was some 10 records available while executing no insert and update. Then, i stopped it and execute it again at that time i checked in the CDC table ie., the same table, but there was only 2 records available in CDC the old records were disappeared.
    I dont know the exact issue? My colleague is telling may be SNP tables not refreshing. Kindly suggest any solution.

  • Updating a database using EJB Inheritance

    I am new to EJB's, so please forgive my ignorance. I creating the following classes that inherit from each other along with a method to update my database:
    @Entity
    @Inheritance(strategy = InheritanceType.JOINED)
    @DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING)
    public abstract class ObjectA implements java.io.Serializable {
         protected String name;
         protected String desc;
         protected String type;
    @Entity
    @DiscriminatorValue("OBJECTB")
    public class ObjectB extends ObjectA implements java.io.Serializable {
         protected String str_b;
         public ObjectB(String name, String desc, String type, String str_b) {
              this.name = name;
              this.desc = desc;
              this.type = type;
              this.str_b = str_b;
    @Entity
    @DiscriminatorValue("OBJECTC")
    public class ObjectC extends ObjectB implements java.io.Serializable {
         private String str_c;
         public ObjectC(String name, String desc, String type, String str_b, String str_c) {
              this.name = name;
              this.desc = desc;
              this.type = type;
              this.str_b = str_b;
              this.str_c = str_c;
    public class MyFacade implements ServletContextListener {
         @PersistenceUnit(unitName="Pu")
        private EntityManagerFactory emf;
        @Resource
        private UserTransaction utx;
        public MyFacade() { }
        public void contextDestroyed(ServletContextEvent sce) {
            if (emf.isOpen()) emf.close();
        public void contextInitialized(ServletContextEvent sce) {
            ServletContext context = sce.getServletContext();
            context.setAttribute("MyFacade", this);
         public void updateObject(ObjectA obj) {
            EntityManager em = emf.createEntityManager();
            try{
                utx.begin();
                em.merge(obj);
                utx.commit();
            } catch(Exception exe){
                try {
                    utx.rollback();
                } catch (Exception e) {}
                throw new RuntimeException("Error updating obj", exe);
            } finally {
                em.close();
    }If I do the following:
         String name = "test name";
         String desc = "updating object c";
         String type = "OBJECTC";
         String b = "b";
         String c = "c";
         MyFacade myf = new MyFacade();
         ObjectC objC = new ObjectC(name, desc, type, b, c);
         myf.updateObject(objC);
         .....In my database, only the values associated with ObjectC get updated and nothing from ObjectA or ObjectB get updated in the database. Does the "merge" method not work on inheritance. How do I update my database using inheritance?
    Thanks!
    Message was edited by:
    FourierXForm

    did you only have ISQL for testing it?
    Can you debug the form and look, if someone happens - exceptions, ... ?
    after the update you can use
    message (SQL%ROWCOUNT); pause ;
    to look, how many records were updated

  • Apex, Tabular forms and Nested Tables := Headache

    Hi All,
    I'm constructing an Apex aplication for Performance Reviewing staff and I have need of nested tables within each line item for ongoing comments during the year, the headings of which are drawn from another table, based on a template for which ones are to be used at any given time.
    I'd like to be able to use a tabular form to draw out the history of comments at any given time and modify them however I'm at a complete loss as to how to get this working with a tabular form in Apex. If anyone could point me at some good documentation on the subject or even suggest a better method to get this done I'd be very grateful.
    Thanks!

    Hi,
    Take a look at this article:
    http://www.oracle-base.com/articles/misc/ObjectViewsAndNestedTables.php
    First, create a view as described on your nested and other table(s), with 'Instead Of' triggers handling the DML. Next create the tabular form based on the view. You'll find many posts in the forum regarding building a tablular form based on a view.
    Paul Brookes.

  • Connecting to datasource and retrieve, insert and update data in SQL Server

    hi,
    i am trying to retrieve, insert and update data from SQL Server 2000 and display in JSPDynPage and is for Portal Application. I have already created datasource in visual composer. Is there any sample codes for mi to use it as reference???
    Thanks
    Regards,
    shixuan

    Hi,
    See this link
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6209b52e-0401-0010-6a9f-d40ec3a09424
    Regards,
    Senthil kumar K.

Maybe you are looking for

  • Replication of Sales Order from SAP ECC to SAP CRM

    Hi, The scenario I am working on is breifly as under: Telesales will create sales order directly in ECC. The sales order created in ECC will be replicated in CRM. I have some queries and request guidance: 1. The same sales order type will be used by

  • "Logical System"  &  "Assign Logical System to Client"

    Hi Experts, I'm new to Basis, I have the following systems installed: 1. EBP and SUS are installed in same server with different client:     EBP:  E01 with client 100     SUS: E01 with client 200 2. ECC system is installed at a separate setver     EC

  • How JPG or GIF Image open in MIDP?

    How my j2me application can support jpg or gif image format. I have tested png file in midp 1.0 and its not support other than png format( im not sure about midp 2.0 does it support or not). I have seen lot of mobiles those support gif and jpg file f

  • Memory leak with multiple "nodes" in CustomNode

    The displayed GUI has the ability to update a view when u press a button. If I press this button many times the process becomes longer and finally results in " java.lang.OutOfMemoryError: Java heap space " I think the problem is created by the update

  • Adapter Errors

    I am trying to trap the adapter errors using Alert configuration. When file content conversion fails, an alert message is raised correctly.. But the link goes to MDT instead of going to adapter monitor? MDT is usually empty in such scenario. Is there