How to transform online hours in webshop credits?
Help Please!
How to transform online hours in webshop credits?
Help Please!
how to modify this code to get webshop credits?
CREATE PROCEDURE [dbo].[WZ_DISCONNECT_MEMB]
@memb___id varchar(10)
AS
Begin
set nocount on
Declare @find_id varchar(10)
Declare @ConnectStat tinyint
declare @OnlineHours real
declare @cspoints int
Set @ConnectStat = 0
Set @find_id = 'NOT'
select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id
where I.memb___id = @memb___id
if( @find_id <> 'NOT' )
begin
SELECT @cspoints= cs_points FROM MEMB_INFO where memb___id = @memb___id
update MEMB_STAT set ConnectStat = @ConnectStat, DisConnectTM = getdate(), OnlineHours = @cspoints/10+(DATEDIFF(hh,ConnectTM,getdate()))
where memb___id = @memb___id
SELECT @OnlineHours =OnlineHours FROM MEMB_STAT WHERE memb___id = @memb___id
UPDATE [dbo].[MEMB_INFO]
SET cs_points=cs_points + (@OnlineHours * 10)
WHERE memb___id = @memb___id
end
end
GO
UPDATE [dbo].[MEMB_INFO]
SET cs_points=cs_points + (@OnlineHours * 10)
WHERE memb___id = @memb___id
end
end
GO
in this change name of table MEMB_INFO to table where you have stored credits row
and change name of cs_points "SET cs_points=cs_points" to name of credits row
so for example if your table name is Awesome and row of credits is Yeah
script should be
Code:CREATE PROCEDURE [dbo].[WZ_DISCONNECT_MEMB] @memb___id varchar(10) AS Begin set nocount on Declare @find_id varchar(10) Declare @ConnectStat tinyint declare @OnlineHours real declare @cspoints int Set @ConnectStat = 0 Set @find_id = 'NOT' select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id where I.memb___id = @memb___id if( @find_id <> 'NOT' ) begin SELECT @cspoints= cs_points FROM MEMB_INFO where memb___id = @memb___id update MEMB_STAT set ConnectStat = @ConnectStat, DisConnectTM = getdate(), OnlineHours = @cspoints/10+(DATEDIFF(hh,ConnectTM,getdate())) where memb___id = @memb___id SELECT @OnlineHours =OnlineHours FROM MEMB_STAT WHERE memb___id = @memb___id UPDATE [dbo].[Awesome] SET Yeah=Yeah + (@OnlineHours * 10) WHERE memb___id = @memb___id end end GO
where OnlineHours * 10
10 = number of credits for 1 hour
==>CREATE PROCEDURE [dbo].[WZ_DISCONNECT_MEMB]
@memb___id varchar(10)
AS
Begin
set nocount on
Declare @find_id varchar(10)
Declare @ConnectStat tinyint
declare @OnlineHours real
declare @cspoints int
Set @ConnectStat = 0
Set @find_id = 'NOT'
select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id
where I.memb___id = @memb___id
if( @find_id <> 'NOT' )
begin
SELECT @cspoints= cs_points FROM MEMB_INFO where memb___id = @memb___id
update MEMB_STAT set ConnectStat = @ConnectStat, DisConnectTM = getdate(), OnlineHours = @cspoints/10+(DATEDIFF(hh,ConnectTM,getdate()))
where memb___id = @memb___id
SELECT @OnlineHours =OnlineHours FROM MEMB_STAT WHERE memb___id = @memb___id
UPDATE [dbo].[MEMB_CREDITS]
SET credits=credits + (@OnlineHours * 2)
WHERE memb___id = @memb___id
end
end
GOHelp?:-sServer: Msg 446, Level 16, State 9, Procedure WZ_DISCONNECT_MEMB, Line 12
Cannot resolve collation conflict for equal to operation.
Last edited by mRpLaYbOy; 24-06-12 at 06:19 PM.
change names there too
declare @cspoints int
select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id
SELECT @cspoints= cs_points FROM MEMB_INFO where memb___id = @memb___id
update MEMB_STAT set ConnectStat = @ConnectStat, DisConnectTM = getdate(), OnlineHours = @cspoints/10+
MEMB_INFO to ur credits table (MEMB_CREDITS)
and cspoints to ur credits row (credits)
and of course if in ur table MEMB_CREDITS accounts is different than memb___id change this line everywhere too
but if you have memb___id in MEMB_CREDITS don't change this line ;p
hope u get it
in memb_stat don`t work OnlineHours... How To Fix?
Up :-s
Up :(