How to update many tables using the same code

<%@ page language = "java" import = "java.sql.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.text.*" %>
<%
String custname1=request.getParameter("custname");
session.setAttribute("custname",custname1);
String custtin1=request.getParameter("custtin");
session.setAttribute("custtin",custtin1);
%>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:loginval");
Statement stat=conn.createStatement();
String stmt="insert into custdetails values('"+custname1+"','"+custtin1+"')";
stat.executeUpdate(stmt);
stat.close();
conn.close();
%>
<jsp:forward page = "success.html"/>
<%
catch(Exception e)
%>
<jsp:forward page = "tinerror.jsp"/>
<%
%>---------------------------------------------------------------
this is my code, now this code will be used by many users to update their corresponding tables. so my problem is based on the username i need to change the table name in the insert query, for example if the username is sai, then the table name has to be saicustdetails and if the user name is ram then the table name in the query has to be ramcustdetails. and so on.
please help

*<%@ page language = "java" import = "java.sql.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.text.*" %>
<%
String tin1=request.getParameter("tin");
session.setAttribute("tin",tin1);
tin1=tin1+"custdetails";
String custname1=request.getParameter("custname");
session.setAttribute("custname",custname1);
String custtin1=request.getParameter("custtin");
session.setAttribute("custtin",custtin1);
//String tin2;
%>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:loginval");
Statement stat=conn.createStatement();
String tin2;
tin2=tin1;
String stmt="insert into "+tin2+"values('"+custname1+"','"+custtin1+"')";
stat.executeUpdate(stmt);
stat.close();
conn.close();
%>
<jsp:forward page = "success.html"/>
<%
catch(Exception e)
%>
<jsp:forward page = "tinerror.jsp"/>
<%
%>i tried what u have said but still it does not work, anyother way?????

Similar Messages

  • How to update two tables at the same time using jdbc

    Plz will anybody tell me what is the code or query in jdbc by which you insert entry in one table and simultaneously it goes in another table?
    Thanks in advance

    You might be
    able to design a trigger to do what you're talking
    about, but that would be a database thing, not a java
    thingAnother option would be an updatable view (google for usage), but it has limitations and should be used with caution. And yes, its a database thinggy and not java.
    cheers,
    ram.

  • Updating two tables at the same time

    Please,
    Does someone have an idea on how to update two tables at the same times?
    Thanks a lot in advance

    I was thinking about a single session and single update command.
    That's why I thougth someone else could have a clue.
    Thank you

  • How to create many user in the same database

    hi
    my question is "How to create many user in the same database(application)?"
    for example, i have students, teachers, and staffs user using my application.
    i can create many users to use the same application right?, how ^^''' ???
    (right now i can only create application and then it shows every data in my DB
    but i want it to show only the data for the user who login to that application)
    Thanks.
    ps. i'm newbie, please help T^T

    You need to create a user table within your application that maintains their privileges. If you have LDAP you could use this for authorisation otherwise the table would handle that as well (store passwords etc). Your reports etc would then be filtered on information from this table.
    Check out some of the sample applications to see how authorisation and access is implemented (Online store is one). The how-to on the issue tracking system should also have some useful pointers.
    http://download-west.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/issue_track.htm#BABBGBJG
    cheers,
    Ron

  • How to Update  crmd_customer_h TABLE Using CRMV_EVENT Through Funtion Module

    Hi
    How we can update customer_h table using the CRMV_EVENT Where i implemented logic below in the Funtion Module.
    data:     lt_doc_flow          TYPE crmt_doc_flow_wrkt,
              lw_cust_h_com        TYPE crmt_customer_h_com,
              lw_input_field_names TYPE crmt_input_field_names,
              lt_input_field_names TYPE crmt_input_field_names_tab,
              lt_objects_to_save TYPE crmt_object_guid_tab,
              lw_guid TYPE CRMT_OBJECT_GUID.
    DATA : lv_process_type TYPE crmt_process_type.
    data: wa_doc_flow type CRMT_DOC_FLOW_WRK.
    data: wa_customer_h type crmd_customer_h.
    *  Function module for retriving the Process type.
      CALL FUNCTION 'CRM_ORDERADM_H_READ_OW'
        EXPORTING
          iv_orderadm_h_guid     = iv_header_guid
        IMPORTING
          ev_process_type        = lv_process_type
        EXCEPTIONS
          admin_header_not_found = 1
          OTHERS                 = 2.
    if lv_process_type eq 'ZG01'.
    CALL FUNCTION 'CRM_DOC_FLOW_READ_OB'
    EXPORTING
       IV_HEADER_GUID                 = iv_header_guid
    IMPORTING
       ET_DOC_FLOW_WRK                = lt_doc_flow.
    read table lt_doc_flow with key objtype_a = 'BUS2000116' INTO wa_doc_flow. "gc_object_type-service.
                if sy-subrc eq 0.                    "set flag for service order
                lw_cust_h_com-ref_guid       =  wa_doc_flow-objkey_a.
                lw_cust_h_com-ZZTRAIL_FLAG   = 'X'.
                 lw_cust_h_com-mode           = 'A'.
                lw_cust_h_com-ref_handle     = '0000000001'.
                lw_guid = wa_doc_flow-objkey_a.
                INSERT lw_guid INTO TABLE lt_objects_to_save.
         endif.
                  lw_input_field_names-fieldname = 'REF_GUID'.
                lw_input_field_names-fieldname = 'ZZTRAIL_FLAG'.
              lw_input_field_names-changeable = ' '.
               INSERT lw_input_field_names INTO TABLE lt_input_field_names.
    Maintain Customer H
             CALL FUNCTION 'CRM_CUSTOMER_H_MAINTAIN_OW'
                  EXPORTING
                    is_customer_h_com    = lw_cust_h_com
                  CHANGING
                    ct_input_field_names = lt_input_field_names
                  EXCEPTIONS
                    header_change_error  = 1
                    header_create_error  = 2
                   error_occurred       = 3.
    ENDIF.
    *endif.
    *Clearing local variables
      clear: lv_process_type,
             lw_cust_h_com,
             lw_input_field_names.
    *Free internal tables
      free: lt_doc_flow,
            lt_input_field_names.

    Hi Faisal
    I think your not clear with what i am saying anyhow i will again explain you my requirement
    As per my requirement
    1)in the service order search report i need to add a field called "Has trail order with No Follow up" with values "Yes" & "Blank"
    For above Field i added  using the structure CRMST_QUERY_SRVO_BTIL and through configuration i am able to display the field in webui as per (Attachement Pic 1)
    2)When i  search with search criteria as  "Has trail order with No Follow up" with  "Yes"
    Then in result list i need to show the service order those having follow up as trail orders(sales order) only.if for  next document trail order  having any follow up then those service orders dont want to show in result list.
    For above requirement i implemented F.M using CRMV_EVENT & I configured for BUS2000115 And BEFORE_SAVE The Order
    The FM Will get trigger when i save the service order and for that service order if create any follow up and try to save the trail order then This FM Will trigger and in this i am doing validations.
    3)Add one AET Trail Flag field is added under CUSTOMER_H Table.
    4)in the FM I am validating for if the trail order having the preceding document as service order then i need to make flag as "X" For that service order in customer_h
    if suppose when i delete trail order from the service order then that flag must need to be "unset" from the CUSTOMER_H.
    Why bcoz we are doing above process is do show records in result list based on Flag values
    these flag checks are validating in the BADI Which we implemented for search logic.
    Please refer below Login for my requirement:-
    Proposal to have a custom “flag” field (background at table level,
         crmd_customer_h) linked to service order which gets flagged whenever at
         least one Trial order is created and saved from the Service Order.
    The flag value should be cleared when all the trial orders created and
    saved as follow up transactions are deleted from the system.
    Similarly for Trial Orders will use the same custom “flag” field
         which gets activated when at least one follow up is created and saved from Trial Order.
    The flag value should be cleared when all the follow up transactions from
    the Trial Order are deleted from the system.
    When the above search criteria “Has Trial order with no follow up”
         “is” “Yes” is applied then the logic derives all the service
         orders which satisfy additional search criteria applied in the search and
         for these Service orders checks if the custom flag field is checked to
         derive all Service orders which have Trial order. The custom flag values
         values are derived from crmd_customer_h table in CRM.
    4 )Further for all the Trial Orders determined in Step 3
    check if the Trial Order has a follow up by checking if the custom flag field
    is checked. The custom flag values are derived from crmd_customer_h table in
    CRM.
    5) If step 4 is not met populate the preceding Service
    Orders in the Result list

  • How am i able to use the same itunes account on a different ipod?

    How am I able to use the same iTunes account on a different iPod?

    By just using the same iTunes account.  If you set up the iPod on your computer just make sure that iTunes is signed your account.  Of settingup via wifi, just enter your existing account.  Do not create a new one.

  • How do I do to use the same appleid on all my devices, I want to use the last one I have on my Ipad mini, do I deleta the one I have on my Iphone and reeinstall it with the Id I use on my Ipad..?

    how do I do to use the same appleid on all my devices, I want to use the last one I have on my Ipad mini, do I deleta the one I have on my Iphone and reeinstall it with the Id I use on my Ipad..?

    Hi john,
    Yes, you would sign out of iTunes & App Store: Settings>iTunes & App Store, click on the Apple ID, click on Sign Out. Then sign back on with the new Apple ID. Also, if you have an iCloud account with the other Apple ID, you would delete that iCloud account, and then sign on with your new ID: Settings>iCloud>Delete Account.
    Cheers,
    GB

  • Two forms that update differrent tables on the same page?

    I tried to add two forms that update different tables on to one page.
    Problem is when I do that the forms gives me an error saying the field does not exist. It's like it is trying to update one table with the other tables fields.
    As an example Say I have one forms that is for people table and another one that is the Jobs table.
    When I go to update the people table, it sends the data for the jobs fields too I get an error like the field job description does not exist.
    I have two different forms for these and everything.
    I would hope it is possible to have two forms that update different tables on the same page.

    I was trying the exact same thing, but i managed to work round it by setting the steps to hide one region, so the user would enter the form see one region submit the region then direct back to the same page with the different region visible and the original hidden.
    I don't know if this would be acceptable for you...

  • Hi everyone, to use the portal with many users using the same portal user?

    I have an another question is possible to use the portal with many users using the same portal user with diferent roles in the same time?
    thanks

    Hi Israel,
    It is possible to have same user logged in through differnt terminals or browser windows. However if there are say 10 roles assigned to that user, all 10 will be visible in all the windows. However you may open and work on different roles.. in the different windows.
    Note that the real time collaboration features shall not be available if the same user logs in multiple times.
    Hope this is useful.
    Regards,
    Anagha

  • Use the same code module for several steps in the sequence

    Hello All,
      I have been trying to set up a sequence that uses the same code module for all of the steps in the sequence, but am having trouble referring back to it when I need to send it commands.  I have gotten as far as calling the VI in a new thread so that it can be run asynchronously.  I can run the simple sequence and it will indeed open the VI, and move on to the next step.  When I close the VI manually from the front panel, the sequence in TestStand completes, as expected.  So it appears that I have that much working. 
      My question is how to call the separate thread from the main sequence or other sub sequences when I need to edit the parameters.  If I insert an Action step, I am required to select a VI file, but from what I can tell, it opens a different instance of the file, and does not provide an interface with the other instance running asycronously.  My next guess was to use a Statement step, but I was not able to figure out how to configure the lookup string to call the VI parameters.  Beyond that, I'm not sure how to proceed.  Please advise.   
      My intention is to start the code module VI (asynchronously), run several different subsequences within the main sequence that call that same VI and edit it's parameters, close everything and report on the results.  If I am misunderstanding how TestStand is supposed to work, please let me know. 
    Thanks,
    GSinMN    
    Solved!
    Go to Solution.

    What I do is use a Queue to send data to the asynchronous VI.  So it can run and do whatever, but also recieve the commands from the queue.  I use an Action Engine that holds the queue reference and sends the commands.  So you really just have to call the Action Engine from your sequences.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How do you insert new records into multiple tables using the same unique primary key?

    I’ve created a PHP site and MySQL server using a free app called XAMPP.  I have successfully created a form in Dreamweaver that will write data to a (name) table in the SQL database.  Here’s my question: How do you write to two (or more) tables in the same database and pass the same primary key to both tables?  In the SQL database, I defined the first field as ID and set it as the primary key with auto update.  So, when you insert a new record, it creates a unique primary key for that record.  In my form, I’m capturing info that needs to be stored to two tables at the same time; a Name table and Address table. Since the Name and Address tables use the ID field as the primary key, I believe I will need to pass the ID value from the Name table to the insert of the Address table to insure they both have the same primary key, right?

    No. You probably need the primary key from one table to be a foreign key in the other tables. In any case, I believe you can use two methods to obtain the auto generated key. First with SQL:
    http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
    And the other using a PHP function:
    http://us3.php.net/mysql_insert_id

  • To use the same code for many movieclips

    Dear all.
    I am using the flash to build my personal book online. I need zoom  many movieclip, my images.
    i make the code and function perfectly. But I want to find a way to use the same function for all movieclips and so, mantaining my code clean.
    mc_01.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, Drag);
    mc_01.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, unDrag);
    mc_02.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, Drag);
    mc_02.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, unDrag);
    and many others....
    function Zoom(e:MouseEvent):void
            mc_01.x = 0;  //I try here for this.x but the previews movie, called "Books" is who have changed your x value.
            mc_01.y = 0;
    I
    EDIT: For untangle, the previews movie is called MyAllPhotos and then, contain all movieclips that are each movie clip is one my images

    Hi Mr Kglad.
    And when I call a property like a X position I use this["mc_"+padF(i)].x = 0;  for substitute the mc_01.x = 0 ?
    My problem realy is inside the function. Your loop add an event to my clips and direction to function Drag and UnDrag.
    But inside in this functions, I need get some informations for the clip.
    Here the code:
    function Zoom(e:MouseEvent):void  //Sorry, but the correct name my functions is Zoom and not Drag and unDrag
               var mod:Number = 50;
               mc_01.scaleX += e.delta / mod; //in this name mc what I need to use? this, parent? I try and not function.
               mc_01.scaleY += e.delta / mod;

  • How to handle multiple exceptions by the same code?

    Hi, all:
    In my situation I want AException and BException handled by the same code, while CException and DException handled by another code. How can I write my try-catch code in a simple way? Of course I can do the following:
    public void TheMainFunction() {
        try {
        } catch (AException e) {
            Handle_AB();
        } catch (BException e) {
            Handle_AB();
        } catch (CException e) {
            Handle_CD();
        } catch (DException e) {
            Handle_CD();
    private void Handle_AB() {
    private void Handle_CD() {
    }But is there a simpler way?
    Thanks in advance.

    If you have one or two places in your code that need multiple exceptions, just do it with multiple catch statements. Unless you are trying to write the most compact Programming 101 homework program, inventing tricks to remove two lines of code is not good use of your time.
    If you have multiple catches all over your code it could be a code smell. You may have too much stuff happening inside one try statement. It becomes hard to know what method call throws one of those exceptions, and you end up handling an exception from some else piece of code than what you intended. E.g. you mention NumberFormatException -- only process one user input inside that try/catch so it is easy to see what error message is given if that particular input is gunk. The next step of processing goes inside its own try/catch.
    In my case, the ArrayIndexOutOfBoundsException and
    NumberFormatException should be handled by the same way.Why?
    I don't think I have ever seen an ArrayIndexOutOfBoundsException that didn't indicate a bug in the code. Instead of an AIOOBE perhaps there should be an if statement somewhere that prevents it, or the algorithm logic should prevent it automatically.

  • How to update a table with the time of insert instead of time of commit

    dear,
    i have 10 record at source side which needs to be injected in a target table ;
    the record creation date is injected with the systimestamp -
    when commiting it takes for all the same timestamp for all records( at commit time ) however I would like to insert the timestamp at INSERT moment to have a unique timestamp - id est at INSERT time.
    Can anyone please adviseN?
    Thanks
    Erik
    Edited by: 845498 on 29-aug-2012 1:36

    845498 wrote:
    dear,
    when commiting it takes for all the same timestamp for all records( at commit time ) Not true about commit time. True about same time. Function SYSDATE is always calculated once for SQL statement no matter how many times and for how many rows it is referenced. So when you issue:
    insert
      into target(insert_date)
      select sysdate
        from  source
    /All inserted rows will have same insert_date. Now keep in mind, Oracle date datatype precision is one second. So unless your insert of 10 rows takes more than a second (which would be a problem on its own), date precision will not give you what you want. You would need timestamp. But again, same as SYSDATE, SYSTIMESTAMP is called once per statement. To call it row each row and reference you need to create user-defined function:
    create or replace
      function get_systimestamp
        return timestamp
        is
        begin
            return systimestamp;
    end;
    /Now:
    SQL> select  systimestamp,
      2          get_systimestamp
      3    from  hr.employees
      4  /
    SYSTIMESTAMP                        GET_SYSTIMESTAMP
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.671000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    SYSTIMESTAMP                        GET_SYSTIMESTAMP
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.687000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000
    29-AUG-12 01.55.23.656000 PM -04:00 08/29/2012 13:55:23.765000000.
    .SY.

  • How to update many tables in PL/SQL

    Hi all,
    I have to update EMPNIC colum in all the tables using PL/SQL. There are over 700 tables in the database that has the same column name 'EMPNIC'
    I create one table called 'UPDATEEMPNIC' According to that table I have to update all the tables.
    This is my PL/SQL statement. But in this code its not updating the 'NEWEMPNIC'
    PROCEDURE UPDATE_EMP_NIC IS
    sql_stmt VARCHAR2(200);
    newempnic VARCHAR (20);
    empnic VARCHAR (20);
    table_name VARCHAR(100);
    BEGIN
    DECLARE
    CURSOR C IS
    --I can find all the table names that I have to update using this query.
    select table_name from all_tab_cols where table_name like 'TBL%' and column_name like 'EMPNIC';
    REC C%ROWTYPE;
    TYPE temp_refcur IS REF CURSOR;
    temp temp_refcur;
    --er temp%ROWTYPE;
    type rec_emp is record
    newempnic VARCHAR2 (20),
    empnic VARCHAR2 (20)
    er rec_emp;
         begin
         --for x in cur
              OPEN C ;
              loop
              FETCH C INTO REC;
    EXIT WHEN C%NOTFOUND;
    open temp for 'SELECT EMPNIC, NEWEMPNIC FROM UPDATEEMPNIC';
    loop
              fetch temp into er;
              exit when temp%notfound;
                   sql_stmt :='UPDATE '||REC.table_name||' SET EMPNIC ='''||er.NEWEMPNIC||'''WHERE EMPNIC ='''||er.EMPNIC||'''';
                   DBMS_OUTPUT.PUT_LINE(sql_stmt);
    EXECUTE IMMEDIATE sql_stmt ;
         end loop;
              close temp;
              end loop;
              CLOSE C;
    END;
    end UPDATE_EMP_NIC;
    But I can't find the whats the wrong.
    Let me know anyone know to do this.
    Thankyou all

    Why do you open a new thread for the same question?
    Please see the other thread!

Maybe you are looking for