Solo usuarios registrados pueden comentar y agradecer, Logueate o Registrate

Autor Topic: Problema al ejecutar proseso almacenado SQL ejecuta una parte y la otra no  (Visto 1657 veces)

0 Miembros and 1 Guest are viewing this topic.

Offline YolaxD Posteado: July 28, 2017, 10:57:53 PM | Modificado: July 28, 2017, 11:01:00 PM by yolaxd

  • C++ Coder
  • 0 puntos por ventas
  • *
  • Rank: Puto amo
  • Posts: 542
  • Gracias recibida: 8368
  • ar
hola como dice el titulo tengo un problema con un proseso almacenado el cual me ejecuta todo bien asta llegar a incertar informacion a dos tablas el problema se genera ay digamos que tenemos la tabla 1 en la cual se guarda informacion de pepe y en la tabla 2 se guarda la info de juan lo que me pasa es que se guarda solo la de juan que esta ultima y la primera de pepe no se guarda la verdad me esta comiendo el coco esto dejo el proseso por si le ven algo mal

Code: [Select]


USE [MuOnline]
GO

/****** Object:  StoredProcedure [dbo].[BattleCoreJoinUser]    Script Date: 07/28/2017 23:54:59 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[BattleCoreJoinUser]
@AccountID varchar(10),
@Name varchar(10),
@UBFName varchar(10),
@ServerCode int,
@RegisterState int,
@RegisterMonth int,
@RegisterDay int
AS
BEGIN
SET NOCOUNT ON;

IF ((SELECT COUNT (*) FROM BattleCoreInfo WHERE AccountID = @AccountID AND RegisterState = 1) >= 2)
BEGIN
SELECT 4 AS Result
RETURN
END

IF EXISTS (SELECT * FROM BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @UBFName AND ServerCode = @ServerCode AND RegisterState = 1)
BEGIN
SELECT 2 AS Result
RETURN
END

IF EXISTS (SELECT * FROM BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @UBFName AND ServerCode = @ServerCode AND RegisterState = 0)
BEGIN
DECLARE @LeftTime smalldatetime
SELECT @LeftTime = LeftTime FROM BattleCoreInfo WHERE AccountID = @AccountID AND UBFName = @UBFName AND ServerCode = @ServerCode AND RegisterState = 0

IF (DATEDIFF(SECOND, @LeftTime, GETDATE()) < 180)
BEGIN
SELECT 3 AS Result, (180 - DATEDIFF(SECOND, @LeftTime, GETDATE())) AS LeftSecond
RETURN
END
ELSE
BEGIN
UPDATE BattleCoreInfo SET RegisterState = 1, RegisterMonth = @RegisterMonth, RegisterDay = @RegisterDay WHERE AccountID = @AccountID AND UBFName = @UBFName AND ServerCode = @ServerCode
SELECT 1 AS Result
RETURN
END
END
ELSE
BEGIN

DECLARE @FreeKeyName int
SET @FreeKeyName = 0

WHILE (1 = 1)
BEGIN

SET @FreeKeyName = ROUND(((2000000000 - 1 -1) * RAND() + 1), 0)
IF NOT EXISTS (SELECT * FROM [dbo].BattleCoreInfo WHERE Name = @FreeKeyName)
BEGIN
BREAK
END
END


                                  Aqui esta el problema este no se ejecuta el de abajo si!



 
INSERT INTO BattleCoreInfo (AccountID, Name, UBFName, ServerCode, RegisterState, RegisterMonth, RegisterDay, LeftTime)

VALUES (@AccountID, @FreeKeyName, @UBFName, @ServerCode, 1, @RegisterMonth, @RegisterDay, NULL)



INSERT INTO BattleCoreAccountCharacter(Id, GameID1, GameID2, GameID3, GameID4, GameID5, GameIDC, MoveCnt,ExtClass, ExtWarehouse)

VALUES (@AccountID, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 1)




SELECT 0 AS Result
END
RETURN
END

GO



Offline YolaxD #1 Posteado: July 29, 2017, 12:29:12 AM

  • C++ Coder
  • 0 puntos por ventas
  • *
  • Rank: Puto amo
  • Posts: 542
  • Gracias recibida: 8368
  • ar
Solucion: no se le pasa el valor a un campo que tenia valor null no permitido por lo tanto no dejaba ejecutar pero tampoco daba error


Solo usuarios registrados pueden comentar y agradecer, Logueate o Registrate


 

Related Topics

  Subject / Started by Replies Last post
4 Replies
1905 Views
Last post March 23, 2017, 06:08:20 PM
by extrajuegosya
0 Replies
696 Views
Last post May 04, 2017, 11:12:21 AM
by humito
5 Replies
1631 Views
Last post April 25, 2018, 04:23:48 PM
by caron22
1 Replies
1597 Views
Last post August 12, 2022, 02:48:29 PM
by ShinedowN
3 Replies
1135 Views
Last post February 16, 2024, 09:34:12 AM
by ShinedowN