Register for your free account! | Forgot your password?

You last visited: Today at 10:48

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Clean and functional Stored Procedures

Discussion on Clean and functional Stored Procedures within the SRO PServer Guides & Releases forum part of the SRO Private Server category.

Reply
 
Old   #1

 
*Silverlight*'s Avatar
 
elite*gold: 13
Join Date: Sep 2015
Posts: 303
Received Thanks: 334
Clean and functional Stored Procedures

What the hell is this?

While working on checking the Stored Procedures for blietzkrieg (or however it's written) package I noticed that many of them will not run due to wrong column names being used or more weird scenarios.

I have basically gone through each one of the errors and manually fixed the references so that stuff like SMC doesn't crash like crazy on you anymore.

The fixed Stored Procedures seem to be related with automatic content creation which could be related to a tool we don't have access to by Joymax. But some of them have to do with Stall Network (the ItemQuotation creation Stored Procedure is messed up by default, and I'm not 100% sure that my version will fix any ItemQuotation issues if any).

How to use this?

Open your SQL Management Studio, open a Query after selecting your SRO_VT_SHARD, and place the text in the attached file inside. Run the query with F5 and see how your Stored Procedures get reapplied with no errors.

How can I know if my Stored Procedures are screwed?

Do this if you do not want to run my queries with blindfold and want to know if your database has issues by yourself. Follow these steps to reproduce the way that I found that the SPs were screwed:
  1. Enter your SQL Management Studio.
  2. Right click on your SRO_VT_SHARD (or equivalent).
  3. Select Tasks/Generate Scripts.
  4. Click on 'Next' or 'Choose Objects' in the sidebar.
  5. Select 'Select specific database objects'.
  6. Mark the 'Stored Procedures' checkbox and hit Next.
  7. Click on 'Advanced' and change the 'Script DROP and CREATE' option to 'Script DROP and CREATE' instead of 'Script CREATE'.
  8. Click on 'Next' twice to generate the scripts with your Stored Procedures.
  9. Go to your 'Documents' and open 'script.sql' with Miscrosoft SQL Management Studio.
  10. Select SRO_VT_SHARD and run the query.
  11. Check any errors in the output to verify if your SPs are clean or not.
  12. Fix any errors and keep running the query until everything in your output is black.

Are my other databases good or not?

I just thought about checking the other databases, but I'm too lazy to do it right now. Might go ahead and do it later on, but anyone else is welcome to reproduce the steps above to check their other databases.

I recommend you to check your Stored Procedures manually if you are a capable developer, since I am not the smartest one out there. This could come with new bugs that nobody ever saw before, so take care with my releases jeje.
Attached Files
File Type: txt cleanSPs.txt (788.1 KB, 306 views)
*Silverlight* is offline  
Thanks
17 Users
Old 04/21/2019, 19:26   #2
 
Klito*'s Avatar
 
elite*gold: 0
Join Date: May 2018
Posts: 84
Received Thanks: 44
Nice, Potato!
Klito* is offline  
Thanks
1 User
Old 04/25/2019, 01:01   #3
 
elite*gold: 0
Join Date: Feb 2012
Posts: 551
Received Thanks: 46
that's amazing actually and will make the db more stable but you have 1 mistake in Proc "_InsertSiegeFortressStruct"
you changed the column name from GameConfig1 to WorldCodeName128 which is calling the name from table _RefSiegeFortress and in this case it won't be the same ever cuz they are different
the meant column here instead of GameConfig1 should be ConfigGroupCodeName128 but it will need a little change in its structure because they are not the same as well the return still will be 0
so i made it suitable for both proc and column values and it will be something like this

PHP Code:
USE SRO_VT_SHARD
GO
/****** Object:  StoredProcedure [dbo].[_InsertSiegeFortressStruct]    Script Date: 4/25/2019 12:58:22 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER PROCEDURE 
[dbo].[_InsertSiegeFortressStruct]
    @
FortressID        INT
AS
    DECLARE @
RefEventStructID    INT
    
DECLARE @StructCodeName        VARCHAR(129)
    DECLARE @
FortressName        VARCHAR(129)
    
    IF @
FortressID <= 0
    BEGIN
        
RETURN -1
    END

    SELECT 
@FortressName CodeName128 FROM _RefSiegeFortress WITH (NOLOCKWHERE FortressID = @FortressID

    
DECLARE FortressStructCursor CURSOR  FOR
    
SELECT [ID],strParam1  FROM _RefEventZone WITH (NOLOCKWHERE Service AND strParam2 = (
        
SELECT WorldCodeName128 FROM _RefGame_World WHERE ConfigGroupCodeName128 'GROUP_'+@FortressName
    
)

    
OPEN FortressStructCursor
    FETCH NEXT FROM FortressStructCursor INTO 
@RefEventStructID, @StructCodeName
    
WHILE (@@fetch_status 0)
    
BEGIN    
        
DECLARE @RefObjID       INT
        
DECLARE @Link    INT
        
        SET 
@RefObjID 0
        SET 
@Link 0

        SELECT 
@RefObjID = [ID], @Link Link FROM _RefObjCommon WITH (NOLOCKWHERE CodeName128 = @StructCodeName
        
IF @RefObjID <= 0
        BEGIN
            FETCH NEXT FROM FortressStructCursor INTO 
@RefEventStructID, @StructCodeName
            
CONTINUE
        
END

        
DECLARE @MaxHP   INT
        SELECT 
@MaxHP MaxHP FROM _RefObjChar WITH (NOLOCKWHERE [ID] = @Link
        
IF @MaxHP 0
        BEGIN
            FETCH NEXT FROM FortressStructCursor INTO 
@RefEventStructID, @StructCodeName
            
CONTINUE
        
END

        
IF NOT EXISTS (SELECT FROM _SiegeFortressStruct  WITH (NOLOCK)  WHERE RefEventStructID = @RefEventStructID)
        
BEGIN
            
-- ·¹ÆÛ·±½º Å×ÀÌºí¿¡¼Æ÷Æ®¸®½º ÀνºÅϽº¸¦ ¹Ì¸® ¸¸µç´Ù°ªÀº ¸ðµÎ default·Î ¼¼ÆÃ!
            
INSERT INTO [dbo]._SiegeFortressStruct VALUES ( @FortressID0, @RefEventStructID, @RefObjID, @MaxHPGetDate(), 0)
        
END

        FETCH NEXT FROM FortressStructCursor INTO 
@RefEventStructID, @StructCodeName
    END

    CLOSE FortressStructCursor
    DEALLOCATE FortressStructCursor    

    
RETURN 
thebigbody is offline  
Old 05/01/2019, 03:17   #4
 
elite*gold: 0
Join Date: Dec 2007
Posts: 71
Received Thanks: 5
Cannot resolve the collation conflict between "Korean_Wansung_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
anikan1985 is offline  
Old 05/01/2019, 05:06   #5
 
elite*gold: 0
Join Date: Jul 2014
Posts: 187
Received Thanks: 70
Quote:
Originally Posted by anikan1985 View Post
Cannot resolve the collation conflict between "Korean_Wansung_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.
Find on which line it happens, google on how to use COLLATE (or you can just try to randomly place it xD).

COLLATE DATABASE_DEFAULT
JohnDornel^ is offline  
Old 05/01/2019, 23:56   #6
 
elite*gold: 0
Join Date: Dec 2007
Posts: 71
Received Thanks: 5
well its not only 1 error :

anikan1985 is offline  
Old 05/03/2019, 12:47   #7

 
Dev.L0RdReVaN's Avatar
 
elite*gold: 355
Join Date: Mar 2009
Posts: 264
Received Thanks: 52
WOW
that's awesome
Dev.L0RdReVaN is offline  
Old 05/03/2019, 15:49   #8
 
elite*gold: 0
Join Date: Feb 2012
Posts: 551
Received Thanks: 46
Quote:
Originally Posted by anikan1985 View Post
well its not only 1 error :

it's all about ID column just make it auto in all of em
thebigbody is offline  
Old 08/20/2019, 22:17   #9
 
ScarOnline's Avatar
 
elite*gold: 0
Join Date: Mar 2018
Posts: 116
Received Thanks: 31
awesome release, thanks for sharing
ScarOnline is offline  
Reply


Similar Threads Similar Threads
DB Stored Procedures F1 F6
03/05/2018 - Dekaron Private Server - 0 Replies
#
[RELEASE]Stored Procedures from EP5 DB
01/31/2015 - Shaiya PServer Guides & Releases - 2 Replies
Hi, i just found out how to get stored procedures out of DB, so i decided to release them. I took them out for test purposes. It contains procedures from PS_ChatLog, Ps_GameData, PS_GameDefs, PS_GameLog, PS_GMTool, PS_StatData and PS_UserData. VirusTotal Here
Stored Procedures and Monsters
09/05/2013 - SRO Private Server - 0 Replies
So i was wundering if it was possible to spawn a mob / monster by using one of the Stored Procedures in the DB? It must be, as the GM commands use them right? Ive been looking at SP_InsertRefHive
[Wanted]Stored procedures
03/27/2012 - Shaiya Private Server - 5 Replies
Im in need of 3 stored procedures which iv got but theyve been messed about with so much that they are causing increasingly annoying problems usp_Try_GameLogin_Taiwan usp_Insert_Action_Log_E and usp_Try_GameLogout_R before anyone says use search i have tried multiple times to correct these and always same result works for a little while and then causes the Ps_game.exe to crash so would like a 2nd copy of them so i can compare and find what is causing this to happen



All times are GMT +1. The time now is 10:49.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.