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
Link to comment
Share on other sites

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;


Link to comment
Share on other sites

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 :)
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.