Storage process (SQL sample version)
Today I will send you a SQL storage process for you to understand
The code copy is as follows:
CREATEPROCEDURElogin_verify
(
@community_idint,--take the value
@usernamevarchar(20),
@passwordvarchar(40),
@resulttinyintoutput
)
AS
setnocountON
declare@service_deadline_datesmalldatetime,@community_setting_max_online_countint--Define a variable in a short date format
select@community_setting_max_online_count=community_setting_max_online_count,@service_deadline_date=service_deadline_datefromcommunity_infowherecommunity_id=@community_id--This is to find the maximum number of logins.
ifdatediff(d,@service_deadline_date,getdate())>10--In fact, this is to limit the user's usage period. If the current date and the record date in the library are greater than 10 days, then return @result=11
Begin
set@result=11--Exceeding service life
Return
end
if(selectcount(*)fromonline_userwhere=@community_setting_max_online_count">community_id=@community_id)>=@community_setting_max_online_count--Comparison with the current number of people based on the record settings in the library
Begin
set@result=10--Exceed the online number limit-Return to @result=10
Return
end
declare@stamiaint,@last_update_stamia_datesmalldatetime,@level_idint--Define variable integer short date integer
declare@useridint,@user_roleint
select@userid=userid,@user_role=user_role,@stamia=stamia,@last_update_stamia_date=last_update_stamia_date,@level_id=level_idfromuser_infowhereusername=@usernameandpassword=@passwordandcommunity_id=@community_idanduser_type=0
--Write some information into the three variables defined from the user information table
if@useridisnotnull---If @userid does not change the null value
begin--Username and password verification is successful
set@result=1--The test is successful
Return
end
else
Begin
set@result=0--Log in failed
end
setnocountOFF
GO
Let's name the above process login_verify
Written as the place where security authentication is called in ASP code
'''Conn has been defined in advance
Setcmd.ActiveConnection=conn
cmd.CommandText="login_verify"
cmd.CommandType=&H0004
@community_idint,--take the value
@usernamevarchar(20),
@passwordvarchar(40),
@resultint
cmd.Parameters.Appendcmd.CreateParameter("@community_id",3)
cmd.Parameters.Appendcmd.CreateParameter("@username",200)