...

View Full Version : stored procedure help



esthera
08-24-2006, 07:18 AM
i'm trying to create my first stored procedure.
this is what i have so far. No procedural statements yet as I want to get this working first and then i'll add in more.
now i'm still getting errors on every line.
what am I doing wrong?



DELIMITER //

CREATE PROCEDURE spinsertnew (_filesource int,_firstname char(200),_lastname char(200))

BEGIN

DECLARE _Random int;
DECLARE _Upper int;
DECLARE _Lower int;
DECLARE _MyIdentity int;
DECLARE _isdouble int;

END;
//

vinyl-junkie
08-28-2006, 03:02 AM
I'm pretty new to stored procedures, but I think what is missing is the word AS:


DELIMITER //

CREATE PROCEDURE spinsertnew (_filesource int,_firstname char(200),_lastname char(200))

AS

BEGIN

DECLARE _Random int;
DECLARE _Upper int;
DECLARE _Lower int;
DECLARE _MyIdentity int;
DECLARE _isdouble int;

END;
//

BTW, you should use code tags to distinguish your code from the rest of your post. That makes it much easier to read. :)

guelphdad
08-28-2006, 03:19 AM
are you using mysql 5? you can't create a stored procedure if you aren't using mysql 5. do a
select version() to see what version you are using.

esthera
08-29-2006, 06:53 PM
i'm using mysql 5 but maybe it's not installed properly as now I'm getting an error mysql.proc does not exist.

by the way the as is used with sql sever but I don't think with mysql.

christrinder
01-07-2007, 07:16 PM
Does version 4.0.23 not support Stored Procedures in any way at all?

I've just signed up to a hosting package (with the above version of MySql) and am here because I can't create a stored procedure. Are you saying I will need to find a new hosting company to be able to use Stored Procs? :(

Thanks for your help.
Chris

guelphdad
01-07-2007, 10:10 PM
no not at all, only 5 supports stored procedures.

you should find another host 4.0.x is out of date, and they should be using 4.1 at a minimum. you are not able to use subqueries or GROUP_CONCAT nor manage collations and character sets in 4.0 the way you are able to do for 4.1 and above.

Note that 5.0 is the current production version of mysql, supplanting 4.1 in October 2005. MySQL 4.1 supplanted 4.0.x in October 2004 so that is quite out of date.

christrinder
01-08-2007, 02:50 PM
Oh bum! :(

To be honest, the only reason I used Stored Procedures was the ability to return the identity of newly inserted rows. Is there another way I can do this in MySQL 4.0?

Thanks again for your help. :thumbsup:

Regards,
Chris

LimpBagel
01-19-2007, 05:34 AM
If you are using PHP, mysql_insert_id()

guelphdad
01-19-2007, 10:41 PM
last_insert_id() is the function in mysql. php's mysql_insert_id() merely calls last_insert_id. I mention it because you can probably find something similar if you are using another application than php.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum