Rakesh Poddar
Rakesh Poddar

Reputation: 193

How to use or declare Cursors in Phpmyadmin?

I am reading the book Sams Teach Yourself SQL in 10 Minutes (Fifth Edition) to learn SQL.

I cam across the chapter on Cursors and tried to execute the below query in phpmyadmin

DECLARE CustCursor CURSOR
FOR
SELECT * FROM Customers
WHERE cust_email IS NULL;

And got this error:

Unrecognized statement type. (near "DECLARE" at position 0)

I tried searching a lot and even question on StackOverflow but couldn't find any answer which could solve the issue. Some talks were regarding Delimiters but I couldn't solve the issue and just learnt that DELIMITER is not a MySQL command..

Upvotes: 0

Views: 397

Answers (1)

Gadonski
Gadonski

Reputation: 3330

The problem is not with PhpMyAdmin, but the syntax of your sql command.

Cursors only can be declared inside a procedure. You cant write a simple select with cursor and execute, this will throw and error.

Take a look on the thread: MySql Cursor - Creating a procedure OR Mysql Stored procedure with cursor

Upvotes: 1

Related Questions