Post Pacific

Post Pacific (https://postpacific.loc-online.com/index.php)
-   Темы без сохранившегося раздела (https://postpacific.loc-online.com/forumdisplay.php?f=10001)
-   -   [Fix] Error sql: EXEC lin_NominateHeroes (https://postpacific.loc-online.com/showthread.php?t=6163)

Charis 05.11.2006 17:13

[Fix] Error sql: EXEC lin_NominateHeroes
 
I don't know if someone else have that error in Cashed< but I have and so share fix for it

All you need is to update DB procedure:
Code:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO





ALTER  PROCEDURE dbo.lin_NominateHeroes
(
@now_season INT,
@new_step INT,
@new_season_start_time INT
)
AS
SET NOCOUNT ON

UPDATE user_nobless
SET hero_type = 0

CREATE TABLE #hero_candidate (char_id INT, main_class INT, match_count INT, olympiad_point INT)
INSERT INTO #hero_candidate (char_id, main_class, match_count, olympiad_point)
        SELECT un.char_id, ud.subjob0_class, un.match_count, un.olympiad_point
        FROM user_nobless un, user_data ud
        WHERE un.char_id = ud.char_id AND un.match_count >= 5 AND un.olympiad_win_count >= 1

CREATE TABLE #highest_score (main_class INT, olympiad_point INT, match_count INT)

DECLARE @hero_candidate_class INT
DECLARE hero_candidate_cursor CURSOR FOR
SELECT DISTINCT main_class FROM #hero_candidate

OPEN hero_candidate_cursor

FETCH NEXT FROM hero_candidate_cursor INTO @hero_candidate_class

WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #highest_score
        SELECT TOP 1 main_class, olympiad_point, match_count
        FROM #hero_candidate
        WHERE main_class = @hero_candidate_class
        ORDER BY olympiad_point DESC, match_count DESC

        FETCH NEXT FROM hero_candidate_cursor INTO @hero_candidate_class
END
CLOSE hero_candidate_cursor
DEALLOCATE hero_candidate_cursor

CREATE TABLE #highest_score_nobless (char_id INT, main_class INT)
INSERT INTO #highest_score_nobless
        SELECT c.char_id, c.main_class FROM #hero_candidate c, #highest_score s
                WHERE c.main_class = s.main_class AND c.olympiad_point = s.olympiad_point AND c.match_count = s.match_count

CREATE TABLE #hero (char_id INT, main_class INT)
INSERT INTO #hero
        SELECT char_id, main_class  FROM #highest_score_nobless WHERE main_class IN (SELECT main_class FROM #highest_score_nobless GROUP BY main_class HAVING COUNT(main_class) = 1)

UPDATE user_nobless
SET hero_type = 1, win_count = win_count+1
WHERE char_id IN (SELECT char_id FROM #hero)

UPDATE user_nobless
SET previous_point = olympiad_point

UPDATE user_nobless
SET olympiad_point = 0, match_count = 0, olympiad_win_count = 0, olympiad_lose_count = 0

INSERT INTO olympiad_result
        SELECT @now_season, main_class, char_id, olympiad_point, match_count, 0, 0 FROM #hero_candidate

INSERT INTO olympiad
        (step, season_start_time) VALUES (@new_step, @new_season_start_time)

SELECT @@IDENTITY



GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO


m4rk 05.11.2006 18:29

Will try it... Comparing the old procedure with this one I understand some things now...

Thanks a lot!

top-gear 01.12.2006 01:29

I used that script and I can see the hero_type = 1 for some chars to "nobless" table, but I start the server and the hero list is empty. Am I missing something?

djvogans 01.01.2007 12:32

fixed : olympiad_result table not complete

season:int
class:int
char_id:int
point:int
match_count:int
olympiad_win_count:int
olympiad_lose_count:int


All times are GMT. The time now is 15:06.