TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

MySQL Cursor

MySQL Cursor for beginners and professionals on mysql tutorial, examples, functions, programming, mysql, literals, cursor, procedure, trigger, regexp_like(), regexp_replace operator, regular expression, regexp_instr(), crud etc.

<< Back to MYSQL

MySQL Cursor

In MySQL, Cursor can also be created. Following are the steps for creating a cursor.

1. Declare Cursor

A cursor is a select statement, defined in the declaration section in MySQL.

Syntax

DECLARE cursor_name CURSOR FOR
Select statement;

Parameter:

cursor_name: name of the cursor

select_statement: select query associated with the cursor

2. Open Cursor

After declaring the cursor the next step is to open the cursor using open statement.

Syntax

Open cursor_name;

Parameter:

cursor_name: name of the cursor which is already declared.

3. Fetch Cursor

After declaring and opening the cursor, the next step is to fetch the cursor. It is used to fetch the row or the column.

Syntax

FETCH [ NEXT [ FROM ] ] cursor_name INTO variable_list;

Parameter:

cursor_name: name of the cursor

variable_list: variables, comma separated, etc. is stored in a cursor for the result set

4. Close Cursor

The final step is to close the cursor.

Syntax

Close cursor_name;

Parameter:

Cursor_name: name of the cursor

Example for the cursor:

Step 1: Open the database and table.

MySQL Cursor

Step 2: Now create the cursor.

Query:

MySQL Cursor

Step 3: Now call the cursor.

Query:

SET @name_list ="";
CALL list_name(@name_list);
SELECT @name_list;
MySQL Cursor
Next TopicMySQL limit




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf