Jump to content

MySQL Store Procedure with Parameters?


random1

Recommended Posts

I've got the SQL:

 

CREATE PROCEDURE `procedure_add_new_user`(IN `p_user_name` VARCHAR(50))
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT 'Adds a new user (registration) to the \'user\' table.'
BEGIN
/* Adds a new user (Registration) */

INSERT INTO `user` (`user_profile_id`, `user_avatar_id`,
`user_status`, `user_username`, `user_password`, `user_passphrase`,
`user_title`, `user_firstname`, `user_lastname`,
`user_datetime_utc_last_login`, `user_datetime_utc_created`,
`user_date_of_birth`)
VALUES (2, 1, 1, p_user_name,
'password',
'passphrase',
'Mr', 'Jacob', 'Mendlebury', UTC_DATE,
UTC_DATE,
'1984-08-12 00:00:00');

SELECT `user_id` FROM `user` WHERE `user_username` = p_user_name;

END

 

'p_user_name' is the parameter I've created and I am calling it using:

 

procedure_add_new_user('test');

 

It complains about syntax about an error on line 1 but I can't find an issue.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/195981-mysql-store-procedure-with-parameters/
Share on other sites

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.