묻고답하기

CREATE TRIGGER trg_mug_new2
ON char_data
For update
AS
update char_data
   set char_name = replace(i.char_name, '$C', '$B'), char_level=11, char_str=45, char_con=0, char_w1=0, char_w2=0, char_w3=0, char_w4=0, char_str_exp=0, char_con_exp=0, char_dex_exp=0, char_w1_exp=0, char_w2_exp=0, char_w3_exp=0, char_w4_exp=0, char_max_hit=(i.char_max_hit*0.6), char_hit=(i.char_hit*0.6), char_exp=0 , char_chk=2
   from char_data c inner join inserted i on i.char_serial = c.char_serial  
   where i.char_level>=1500 and (i.char_str+
             case when i.char_class=0 then i.char_w1
                  when i.char_class=1 then i.char_w2
                  when i.char_class=2 then i.char_w3
                  when i.char_class=3 then i.char_w4
                end
)>=5000 and i.char_chk = 1
--------------------------------------------------------
사용된 트리거는 이것이구요.. 이트리거를 실행시키기위해
업데이트를 해보면 아래그림처럼 오류가뜨네용..
--------------------------------------------------------


--------------------------------------------------------
그리구 char_data 테이블의 속성은 이렇습니다..
--------------------------------------------------------
CREATE TABLE [dbo].[Char_Data] (
        [Char_Serial] [int] IDENTITY (1, 1) NOT FOR REPLICATION  NOT NULL ,
        [Char_Account_Num] [int] NULL ,
        [Char_Name] [nvarchar] (12) COLLATE Korean_Wansung_CI_AS NULL ,
        [Char_Title] [varchar] (12) COLLATE Korean_Wansung_CI_AS NULL ,
        [Char_Level] [smallint] NULL ,
        [Char_Str] [smallint] NULL ,
        [Char_Dex] [smallint] NULL ,
        [Char_Con] [smallint] NULL ,
        [Char_W1] [smallint] NULL ,
        [Char_W2] [smallint] NULL ,
        [Char_W3] [smallint] NULL ,
        [Char_W4] [smallint] NULL ,
        [Char_Str_Exp] [int] NULL ,
        [Char_Dex_Exp] [int] NULL ,
        [Char_Con_Exp] [int] NULL ,
        [Char_W1_Exp] [int] NULL ,
        [Char_W2_Exp] [int] NULL ,
        [Char_W3_Exp] [int] NULL ,
        [Char_W4_Exp] [int] NULL ,
        [Char_Hit] [int] NULL ,
        [Char_Max_Hit] [int] NULL ,
        [Char_Mana] [int] NULL ,
        [Char_Max_Mana] [int] NULL ,
        [Char_Exp] [int] NULL ,
        [Char_Class] [tinyint] NULL ,
        [Char_Sex] [tinyint] NULL ,
        [Char_Agi] [tinyint] NULL ,
        [Char_Gold] [bigint] NULL ,
        [Char_Age] [int] NULL ,
        [Char_Last_Logon] [datetime] NULL ,
        [Char_X] [smallint] NULL ,
        [Char_Y] [smallint] NULL ,
        [Char_Zone] [tinyint] NULL ,
        [Char_Dir] [tinyint] NULL ,
        [Char_Admin_Level] [tinyint] NULL ,
        [Char_Flags] [int] NULL ,
        [Char_Grade] [smallint] NULL ,
        [Char_Ext] [int] NULL ,
        [Char_CHK] [int] NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Char_Data] ADD
        CONSTRAINT [DF_Char_Data_Char_Grade] DEFAULT (0) FOR [Char_Grade],
        CONSTRAINT [DF_Char_Data_Char_Ext] DEFAULT (0) FOR [Char_Ext],
        CONSTRAINT [DF_Char_Data_Char_CHK] DEFAULT (0) FOR [Char_CHK]
GO
------------------------------------------------------
결론을 말씀드리자면..트리거문에 for update 가아닌 instead of update 를 사용하면 잘작동하더라구요. 하지만 instead of update
를 사용하니 데이터값들이 증가하질않고 계속 원상복귀에요.
char_level을 예로들자면 트리거가작동해서 char_level = 11
이되고 또 업데이트이벤트가일어나면 char_level의 값이 증가하질않
는다는거죠. for update를 사용하면 저런오류가 뜨궁..휴.;;
혹시 replace 함수 때문인건가요.?
초보라 설명이 이상하네요..ㅠㅠ 해결책좀..부탁합니다.ㅠ
글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
이준한 MSSQL정확한 쿼리문인지좀봐주세욤. ^^ [1] 2007.08.10
초짜 접힘메뉴 소스입니다. 문제 좀 해결해주세여.  
이동환 <hr>로 선을 그은다음 왼쪽 정렬후 여백을 줄수 있나요? [5] 2007.08.10
최민석 MySQL에서 복구가 안됩니다. [1] 2007.08.10
zh i have a question~ [2] 2007.08.10
테이블 안에 게시판 나오게 하려면 어떻게 해야 되죠? [3] 2007.08.10
제리클 좀 어이없는 질문이지만 -_- 가상 pc에.... [1] 2007.08.10
someday html소스와 관련된 질문이요... [1] 2007.08.10
안대민 텍스트를 롤오버 시키고 싶어요. [1] 2007.08.10
최환웅 쉘로 텔넷 로그인 하는 방법좀..  
김지현 일러스트 파일 버전 질문입니다.. [1] 2007.08.10
흑풍회주 UTF-8 데이터를 php를 이용해서 mysql에 저장하는 방법?  
박재훈 링크를 표안으로... [1] 2007.08.10
다찌 한번클릭->두개 프레임 동시 이동소스가 안 됩니다[제발알려주세요!!]  
Aniori 메뉴 클릭하면 프레임 2곳이 바뀌게 하는법 질문~ (슬라이딩메뉴에서)  
바다와 괜찮은 ddns 서비스 좀 추천해주세요. [3] 2007.08.10
엄태웅 고수님들 도와주세요~~ ^^;;;;  
이한승 리사이즈 하는 방법 좀 알려 주세요.  
Game_I 테이블을 크기를 늘려도 중앙에 오게 하고 싶습니다 [2] 2007.08.10
無題 이런건 어떻게 링크 거나요? ;;;;  
슈바 [급해요] 테이블에서 고정된 양쪽 셀이 자꾸 늘어나요. [1] 2007.08.10
최환웅 마스쿼레이드를 하면 당나귀나 스타 사용 못하나요? [3] 2007.08.10
김은성 스크롤바에 관한 질문입니다  
이준한 mssql관련질문입니다. 도와주셔요 ㅠ  
김찬우 이미지에 특정한 부분을 클릭하면 다음 페이지로 넘어가게... [1] 2007.08.10
김현정 플래쉬 관련 질문인데요~ (사운드) [1] 2007.08.10
샬랄라 실명인증 서비스 사용하려고 하는데요, [3] 2007.08.10
박무환 로그인 페이지에서 쿠키 사용시 에러  
김명규 글쓰기 대이터값을 db에 입력할때 변수를 알고싶어요 [1] 2007.08.10
Aniori 버튼 하나누르면 프레임 두곳 바뀌게 하는법 질문 [1] 2007.08.10