create table parent_user ( userid int auto_increment primary key, username varchar(100) not null, password varchar(200) not null, email varchar(200) not null );
edit : ok made changes:
create procedure `parent_reg` ( pusername varchar(100) ppassword varchar(200) pemail varchar(200) ) begin declare count int declare returncode int select count = count(username) parent_user username = @username if count > 0 begin set returncode = -1 end else begin set returncode = 1 insert parent_user values (pusername, ppassword, pemail) end select preturncode returnvalue end
but still got same error- error 1064: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'ppassword varchar(200) pemail varchar(200) ) ....'
the syntax error @ 'ppassword varchar(200)'
this invalid syntax mysql stored procedure. code posted looks more microsoft sql server (transact sql) syntax.
some observations:
mysql procedure variables cannot start @
. (that character reserved user-defined variables.)
mysql doesn't use nvarchar
type. believe it's setting of character_set_client
variable in session (at time procedure created) controls characterset of procedure variables.
the line select * parent_user,
before create procedure
looks entirely out of place.
missing semicolons. insert
table 4 columns, 3 values, , there's no column list. lots of other oddly bizarre syntax.
if goal create stored procedure in mysql, you'd need syntax closer this:
delimiter $$ create procedure parent_reg(p_username varchar(100), p_password varchar(200), p_email varchar(200) ) begin declare mycount int; declare myreturncode int; select count(pu.username) mycount `parent_user` pu pu.username = p_username; if (mycount > 0 ) set myreturncode = -1; else set myreturncode = 1; insert `parent_user` (`username`, `password`, `email`) values (p_username, p_password, p_email); end if; select myreturncode `returnvalue`; end$$ delimiter ;
Comments
Post a Comment