MySQL Forums
Forum List  »  Stored Procedures

Creating table
Posted by: Patricio Calderon
Date: March 10, 2013 05:20PM

Hello,
I'm trying to create a table using a stored procedure. The table is created, but it's empty. I tested the select statement to make sure it was pulling out what I needed, but when I look at the resulting table, test_t1, it is empty.

What am I missing?

Thanks,
Patricio

DROP PROCEDURE IF EXISTS sinai_new_connections.test3;
CREATE PROCEDURE sinai_new_connections.`test3`()
BEGIN
DECLARE l_id_participant varchar(11);
DECLARE l_first_name varchar(45);
DECLARE l_date_interview date;
DECLARE done INT DEFAULT 0;

DECLARE cur1 CURSOR FOR
select distinct
a.id_participant,
a.first_name,
b.date_interview
from
participants a inner join master_interviews b on a.id_participant = b.participants_id_participant;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
SET done=0;

CREATE TABLE IF NOT EXISTS test_t1
(id_participant varchar(11), first_name varchar(45), date_interview date);

OPEN cur1;
part: LOOP

FETCH cur1 INTO l_id_participant, l_first_name, l_date_interview;

IF done=1 THEN
LEAVE part;
END IF;

END LOOP part;
CLOSE cur1;

SET done=0;

select
id_participant,
first_name,
date_interview
from
test_t1;

END;

Options: ReplyQuote


Subject
Views
Written By
Posted
Creating table
1850
March 10, 2013 05:20PM
935
March 10, 2013 06:00PM
1162
March 10, 2013 08:22PM
935
March 11, 2013 10:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.