retrieve the records from one table to another table by using cursors
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)
View Answers
Related Tutorials/Questions & Answers:
update one table from another tableupdate
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 anothercopying 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
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
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 - HibernateRetrieve 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 databaseFetch 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
deleting all records from a table in mysql;
This will delete all the
records from the
table. But if you are
using auto...deleting all
records from a
table in mysql Hi,
I am finding code for deleting all
records from a
table in mysql.
How to delete all rows in mysql
deleting all records from a table in mysql;
This will delete all the
records from the
table. But if you are
using auto...deleting all
records from a
table in mysql Hi,
I am finding code for deleting all
records from a
table in mysql.
How to delete all rows in mysql
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
Copy One Database Table to Another
Copy data
from one database
table to
another!
4 row(s)affected...
Copy
One Database
Table to
Another
... to
another database
table. That means we copy
one table to a different
table retrieve record from table and show it in HTMLretrieve 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 tableMYSQL
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 tableI 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 tableHTML & 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
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... are retrieving
records from the
student
table whose roll no is less than 10
Mysql From Table
Mysql
From Table
Mysql
From Table is used to specify the
table from which the
records... '
from' is used to specify the
table 'Stu'
from which
records is retrieved
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 display a table from database using servlethow 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:ADS_TO_REPLACE_1
http://roseindia.net/jsp/servlet-jsp-data
delete row from a table using hibernatedelete 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
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 PHP WHERE clause example to fetch records from Database Table the data
within the MYSQL database
table. You can also fetch the results
using... on the MYSQL Server and will fetch the results
from the
database
table employee...)
To test the code we are
using existing database
table. You can create your
own
Retrieving Data from the table using PreparedStatement Retrieving Data
from the
table using PreparedStatement... to fetch the data
from the
database in the
table from our java program
using... the getWriter() method
of the PrintWriter class. We can
retrieve the data
from 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 values from database into table using jsphow to display values
from database into
table using jsp I want to display values
from database into
table based on condition in query, how... to display books based on either bookname or authorname, for this i created
one jsp page
Adding checkbox in table using that delete table rowsAdding checkbox in
table using that delete
table rows I need coding for how to add checkbox in
table,the
table data
from database.Using that checkbox select more than than
one rows,and
using delete button i want to delete
Select data from Table in Database the selected data
from table in database. The
select query in the database
retrieve... in the syntax
from table.
select *
from table;
The select query
retrieve all... the
table,
from where the data is
retrieve.
Understand with Example
Deleting Records using the Prepared Statement the
records from the
database
table by
using the PreparedStatement interface... for deleting the
records from the database
table.
Brief description below... Deleting
Records using the Prepared Statement
Display table performing action on another tableDisplay
table performing action on
another table
In this section, we have created two tables. The data in
table 1 have shown as a result of
the database... of the
table row,
another table will be displayed showing the data
of that row