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



Home Answers Viewqa SQL retrieve the records from one table to another table by using cursors
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


lakshmi
retrieve the records from one table to another table by using cursors
0 Answer(s)      a year and 4 months ago
Posted in : SQL


Hi I'm fresher to backend(mysql),my requirement is retrieve the records from one table to another table by using cursors.The following is my procedure and tables.After execution it insert one extra record to another table. empproc procedure:

create procedure empproc() begin declare ename varchar(12); declare d int default 0; declare cur cursor for select name from emp; declare continue handler for not found set d=1; open cur; lb1:loop if d=1 then leave lb1; end if; if not d=1 then fetch cur into ename; insert into emp2 values(ename); end if; end loop; close cur; end; //

The actual data is bellow one:

mysql> select * from emp; +------+------+-------+ | eid | name | sal | +------+------+-------+ | 1 | aaaa | 12334 | | 2 | bbbb | 15334 | | 3 | cccc | 15336 | +------+------+-------+ 3 rows in set (0.00 sec)

after executing the procedure i'm getting the following result.print("code sample");

mysql> select * from emp2; +-------+ | ename | +-------+ | aaaa | | bbbb | | cccc | | cccc | +-------+ 4 rows in set (0.00 sec)


Advertisement
View Answers

Related Tutorials/Questions & Answers:
retrieve the records from one table to another table by using cursors
retrieve the records from one table to another table by using cursors  ... from one table to another table by using cursors.The following is my procedure and tables.After execution it insert one extra record to another table. empproc
update one table from another table
update one table from another table  hello, i need to update one table fields by using another table fields. I have to tables Products.... for example TotalQuantity field from Products table should be updated if i
Advertisements
copying data from one table to another
copying data from one table to another  i need to copy data from one table to another table.. i.e the 1st eid of employee table must be copied to the 1st eid in appusers table, 2nd eid of employee to the 2nd eid of appusers
take data from one table and insert same in another
take data from one table and insert same in another  I want to know when a new field update in table and the same data has to update in another table
retrieve record from table
for a single record. I have to retrieve these data from the field table. Actually...retrieve record from table  Hi. I have a field in database named... chennai as one value, trichy as one value. and i have to show it in html. how
mysql select into table from another table example
from one table into another table. Check the example at MySQLselect into new...mysql select into table from another table example  Can you suggest the correct example of select into table from another table example in MySQL
how to move records from one table to other based on its creation time
how to move records from one table to other based on its creation time  Hi all,, As part of my requirement ,the records in one table have to move... to the second table,has to delete from first table.. I am using oracle10, Any suggestions
Retrieving data from table using DBCP
;from a table!\n");     BasicDataSource 
retrieve record from the field table
,kanchipuram for a single record. I have to retrieve these data from the field table...retrieve record from the field table  Hi. I have a field in database... values like chennai as one value, trichy as one value. and i have to show it in html
How to retrieve record from table
,kanchipuram for a single record. I have to retrieve these data from the field table...How to retrieve record from table  Hi. I have a field in database... like chennai as one value, trichy as one value. and i have to show it in html
Retrieve Value from Table - Hibernate
Retrieve Value from Table   Hai friend, I need help, How can i retrieve values From database using hibernate in web Application. As I new to hibernate I couldn't find solution for this problem.. Can anyone help please.. 
Fetch user records from a table in database
Fetch user records from a table in database  Hi. I have a field...,trichy,kanchipuram for a single record. I have to retrieve these data from the field table. Actually they are separated by comma. I want to take the values
Copy One Database Table to Another
Copy One Database Table to Another   ... to another database table. That means we copy one table to a different table...;java CopyOneDatabaseTableToAnother Copy data from one database table
retrieve Dept Name from table dept and retrieve list of employee from emp table for that dept in combobox
retrieve data from database from table1 and display it in another textbox and from the same input paramter then its should retrieve the data from another table...retrieve Dept Name from table dept and retrieve list of employee from emp table
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able to.... i am only able to retrieve one value not more than that. means in my
retrieve record from table and show it in HTML
retrieve record from table and show it in HTML  Hi. I have a field...,trichy,kanchipuram for a single record. I have to retrieve these data from the field table. Actually they are separated by comma. I want to take the values
MYSQL retrieve record from Data table
MYSQL retrieve record from Data table  Hi. I have a field in database...,kanchipuram for a single record. I have to retrieve these data from the field table. Actually they are separated by comma. I want to take the values as single
I have to retrieve these data from the field table
I have to retrieve these data from the field table  Hi. I have... chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table. Actually they are separated by comma. I want to take the values
HTML & MYSQL - retrieve record from table
HTML & MYSQL - retrieve record from table  Hi. I have a field...,trichy,kanchipuram for a single record. I have to retrieve these data from the field table. Actually they are separated by comma. I want to take the values as single
reading the records from a .xlsx file and storing those records in database table
reading the records from a .xlsx file and storing those records in database table  Here is my requirement, I want to read the records from a .xlsx file and store that records in database table. I tried like this public class
How to compare two tables, and insert values which r not in one table to another table?
How to compare two tables, and insert values which r not in one table to another table?  Hi I need to compare two tables MainTable and OUTTable... MT (MT.serialno) values (Select SerialNo Main_Table MT from where not exists
JDBC: Select Records using Prepared Statement
how to retrieve records of table using Prepared Statement. Select Records ... the common sql query. Select statement is used to retrieve records from the table... records from the student table whose roll no is less than 10. package jdbc
Mysql From Table
Mysql From Table       Mysql From Table is used to specify the table from which the records... for From The keyword 'from' is used to specify the table 'Stu' from which records
how to retrieve data from table with runtime values in sql?
how to retrieve data from table with runtime values in sql?  how to retrieve data from table with runtime values in sql? For example, I have table... to execute the command with the dates which I pass. I know how to retrieve a particular
how to count unique and duplicate values from one table in mysql?
how to count unique and duplicate values from one table in mysql?  I have use EMP table.I want to count unique and duplicate records from emp table and how to use in java program
Insert Records in Table
Insert Records in Table       The Insert data in Table is used to insert  records or rows into the table in database. The Syntax used to insert records into a table
Adding a flex table in another flex table column
Adding a flex table in another flex table column  how to add a flex table in another flex table column
PHP WHERE clause example to fetch records from Database Table
the data within the MYSQL database table. You can also fetch the results using... Server and will fetch the results from the database table employee date is equal... different actions in MYSQL Database Tables. PHP WHERE Clause is one of them. We
delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery... [delete from CONTACT] int i=query.executeUpdate
JDBC : Duplicate records in a table
JDBC : Duplicate records in a table In this tutorial, you will learn how to find the duplicate records in a table. Duplicate records in a table : You can check for duplicate records of table. You can group record by any of fields
how to display a table from database using servlet
how to display a table from database using servlet  how to display a table with values from servletpage   Hi Friend, Please go through the following link: http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
 

 

 

DMCA.com