Jump to content

Cannot use CREATE PROCEDURE, FUNCTION in mysql 5.0.26


DarkReaper

Recommended Posts

Well the topic says it all :) i have mysql 5.0.26 and i cant use
CREATE PROCEDURE
CREATE FUNCTION
i've tried with CREATE VIEW and it worked. So i guess ... HELP?! :)

Here is the result of an example simple procedure from the mysql manual

CREATE PROCEDURE simpleproc ()
  BEGIN
    SELECT COUNT(*) FROM log;
    END;

-- result:
#1064 - 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 'SELECT COUNT(*) FROM log' at line 3
Post your whole exact SQL that you're getting the syntax error on in order for people on this forum to help you better, or is that it?

Try

SELECT COUNT(*) INTO total_count FROM log;

Then you can do something with it like:

IF (total_count > 10) THEN
  # do something
END IF;


Thats all. :) This was just a test to see if i can even create a procedure ... one more odd thing to report is that when i do this:
CREATE PROCEDURE tst()
BEGIN
END;

- no error occures and the procedure is created.
But when i add even the simplest select/insert etc. query between the begin and end i get a query error ... please if someone knows why this is happening help me out :)
I updated my previous post.

Are you trying to return the total count of rows? Try something like:

CREATE DEFINER=`root`@`%` PROCEDURE `get_total_log_count`(                         
                            OUT total_log_count INT(7)
                            )                 
BEGIN
    SELECT COUNT(*) INTO total_log_count FROM log;

END

Basically i want when i call the procedure to insert in a couple of tables new row/s with the needed values.
I know how to do it, but i don't know why mysql doesnt accept my syntax :(

The example you've provided doesn't work mysql outputs an error, phpmyadmin also but with an "empty" mysql error ... strange things happen ...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.