Q&A

  • 당황스런 SQL에러네여 조언좀부탁드립니다.
에러메세지는,

Unable to create constraint. See previous errors.

제약에관한 에러인거 같은데 create table로 임시테이블을 만들때 발생합니다.

같은 환경의 다른 DB에서는 에러가 안나는데 새로바꾸는 DB에서만 에러가 납니다. 검색해보아도 이런에러는 없더군요.

환경은 MSSQL 6.5입니다.

아래는 전체 SQL문입니다.
---------------------------------------------------------------------
declare @sf_no                numeric(10)                                            
       ,@j_sno                numeric(07)                                            
       ,@c_sno                numeric(07)                                            
       ,@io_date        smalldatetime                                          
       ,@io_qty        numeric(14,2)                                          
                                                                              
       ,@row_cnt        numeric(03)   -- 변경날짜 갯수                        
       ,@old_sf_no      numeric(10)   -- 이 세개의 변수는                    
       ,@old_c_sno      numeric(10)   -- 전과 변경량이 같                    
       ,@old_qty        numeric(10,2) -- 으면 기록 no                        
                                                                              
       ,@temp_date      smalldatetime  -- 커서내에 쓰는 변수                  
       ,@io_date1       smalldatetime  -- 변경날짜                            
       ,@io_date2       smalldatetime                                        
       ,@io_date3       smalldatetime                                        
       ,@io_date4       smalldatetime                                        
       ,@io_date5       smalldatetime                                        
       ,@io_date6       smalldatetime                                        
       ,@io_date7       smalldatetime                                        
       ,@io_date8       smalldatetime                                        
       ,@io_date9       smalldatetime                                        
       ,@io_date10      smalldatetime                                        
                                                                              
       ,@firstdate      smalldatetime                                        
       ,@io_Fdate       smalldatetime                                        
       ,@io_Tdate       smalldatetime                                        
                                                                              
       ,@year   numeric(4)                                                    
       ,@month  numeric(2)                                                    
       ,@sa_sno numeric(7)                                                    
       ,@Fsf_no numeric(10)                                                  
       ,@Tsf_no numeric(10)                                                  
                                                                              
   select @io_Fdate = '2003-04-01'                                              
   select @io_Tdate = '2003-04-30'                                              
   select @year     = 2003                                                  
   select @month    = 5                                                  
   select @sa_sno   = 1                                                
   select @Fsf_no   = 2003050000                                                
   select @Tsf_no   = 2003059999                                                
                                                                              
                                                                              
   select @firstdate =(select convert(smalldatetime,                          
                       convert(char(4),@year)+"-"+                            
                       convert(char(2),@month)+"-01"))                        
   /*** 변경날짜 구함 ***/                                                    
   declare CUR_DATE insensitive cursor for                                    
                      select distinct HH.IO_DATE                              
                        from JJ_SALES_PLAN          PP                        
                            ,JJ_SALES_PLAN_QTY_HIST HH                        
                       where PP.SA_SNO  = @sa_sno                            
                         and PP.SP_YY   = @year                              
                         and PP.SP_MM   = @month                              
                         and PP.SF_NO   BETWEEN @Fsf_no AND @Tsf_no          
                         and PP.SP_SNO  = HH.SP_SNO                          
                                                                              
   select @row_cnt = 0                                                        
   /*** 자료 fetch ***/                                                      
   open CUR_DATE                                                              
   while (@@cursor_rows <> 0) begin                                          
      fetch next from CUR_DATE into @temp_date                                
                                                                              
      if @@fetch_status = -1 break                                            
      if @@fetch_status = -2 continue                                        
                                                                              
      select @row_cnt = @row_cnt + 1                                          
                                                                              
      if @row_cnt > 10                                                        
        select @row_cnt = 10                                                  
                                                                              
      if @row_cnt = 1                                                        
         select @io_date1 = @temp_date                                        
      if @row_cnt = 2                                                        
         select @io_date2 = @temp_date                                        
      if @row_cnt = 3                                                        
         select @io_date3 = @temp_date                                        
      if @row_cnt = 4                                                        
         select @io_date4 = @temp_date                                        
      if @row_cnt = 5                                                        
         select @io_date5 = @temp_date                                        
      if @row_cnt = 6                                                        
         select @io_date6  = @temp_date                                      
      if @row_cnt = 7                                                        
         select @io_date7  = @temp_date                                      
      if @row_cnt = 8                                                        
         select @io_date8  = @temp_date                                      
      if @row_cnt = 9                                                        
         select @io_date9  = @temp_date                                      
      if @row_cnt = 10                                                        
         select @io_date10 = @temp_date                                      
   end -- while                                                              
   close CUR_DATE                                                            
   deallocate CUR_DATE                                                        
                                                                              
   /*** 임시 테이블 생성 ***/                                                
   create table #TP_TABLE                                                    
   (            SF_NO          numeric(10)                                    
               ,J_SNO          numeric(07)                                    
               ,C_SNO          numeric(07)                                    
               ,IO_QTY1        numeric(10,2)   NULL default 0                
               ,IO_QTY2        numeric(10,2)   NULL default 0                
               ,IO_QTY3        numeric(10,2)   NULL default 0                
               ,IO_QTY4        numeric(10,2)   NULL default 0                
               ,IO_QTY5        numeric(10,2)   NULL default 0                
               ,IO_QTY6        numeric(10,2)   NULL default 0                
               ,IO_QTY7        numeric(10,2)   NULL default 0                
               ,IO_QTY8        numeric(10,2)   NULL default 0                
               ,IO_QTY9        numeric(10,2)   NULL default 0                
               ,IO_QTY10       numeric(10,2)   NULL default 0                
   )                                                                          
                                                                              
  SELECT SP.SP_SNO,SP.SF_NO,SP.J_SNO,SP.C_SNO                                
        ,(SP.IO_QTY_INPUT + SP.IO_QTY_TRANS - SP.NY_QTY)  AS QTY              
    INTO #T                                                                  
    FROM JJ_SALES_PLAN      SP                                                
   WHERE SP.SA_SNO = @sa_sno                                                  
     AND SP.SP_YY  = @year                                                    
     AND SP.SP_MM  = @month                                                  
     AND SP.SF_NO  BETWEEN @Fsf_no AND @Tsf_no                                
     AND SP.SP_SNO IN(SELECT SP_SNO FROM JJ_SALES_PLAN_HIST                  
                       WHERE IO_DATE BETWEEN @io_Fdate AND @io_Tdate          
                         AND SP_FIRST IN(1,2)                                
                     )                                                        
                                                                              
   declare CUR_DATA_SA insensitive cursor for                                
                      select PP.SF_NO, PP.J_SNO, PP.C_SNO                    
                            ,HH.IO_DATE                                      
                            ,PP.QTY+HH.TOT_QTY_GA                            
                        from #T                     PP                        
                            ,JJ_SALES_PLAN_QTY_HIST HH                        
                       where PP.SP_SNO = HH.SP_SNO                            
                      order by PP.SF_NO, PP.C_SNO, HH.IO_DATE                
                                                                              
   select @old_sf_no = 0                                                      
   select @old_c_sno = 0                                                      
   select @old_qty   = 0                                                      
                                                                              
   /*** 자료 fetch ***/                                                      
   open CUR_DATA_SA                                                          
   while (@@cursor_rows <> 0) begin                                          
      fetch next from CUR_DATA_SA                                            
                 into @sf_no ,@j_sno ,@c_sno ,@io_date ,@io_qty              
      if @@fetch_status = -1 break                                            
      if @@fetch_status = -2 continue                                        
                                                                              
      if (@sf_no <> @old_sf_no) or (@c_sno <> @old_c_sno)                    
      begin                                                                  
        select @old_sf_no = @sf_no                                            
        select @old_c_sno = @c_sno                                            
        select @old_qty = 0                                                  
      end                                                                    
                                                                              
      if not exists (select SF_NO from #TP_TABLE                              
                      where SF_NO = @sf_no                                    
                        and J_SNO = @j_sno                                    
                        and C_SNO = @c_sno)                                  
         insert into #TP_TABLE (SF_NO,J_SNO,C_SNO)                            
                        values (@sf_no ,@j_sno ,@c_sno)                      
                                                                              
      if (@io_date1 = @io_date) and (@io_qty <> @old_qty)                    
         update #TP_TABLE                                                    
            set IO_QTY1  = @io_qty                                            
          where SF_NO = @sf_no                                                
            and J_SNO = @j_sno                                                
            and C_SNO = @c_sno                                                
      if (@io_date2 = @io_date) and (@io_qty <> @old_qty)                    
         update #TP_TABLE                                                    
            set IO_QTY2  = @io_qty                                            
          where SF_NO = @sf_no                                                
            and J_SNO = @j_sno                                                
            and C_SNO = @c_sno                                                
      if (@io_date3 = @io_date) and (@io_qty <> @old_qty)                    
         update #TP_TABLE                                                    
            set IO_QTY3  = @io_qty                                            
          where SF_NO = @sf_no                                                
            and J_SNO = @j_sno                                                
            and C_SNO = @c_sno                                                
      if (@io_date4 = @io_date) and (@io_qty <> @old_qty)                    
         update #TP_TABLE                                                    
            set IO_QTY4  = @io_qty                                            
          where SF_NO = @sf_no                                                
            and J_SNO = @j_sno                                                
            and C_SNO = @c_sno                                                
      if (@io_date5 = @io_date) and (@io_qty <> @old_qty)                    
         update #TP_TABLE                                                    
     &nb
0  COMMENTS
    • KDDG_ZZOM
      2003.05.15 00:15
      pk가 뭔지? 글구 데이타 베이스가 뭔가요? 조인을 거시면 될것같네요... 한번의 쿼리로 tmp1 tmp2의 ...
    • 홍길동
      2003.05.15 00:24
      답변 감사합니다.. 디비는 Access 쓰구요.. 모두 해 보았는데 잘 되지 않내요.. Select a, Coun...
    • KDDG_ZZOM
      2003.05.15 01:12
      ^^ 지금 오라클에서 테스트했는데.. 잘되는데... select a, sum(cnt)   from (select a, coun...
    • 홍길동
      2003.05.15 01:27
      감사합니다.. 해결 되었내요.. select a, sum(cnt)  from 이후에 부분에 대해서는 제가 몰랐...
    • (__+)
    • 2003.05.14 23:32
    • 5 COMMENTS
    • /
    • 0 LIKES
    • 김경록
      2003.05.15 07:04
      먼저, 메모는 받으셨는지.. 저번 메모에 대한 답변이었는데.. 동영상으로 제작해서 보내드릴려고 했는데.....
    • KDDG_ZZOM
      2003.05.15 00:01
      테이블의 형은 스트링이고 조건으로 들어가는 temp1,2가 데이트형아닌가요? 그냥 Temp1,Temp2를 스트링으...
    • (__+)
      2003.05.15 00:52
      TEMP1,2 모두 스트링이랍니다. 다시 한번만 봐 주세여~ㅡㅜ
    • KDDG_ZZOM
      2003.05.15 01:17
      저장될때는 20030514이런식으로 저장을 하면서 Temp1 := FormatDateTime('MM-DD-YYYY',DateEdit1.date); ...
    • (__+)
      2003.05.15 01:29
      이건 그냥 제가 이해하기 편하려고 저장하는거구여.... 이건..MDB는 이런식으로 값을 주고 조회하니...
    • 전계진
    • 2003.05.14 21:53
    • 4 COMMENTS
    • /
    • 0 LIKES
    • 데빌카마라
      2003.05.15 00:46
      안녕하세요... 저도 초보이지만 제가 아는 것을 가려켜 드리겠습니다. 다음은 예제인거든요 다음을 보면...
    • 전계진
      2003.05.15 19:10
      안녕하세요 감사 합니다.. 그런데 제가 아직 초보라서 test를 했는데 button1Click(sender); 에...
    • 데빌카마라
      2003.05.16 00:10
      안냥하세요 button1Click(sender); 이 무엇을 뜻하냐하면요 procedure의 button1Click으로 보낸...
    • 전계진
      2003.05.20 01:40
      감사합니다.
    • 박희경
    • 2003.05.14 21:35
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 바다를향해
      2003.05.14 22:56
      Tools->Environment Options->Preferences->AutoSave Options 에 보시면요. Project Desktop이 ...
    • yosule
      2003.05.14 21:55
      참 황당한 일이군요. 제 경우가 답이 될 지 모르겠군요. b 프로젝트를 열어서 프로젝트 매니저를 한 ...
    • 김병곤
      2003.05.15 03:40
      물론 가능합니다. 하지만 인디의 텔넷 콤포넌트를 이용하시는게 좋을겁니다. 꼭 소켓 프로그램으로 구현...
    • 버섯
    • 2003.05.14 21:33
    • 0 COMMENTS
    • /
    • 0 LIKES
    • 정용광
      2003.05.14 21:12
      아주 간단하죠..     Application.HelpFile := GetExePath+'파일명.hlp';  &...
    • 마당쇠(오정민)
      2003.05.14 21:18
      감사합니다. 많은 도움이 되었습니다.
    • 최남선
      2003.05.14 20:39
      참고로 첨부해주신 화면을 편집해서 해보니 동일하게 나오는데... 탈색은 대부분 색상수가 변환되었을때 ...
    • 맑은물
      2003.05.14 23:47
      자꾸 귀찮게 해 죄송합니다. 파일 첨부합니다. 그리고 혹시 jpg형식의 파일을 bmp형식으로 변경할 수...
    • 최남선
      2003.05.15 03:03
      역시 이상하네영...첨부해주신 이미지가 같아보이니... 아무래두 더이상은 도움드릴만한 실력이 안되는거 ...
    • 유창원
    • 2003.05.14 19:57
    • 1 COMMENTS
    • /
    • 0 LIKES
    • yosule
      2003.05.14 21:10
      정확한 답변이 될 지 모르겠군요. TJPEGImage가 계속 메모리에 쌓이는 것 같군요. 즉 정확히 메모리...
    • sky
    • 2003.05.14 19:33
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 별볼일없는
      2003.05.14 21:18
      컴퍼넌트를 찾으시는건지.. 암튼 numedit 소스도 있으니깐 받아보세요 ^^~
    • yosule
      2003.05.14 21:14
      받아가세요...
    • 하얀까마귀
      2003.05.14 14:19
      안녕하세요 하얀까마귀입니다. 퀵리포트와 챠트는 볼랜드에서 만든게 아니라 다른회사에서 제공해주는걸...
    • 정성훈
    • 2003.05.14 06:27
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 김병곤
      2003.05.14 18:39
      델파이로 가능합니까? 란 질문은 이제 좀 그만 봤으면 하는 소망이 있네요. 윈도우 프로그래밍을 하면서 ...
    • 정성훈
      2003.05.14 21:10
      죄송합니다..  제가 델파이를 잘 몰라서요...^^;; 혹시 어떤기술이 사용되었는지 알수 있을까요...
    • Formas
    • 2003.05.14 06:12
    • 0 COMMENTS
    • /
    • 0 LIKES
    • (__+)
    • 2003.05.14 05:56
    • 3 COMMENTS
    • /
    • 0 LIKES
    • 윤신호
      2003.05.14 07:38
      ADO 컴퍼넌트를 사용하시면 됩니다. Database컴퍼넌트대시넹 ADOConnection을 TQuery대신에 ADOQuery를 ...
    • (__+)
      2003.05.14 18:57
      님 답변 감사합니다..^0^)/ 근데여...제가 ADO 컴포넌트를 한 번도 사용 안해봐서 그런데.. ADOConne...
    • 김경록
      2003.05.14 20:30
      제가 올린것두 있구여.. (ADO, Database컴포넌트 모두 사용해서 비교 해 놓았음) 다른 님이 올린것두 ...
    • 대롱이
    • 2003.05.14 04:06
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 나옹이
      2003.05.14 04:43
      자료실에 가면 DelZip 이라는 컴포넌트가 있을거여요 예전에 그걸 가지구 작업을 한적이 있었는뎅, ...
    • 대롱이
      2003.05.26 21:42
      감사합니다.
    • 맑은물
    • 2003.05.14 02:25
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 최남선
      2003.05.14 19:19
      Timagelist 컴포넌트의 편집창입니다. 첨부된 그림에서 보면 Transparent Color가 있습니다. clNone으로 ...
    • YoungMan
    • 2003.05.14 02:16
    • 0 COMMENTS
    • /
    • 0 LIKES
    • 최현수
    • 2003.05.14 01:59
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 최남선
      2003.05.14 20:10
      메소드나 프로퍼티는 찾아봐도 없네요. 캔버스는 스크롤된 경우 문제가 있고... 님이 필요로 하시는게 조...
    • 김정은
    • 2003.05.14 01:41
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 한원희
      2003.05.14 01:48
      안녕하세요. 한원희입니다. 일반 버튼, 비트 버튼은 TWinControl에서 상속 받아서 포커스를 받습니다. ...
    • 김정은
      2003.05.14 03:28
      좋은하루 되시고.. 열심히 일해서 돈많이 벌어서 좋은일 많이 하고 .... 항상 행복하세요~~~ 평안!