Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa SQL update database using two queries at a time
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sharmila
update database using two queries at a time
1 Answer(s)      2 years and 4 months ago
Posted in : SQL


String sql="insert into employee values(emp_seq.nextval,\'"+ename+"\',\'"+eadd+"\',\'"+ephone+"\',\'"+email+"\',\'"+department+"\',"+Integer.parseInt(ebpay)+",20,0)";

stm.executeUpdate(sql);

String sql1="insert into appusers values(emp_seq.nextval,\'"+ename+"\')";

stm.executeUpdate(sql);

---this is the code i have.But i need to perform insertion in both the tables i.e employee and appusers at the same time as i need the same sequense value in both the tables.

plzz help


Advertisement
View Answers

July 5, 2012 at 11:36 AM


You can execute two queries with two different Statement object in the following way. Another thing, you have executed same query twice in your code.

Statement st1=conn.createStatement();

String sql="insert into employee values(emp_seq.nextval,'"+ename+"','"+eadd+"','"+ephone+"','"+email+"','"+department+"',"+Integer.parseInt(ebpay)+",20,0)";

st1.executeUpdate(sql);

Statement st2=conn.createStatement();

String sql1="insert into appusers values(emp_seq.nextval,'"+ename+"')";

st2.executeUpdate(sql1);


Related Tutorials/Questions & Answers:
update database using two queries at a time
update database using two queries at a time  String sql="insert... can execute two queries with two different Statement object in the following way... to perform insertion in both the tables i.e employee and appusers at the same time
Update value of database using hibernate.
Update value of database using hibernate.  How to update value of database using hibernate?   Hibernate provides facility to update... this by setting the value and calling the update method. session.update(employee
Advertisements
two select queries shouldn't depend on each other
two select queries shouldn't depend on each other   i want to write two select queries such that both queries shouldn't depends on each other .or how can i re-write this query? can i write this without using where
How to calculating time difference bewteen two countries using country name?
How to calculating time difference bewteen two countries using country name?  How to calculate the time difference between two countries. Example if i pass India and America, then the program should return the time difference
update two frames at once
update two frames at once  How do I update two frames at once
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database... upload excel file and update database using JSP ? Thanks in Advance
Google Ranking Update for Spammy Queries
ranking update today for some spammy queries". This update was worldwide and many... in their ranking and disappeared from search results. This update targets spam queries... percent of English queries. It is a work in progress and will be completely
update database
update database  hi.. i want to know how the valuesof database can... that can be done there then by pressing the update buutton the value can be updated to database
update mysql database
update mysql database  update mysql database
Update Database Table using JDBC in JSP
Update Database Table using JDBC in JSP       This example shows how to update the existing  record of mysql table using jdbc connectivity in the jsp page
queries
queries  class one having the static variable and method....... we extend class one to class two ..... In clas two if we create a object for class one then we can access the static variable that present in class one
callable statement,stored procedure for insert data and also for update data into oracle database using jsp
callable statement,stored procedure for insert data and also for update data into oracle database using jsp  iam a fresher newbie to softparsing i... procedure for inserting data into oracle database as bind variable and same
Update Database from jsp
Update Database from jsp   I want to update my oracle database... UPDATE button the database field should be updated . I have a drop down menu...= null; st=conn.createStatement(); st.executeUpdate("UPDATE TEST_LINKS SET
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown below.(database created using SQL Server 2005) name : george,simon address... with two text boxes. if I type something in one textbox, the corresponding value
redeploy project update database table
redeploy project update database table  **Dear Sir, i am using Hibernate 3.3 and spring 3.0 and mysql database. Now while redeploying project In tomcat 6 i want to run a sql query Thanks for your wise comments
how to update checkbox list in database
how to update checkbox list in database  Issues: i am using... to update one by one but it's not updating by using below code .it's not adding... in the database below logic is working fine by using insert command
using case in update statement
using case in update statement  i want to use case in update clause... syntax is not working for update stmt.my problem is update emp set case deptno... working but for first condition only update emp set deptno=(case when 10 then 20
How to store multiple images in folder and images path in database at a time using jsp?
How to store multiple images in folder and images path in database at a time using jsp?  I wanna browse multiple images in one form and store them in one folder and their path into datrabase
calculate difference between two time in jsp
calculate difference between two time in jsp  How to calculate difference between two dates
HQL Update Statement to update database table
HQL Update Statement to update database table HQL's update query statement is used to update the values of database rows. Though HQL is similar to SQL.... In this article we are testing an example to update the values of database table. See
Update Records in Database
Update Records in Database       The Update Records in database is used to modify... from update record in database. In this Tutorial, the code run a select query
Oracle Database - Insert System Time
Oracle Database - Insert System Time  Hi I want to insert only system time dynamically using a statement but not a prepared statement into Oracle Database please suggest me any code
How sql Queries possible in DAO without creating Database connections - Java Beginners
How sql Queries possible in DAO without creating Database connections  In DAO we are writting sql queries , how it is possible without creating and closing database connections
total time calculator (starttime+endtime) in servlet USING DATABASE IN SQL2000 PLZ ANY ONE HELPME
total time calculator (starttime+endtime) in servlet USING DATABASE IN SQL2000 PLZ ANY ONE HELPME   <%-- Document : insertdate Created on : Jul 19, 2013, 3:48:28 PM Author : CG0T4908 --%> <
mysql run multiple queries at once
mysql run multiple queries at once  Running two MySQL queries at a time in PHP mysql_query
Update Record using Prepared Statement
JDBC: Update Record using Prepared Statement In this section, you will learn how to update row using Prepared Statements. Update Record  ... statement. Update record is most important operation of database. You can update one
update excel sheet using jsp::
update excel sheet using jsp::   Hi Sir,... I have a excel... given excel sheet and display it into another excel sheet using jsp" i am using 'session' to get the empid from one page to another jsp
Set Time by using the Prepared Statement
the time in database table by using the PreparedStatement interface of java.sql... for setting the time in database table (child) by using the PreparedStatement... Set Time by using the Prepared Statement   
update data to mysql database through JTextField
update data to mysql database through JTextField  I am getting an error, when i am updating a data to mysql database through JTextField. Send me the code used to solve my error. public void update(){ try
update
update  how can i update multiple records in database using jsp ,servlet and jdbc based on selection of checkbox in jsp
store the employee ID,name,login time and logout time of the employee in database
time of the employee along with the time difference between these two in separate columns in a database table..the login and logout time has been stored...store the employee ID,name,login time and logout time of the employee
Advertisements
 

 

 

DMCA.com