MySQL:
delimiter // CREATE PROCEDURE P__Test_Insert( out nUserId int, in strAlias varchar(100), in strPwd varchar(100) ) Begin if not exists(select * from _User where UserName = strAlias) then insert into _User(UserName, PassWord, CreateTime) values(strAlias, strPwd, now()); set nUserId = LAST_INSERT_ID(); end if; End前提:ID字段需设置为AUTO_INCREMENT。