I wrote a Cursor in MySQL to insert values in 2 columns in the intermediate table dw_attended_code_events
DELIMITER //
CREATE PROCEDURE attended_code_events_table()
BEGIN
DECLARE done BOOLEAN DEFAULT FALSE;
DECLARE coder_ID VARCHAR(40);
DECLARE att_code_events CURSOR
FOR SELECT 'ID.x' FROM New_Coders_Survey_Data
WHERE 'ResourceBlogs' = 1;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN att_code_events;
REPEAT
FETCH att_code_events INTO coder_ID;
INSERT INTO dw_attended_code_events (code_event_id, coder_id) VALUES(1, coder_ID);
UNTIL done END REPEAT;
CLOSE att_code_events;
END; //
DELIMITER ;
Into code_event_id
I need to insert id - which is "1" and into coder_id
I need to insert the coder id that comes from table New_Coders_Survey_Data
My cursor currently inserting 1 record: 1 into 1st column and NULL into 2nd column.
How can I correct my cursor?
Kind regards, Anna