/****************************************************************************** 2 Examples of SELECT ... INTO ******************************************************************************/ /*==================================================================== SELECT bounded INTO variables =====================================================================*/ DROP PROCEDURE get_student; / CREATE PROCEDURE get_student(param_student_id INT) BEGIN DECLARE v_fname VARCHAR(30); -- local variables DECLARE v_lname VARCHAR(30); DECLARE v_ssn VARCHAR(30); SELECT fname, lname, ssn -- SELECT bounded INTO INTO v_fname, v_lname, v_ssn FROM student WHERE student_id = param_student_id; SELECT v_fname, v_lname, v_ssn; -- unbounded SELECT END; / CALL get_student(3); / /*==================================================================== SELECT bounded INTO global variables =====================================================================*/ DROP PROCEDURE get_student2; / CREATE PROCEDURE get_student2(param_student_id INT) BEGIN SELECT fname, lname, ssn INTO @v_fname, @v_lname, @v_ssn -- global variables FROM student WHERE student_id=param_student_id; END; / CALL get_student2(3); / SELECT @v_fname, @v_lname, @v_ssn as ssn; -- access variable from outside