Jump to content
Fórum Script Brasil
  • 0

Ajuda com query


bigjohn
 Share

Question

Olá caros amigos, sou estudante novato em SQL, Tenho uma query um pouco avançada gostaria de entende-la para poder modifica-la para outro fim se alguém poder me ajuda ficaria agradecido.

Essa query e pra ser rodada em um banco de dados que uso como teste de um jogo online que tenho, no entendimento geral ela adiciona 60 de cash para cada 20 minutos logados, precisaria que ela em vez de cash fosse gold conforme essa outra query que só adiciona o gold mas queria que fosse por tempo.

 

Query que só coloca gold.

UPDATE [RF_WORLD].[dbo].[tbl_supplement] SET [ActionPoint_2]='QUANTIDADE' WHERE [Serial]='Serial do char'

 

query que adiciona cash

                                                                               1°

USE [RF_World]
ALTER TABLE [dbo].[tbl_base]
ADD LogPlay INT NOT NULL DEFAULT (()) #cria uma nova coluna 

USE [RF_World]

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[pUpdate_Base_MRF]
 @serial INT,
 @logPlay INT
AS
BEGIN

	SET NOCOUNT ON
	
	UPDATE [dbo].[tbl_base]
	SET LogPlay = @logPlay
	WHERE Serial = @serial
	
END
GO

 

USE [Billing]

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[RF_Autocash]
 @id VARCHAR(17),
 @cash INT
AS
BEGIN

	SET NOCOUNT ON
	
	UPDATE [dbo].[tbl_UserStatus]
	SET Cash = (Cash + @cash)
	WHERE id = @id
	
END
GO

 

USE [RF_World]

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [dbo].[Autocash]
	ON [dbo].[tbl_general]
	FOR UPDATE
AS 
BEGIN

	SET NOCOUNT ON
	
	DECLARE @GSerial INT
	DECLARE @GDCK BIT
	DECLARE @GPlay INT
	
	DECLARE @BSerial INT
	DECLARE @BDCK BIT
	DECLARE @BAccount VARCHAR(17)
	DECLARE @BPlay INT
	
	DECLARE @regencash INT
	
	IF UPDATE(TotalPlayMin)
	BEGIN
		SELECT @GSerial = Serial, @GDCK = DCK, @GPlay = TotalPlayMin FROM INSERTED
		IF (@GSerial >  AND @GDCK = )
		BEGIN
			SELECT @BSerial = Serial, @BDCK = DCK, @BAccount = Account, @BPlay = LogPlay FROM [dbo].[tbl_base] WHERE Serial = @GSerial
			IF (@BSerial >  AND @BDCK = )
			BEGIN
				SELECT @regencash = (((@GPlay-@BPlay)/20)*60)
				IF  (@regencash > )
				BEGIN
					EXEC [Billing].[dbo].[RF_Autocash] @id = @BAccount, @cash = @regencash
					EXEC [RF_World].[dbo].[pUpdate_Base_MRF] @serial = @GSerial, @logPlay = @GPlay
				END	
			END
		END	
	END
	
END
GO
Edited by bigjohn
Correção de ortografia.
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.2k
×
×
  • Create New...