filmov
tv
MySQL Stored Procedure Beginners Tutorial #14 - Basics of Cursor in MySQL Stored Procedure | Cursor
Показать описание
In this video we'll see:
Basics of Cursor in MySQL Stored Procedure | Cursor
ABOUT MYSQL CURSOR
============================
MySQL cursor in stored procedures to iterate through a result set returned by a SELECT
statement.
To handle a result set inside a stored procedure, we use a cursor. A cursor allows you to
iterate a set of rows returned by a query and process each row accordingly.
SYNTAX TO FOLLOW TO USE CURSOR
==================
1. DECLARE cursor_name CURSOR FOR SELECT_statement;
2. OPEN cursor_name;
3. DECLARE CONTINUE HANDLER FOR NOT FOUND // termination statement
4. FETCH cursor_name INTO variables list;
5. CLOSE cursor_name;
Example:
BEGIN
DECLARE finished int default 0;
DECLARE emails_list varchar(500) default "";
DECLARE email varchar(50) default "";
DECLARE user_data CURSOR FOR SELECT email from tbl_users limit 5;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;
OPEN user_data;
get_user_email: LOOP
FETCH user_data INTO email;
IF finished = 1 THEN
LEAVE get_user_email;
END IF;
SET emails_list = CONCAT(emails_list,", ",email);
END LOOP get_user_email;
CLOSE user_data;
SELECT emails_list;
END
SOCIAL :
===============
Other Tutorials
===============
Wordpress Customizations:
---------------------------------
and many more...
Javascript framework:
----------------------------------
PHP Frameworks:
----------------------------------
Tags
----------------------------------
mysql stored procedure,
Stored Procedures - MySQL,
Stored Procedures in MySQL and PHP,
SQL Stored Procedures,
MySQL Stored Procedure Tutorial,
MySQL Stored Procedure & MySQL Functions Guide,
mysql stored procedure for beginners,
Beginners' guide to stored procedures with MySQL,
Getting Started with MySQL Stored Procedures,
mysql stored procedure development for beginners,
mysql stored procedure from scratch,
online web tutor mysql stored procedures,
online web tutor sanjay,
Thanks
Online Web Tutor
Keep learning and Sharing :)
Basics of Cursor in MySQL Stored Procedure | Cursor
ABOUT MYSQL CURSOR
============================
MySQL cursor in stored procedures to iterate through a result set returned by a SELECT
statement.
To handle a result set inside a stored procedure, we use a cursor. A cursor allows you to
iterate a set of rows returned by a query and process each row accordingly.
SYNTAX TO FOLLOW TO USE CURSOR
==================
1. DECLARE cursor_name CURSOR FOR SELECT_statement;
2. OPEN cursor_name;
3. DECLARE CONTINUE HANDLER FOR NOT FOUND // termination statement
4. FETCH cursor_name INTO variables list;
5. CLOSE cursor_name;
Example:
BEGIN
DECLARE finished int default 0;
DECLARE emails_list varchar(500) default "";
DECLARE email varchar(50) default "";
DECLARE user_data CURSOR FOR SELECT email from tbl_users limit 5;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;
OPEN user_data;
get_user_email: LOOP
FETCH user_data INTO email;
IF finished = 1 THEN
LEAVE get_user_email;
END IF;
SET emails_list = CONCAT(emails_list,", ",email);
END LOOP get_user_email;
CLOSE user_data;
SELECT emails_list;
END
SOCIAL :
===============
Other Tutorials
===============
Wordpress Customizations:
---------------------------------
and many more...
Javascript framework:
----------------------------------
PHP Frameworks:
----------------------------------
Tags
----------------------------------
mysql stored procedure,
Stored Procedures - MySQL,
Stored Procedures in MySQL and PHP,
SQL Stored Procedures,
MySQL Stored Procedure Tutorial,
MySQL Stored Procedure & MySQL Functions Guide,
mysql stored procedure for beginners,
Beginners' guide to stored procedures with MySQL,
Getting Started with MySQL Stored Procedures,
mysql stored procedure development for beginners,
mysql stored procedure from scratch,
online web tutor mysql stored procedures,
online web tutor sanjay,
Thanks
Online Web Tutor
Keep learning and Sharing :)
Комментарии