On Wed, Mar 12, 2008 at 9:52 PM, smriti Sebastian <[EMAIL PROTECTED]> wrote: > Hi all, > I tried to implement a cursor using the following statement: > create procedure curdemo() > begin > declare cursor1 cursor for select SID from customer; > > I have a customer table with a field SID. > BUt I am getting an error > ERROR 1064 (42000): You have an error in your SQL syntax; check the manual > that corresponds to your MySQL server version for the right syntax to use > near '' at line 1 > > Plz help me to solve this.Thanks in advance. >
Your really jumping into the advanced features of mysql... I do not know what in particular is wrong with your query. If I had to make a guess I would say you are trying to execute it in phpmyadmin or similar and not declaring a delimiter. When I write stored procedures I always write them in a text file and then execute that from the command line. I generally doing something like: DROP PROCEDURE IF EXISTS proc_name(); DELIMITER | CREATE PROCEDURE proc_name() BEGIN DECLARE cursor_name CURSOR FOR SELECT * FROM db_name.table_name END I then create the procedure with something like: "C:\Program Files\MySQL\MySQL SERVER 5.0\bin\mysql.exe" db_name -u user_name < "C:\Documents and Settings\rob\stored_proc.sql" I have not checked that the above code will work. There may be typo's, etc... -- Rob Wultsch -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]