DarkReaper Posted November 4, 2006 Share Posted November 4, 2006 Well the topic says it all :) i have mysql 5.0.26 and i cant use CREATE PROCEDURECREATE FUNCTIONi've tried with CREATE VIEW and it worked. So i guess ... HELP?! :)Here is the result of an example simple procedure from the mysql manualCREATE 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 Quote Link to comment Share on other sites More sharing options...
toplay Posted November 4, 2006 Share Posted November 4, 2006 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?TrySELECT COUNT(*) INTO total_count FROM log;Then you can do something with it like:IF (total_count > 10) THEN # do somethingEND IF; Quote Link to comment Share on other sites More sharing options...
DarkReaper Posted November 4, 2006 Author Share Posted November 4, 2006 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()BEGINEND;- 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 :) Quote Link to comment Share on other sites More sharing options...
toplay Posted November 4, 2006 Share Posted November 4, 2006 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 Quote Link to comment Share on other sites More sharing options...
DarkReaper Posted November 4, 2006 Author Share Posted November 4, 2006 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 ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.