Home > Database > Mysql Tutorial > body text

Why do I need to declare a NOT FOUND handler when using MySQL cursors?

WBOY
Release: 2023-09-09 16:33:07
forward
1061 people have browsed it

为什么在使用 MySQL 游标时需要声明 NOT FOUND 处理程序?

When using MySQL cursors, we must declare the NOT FOUND handler because it handles the case where the cursor cannot find any rows. It also handles when the cursor reaches the end of a row, because every time we call the FETCH statement, the cursor tries to try the next row in the result set. Following is the syntax for declaring NOT FOUND handler -

DECLARE CONTINUE HANDLER FOR NOT FOUND SET var_name = value;
Copy after login

Here var_name is the name of any variable and value is the value of that variable. For example, we can declare -

DECLARE CONTINUE HANDLER FOR NOT FOUND SET err = 1;
Copy after login
as follows

The above is the detailed content of Why do I need to declare a NOT FOUND handler when using MySQL cursors?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template