회원가입

ALTER PROCEDURE [dbo].[RegMember]

            

             (

             @m_id varchar(50),

             @m_pw varchar(50),

             @m_name varchar(50)      ,

             @m_age int,

             @result int output

             )

            

   AS

   declare @state int ,@existed int

   set @state = 0

 

   Exec ExistID @m_id, @result output

  

     if @result = 0

                             begin

                                         insert into MemberInfo values(@m_id,@m_pw,@m_name,@m_age,@state)

                                         Exec NewMemberEachTable @m_id

                                         set @result = 1

                             end

     

    else

                                          begin 

                                                      set @result =0

                                          end

      

 RETURN

 

ID유효 확인

ALTER PROCEDURE dbo.ExistID

            

             (

                @m_id varchar(50),

                @result int output

             )

            

             AS

             if  Exists (select *from MemberInfo where m_id = @m_id)

                           begin

                                        set @result = 1

                           end 

             else

                           begin

                                        set @result =0

                           end

            

             RETURN

 

 

로그인

 

ALTER PROCEDURE dbo.LogMember

 

             (

             @m_id varchar(50),

             @m_pw varchar(50),

             @result int output

             )

AS

   declare @existed int

   declare @state int

   Exec AvailId @m_id, @m_pw, @existed output

             If @existed =  /*ID PW가일치안한다면*/

             begin

                           set @result = 0                

             end

             else     /*일치한다면*/

               begin

                   set @state = ( select  state  from MemberInfo where m_id=@m_id )          /*state를조사한다 */ 

                                          if @state =    /* 이미로그인중이라니라면상태를1로변환한다. */  

                                          begin

                                         set @result =    

                                         update MemberInfo set state=where m_id=@m_id    

                                         update FriendList set state =where m_id = @m_id                          

                                         /*state1로변환시켜준다. */  

                 end

                

               else 

                                        begin

                                                    set @result =  /*아이디를있지만이미로그인상태이다.*/

                                        end                                

             end

             RETURN

AvailId

아디가 유효한지 확인

ALTER PROCEDURE dbo.AvailId

             (

               @m_id varchar(50),

               @m_pw varchar(50),

               @result int output

             )

            

AS

 

             if Exists (select m_id from MemberInfo where m_id=@m_id and m_pw =@m_pw)

            

             begin 

               set @result = 1

   end

  

   else

     begin

        set @result = 0

   end

   RETURN

 

 

 

로그아웃

ALTER PROCEDURE dbo.LogOut

            

             (

             @m_id varchar(50),

             @result int OUTPUT

            

             )

            

AS

             set @result = 0

             Exec LogOutExist @m_id,@result output

            

             IF @result = 1

             BEGIN

                           update MemberInfo set state = where m_id = @m_id

                           update FriendList set state =where m_id = @m_id                           

             END

            

             RETURN

 

로그아웃 유효검사

ALTER PROCEDURE dbo.LogOutExist

            

             (

             @m_id varchar(50),

             @result int OUTPUT

 

             )

 

AS

             Declare @buf varchar(50)

             set @buf = (select m_id from MemberInfo where m_id = @m_id)

             set @result = 0

 

             IF @buf is not null

             BEGIN

             set @result = 1

             END

 

 

             RETURN

 

 

시청한 비디오추가

ALTER PROCEDURE dbo.AddVideo

             (

             @m_id varchar(50),

             @m_videoname varchar(50),

             @result int output

             )

AS

    declare @strSql nvarchar(1000)

    declare @sql nvarchar(1000)

    declare @param nvarchar(1000)

              Exec ExistID @m_id, @result output

             if @result = 1

                           begin 

                           exec ExistVideoName @m_id,@m_videoname,@result output

                           end

             else

                           begin

                           set @result = 0

                           end

            

              set @sql = @m_id+'_wordInfo'

              if @result = 1

                             begin

                                                      SET @strSql = 'INSERT INTO ' + @m_id + '_videoInfo 

                           VALUES(@p_id, @p_videoname)'

 

 

                                                     SET @param = '@p_id varchar(50), 

                           @p_videoname varchar(50)' 

 

                                                     EXECUTE sp_executesql @strSql, @param, 

                                                      @p_id  = @m_id,

                                                      @p_videoname  = @m_videoname                                                 

            

             if NOT EXISTS (SELECT  name FROM sys.sysobjects WHERE  name = @sql AND (type = 'U'))

                                         begin

                                                     set @result =1

                                                                  Exec NewMemberEachWordTable @m_id

                                                     RETURN

                                         end                                            

                                         

                             end

     

    else

                                          begin 

                                                      set @result =1

                                          end

      

            

 

            

            

             RETURN

 

영상이름 유효검사

ALTER PROCEDURE dbo.ExistVideoName

             (

                @m_id varchar(50),

                @m_videoname varchar(50),

                @result int output

             )

AS

             declare @strSql nvarchar(1000)

             declare @params nvarchar(100)

             declare @cnt int

            

             SET @strSql = 'SELECT @p_value = count(m_videoname) from ' + @m_id +'_videoInfo

                                                                                             WHERE m_id = @p_id AND m_videoname =@p_videoname'

 

             SET @params = '@p_id  varchar(50),

                                                                                                          @p_videoname varchar(50),            

                                                                                             @p_value as int OUTPUT '

 

 

 

             EXEC sp_executesql @strSql, @params,

                                           @p_value  = @result OUTPUT,

                                           @p_id = @m_id,

                                           @p_videoname = @m_videoname

            

            

            

                           if @result = 0

                                        begin

                                                     set @result =1

                                        end

                          

                           else

                                        begin

                                                     set @result = 0

                                        end

                          

                           RETURN

                          

 

 

시청한 비디오에 단어 추가

ALTER PROCEDURE dbo.AddWord

             (

             @m_id varchar(50),

             @m_videoname varchar(50),

             @m_word varchar(50),

             @m_mean varchar(50),

             @result int output

             )

AS

             exec ExistVideoName @m_id,@m_videoname,@result output

             declare @strSql nvarchar(1000)

    declare @sql nvarchar(1000)

    declare @param nvarchar(1000)

   

             if @result = 0

                           begin

                                        SET @strSql = 'INSERT INTO ' + @m_id + '_wordInfo 

                           VALUES(@p_id,@p_videoname,@p_word,@p_mean)'

 

 

                                                     SET @param = '@p_id varchar(50), 

                           @p_videoname varchar(50),

                                                                                             @p_word varchar(50),

                                                                                             @p_mean varchar(50)' 

 

                                                     EXECUTE sp_executesql @strSql, @param, 

                                                      @p_id  = @m_id,

                                                      @p_videoname  = @m_videoname,

                                                      @p_word = @m_word,

                                                      @p_mean = @m_mean 

               SET @result = 1

                           end

             else

                           begin

                                        SET @result = 0

                           end

             RETURN


'Programing > 오라클&SQL' 카테고리의 다른 글

저장프로시져  (0) 2016.11.30
오라클 ODBC 연결 프로그램  (0) 2016.11.30
Oracle ODBC 설치 및 연결  (0) 2016.11.30

로그인

 

ALTER PROCEDURE dbo.LogMember

 

             (

             @m_id varchar(50),

             @m_pw varchar(50),

             @result int output

             )

AS

   declare @existed int

   declare @state int

   Exec AvailId @m_id, @m_pw, @existed output

             If @existed =  /*ID PW가일치안한다면*/

             begin

                           set @result = 0               

             end

             else     /*일치한다면*/

               begin

                   set @state = ( select  state  from MemberInfo where m_id=@m_id )       /*state를조사한다 */  

                                          if @state =    /* 이미로그인중이라니라면상태를1로변환한다. */  

                                          begin

                                         set @result =    

                                         update MemberInfo set state=where m_id=@m_id    

                                         update FriendList set state =where m_id = @m_id                                     

                                         /*state1로변환시켜준다. */  

                 end

                

               else 

                                        begin

                                                    set @result =  /*아이디를있지만이미로그인상태이다.*/

                                        end                                

             end

             RETURN

 

 

 

AvailId

아디가 유효한지 확인

ALTER PROCEDURE dbo.AvailId

             (

               @m_id varchar(50),

               @m_pw varchar(50),

               @result int output

             )

            

AS

 

             if Exists (select m_id from MemberInfo where m_id=@m_id and m_pw =@m_pw)

            

             begin 

               set @result = 1

   end

  

   else

     begin

        set @result = 0

   end

   RETURN

 

 

 

시청 동영상 목록 요청

 

ALTER PROCEDURE dbo.ListVideo

(

@m_id varchar(50),

@count int output

)

AS

             declare @sql nvarchar(1000)

             set @count = 0

             Exec GetVideoListCount @m_id,@count output

            

             if @count !=0

                          begin    

                           set @sql = 'select m_videoname from '+@m_id+'_videoInfo'

                           exec (@sql)

                          

                           end       

             else

                           begin

                           set @count = 0

                           end                    

             RETURN

 

해당 ID의 시청한 동영상의 개수

ALTER PROCEDURE dbo.GetVideoListCount

             (

             @m_id varchar(50),

             @count int output           

             )

AS

             declare @sql nvarchar(1000)

             declare @p nvarchar(100)

             declare @cnt int

            

             set @sql = 'select @cnt = count(m_videoname) FROM '+@m_id+'_videoInfo' 

             set @p = '@cnt int output'

            

             exec sp_executesql @sql,@p, @cnt=@count output

 

            

             RETURN

 

 

시청 동영상별 저장 단어와 뜻 요청

ALTER PROCEDURE dbo.ListWord

(

@m_id varchar(50),

@m_videoname varchar(50),

@count int output

)

AS

             declare @sql nvarchar(1000)

             declare @param nvarchar(1000)

             set @count = 0

             Exec GetWordListCount @m_id,@m_videoname,@count output

            

             if @count !=0

                           begin                               

                                                     

                           set @sql = 'select m_word,m_mean from '+@m_id+'_wordInfo where m_videoname =@p_videoname'     

                           set @param = '@p_videoname varchar(50)'

                                       

                                        execute sp_executesql @sql,@param,

                                                                                                                                                                 @p_videoname = @m_videoname                         

                          

                           end       

             else

                           begin

                           set @count = 0

                           end                    

             RETURN

 

영상의 단어 개수 확인

ALTER PROCEDURE dbo.GetWordListCount

             (

             @m_id varchar(50),

             @m_videoname varchar(50),

             @count int output           

             )

AS

             declare @sql nvarchar(1000)

             declare @p nvarchar(100)

             declare @cnt int

            

             set @sql = 'select @cnt = count(m_word) FROM '+@m_id+'_wordInfo where m_videoname = @p_videoname'    

             set @p = '@cnt int output,

                                                                  @p_videoname varchar(50)'

            

             exec sp_executesql @sql,@p, 

                                                                                             @p_videoname = @m_videoname,

                                                                                             @cnt=@count output

 

            

             RETURN

'Programing > 오라클&SQL' 카테고리의 다른 글

저장프로시져  (0) 2016.11.30
오라클 ODBC 연결 프로그램  (0) 2016.11.30
Oracle ODBC 설치 및 연결  (0) 2016.11.30

ODBC 연결로 오라클에잇는 정보 추가 삭제 변경 가능하게 연습예제를 만들어 보았다.

오라오라오라클.zip


'Programing > 오라클&SQL' 카테고리의 다른 글

저장프로시져  (0) 2016.11.30
저장프로시져  (0) 2016.11.30
Oracle ODBC 설치 및 연결  (0) 2016.11.30


1. Oracle.com에서 접속용 기본 프로그램 및 ODBC를 다운 받음.

다운받는 위치:

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html

 

금일현재 Version 11.1.0.7.0가 최신버젼

 

가장 기본적인 프로그램 (무조건 받을 것.)

instantclient-basic-win32-11.1.0.7.0.zip (46,734,555 bytes)

 

가장 기본적인 프로그램 (경량버전)

instantclient-basiclite-win32-11.1.0.7.0.zip (17,667,999 bytes)

 

JDBC 클라이언트 패키지

instantclient-jdbc-win32-11.1.0.7.0.zip (1,562,261 bytes)

 

SQL*Plus 패키지

instantclient-sqlplus-win32-11.1.0.7.0.zip (789,617 bytes)

 

개발자 관련 SDK 패키지

instantclient-sdk-win32-11.1.0.7.0.zip (1,068,348 bytes)

 

개별접속용 ODBC 패키지 - 내가 필요한 기능

instantclient-odbc-win32-11.1.0.7.0.zip (728,899 bytes)

 

WRC 패키지

instantclient-tools-win32-11.1.0.7.0.zip (6,009 bytes)

 

 

 

내가 필요한 것은 기본 프로그램과 ODBC용 패키지로 2개를 다운받아 아래 디렉토리에 압축을 해제함

 

d:\oracle\instentclient_11_1   (요걸 잘 기억 해 주시고...)

 

2. 환경변수 지정

 

시작-> 내컴퓨터 -> 속성




고급 -> 환경변수 





시스템 변수 새로 만들기



시스템 변수 생성



ORACLE_HOME=d:\Oracle\instantclient_11_1

TNS_ADMIN=d:\Oracle\instantclient_11_1 <- tnsnames.ora 파일이 위치할 폴더

NLS_LANG=KOREAN_KOREA.KO16MSWIN949   <- 한글관련 설정

PATH=d:\Oracle\instantclient_11_1 <- 기존 패스에 추가해야 함

 

Path만 기존 변수명에 추가하고 나머지는 새로이 생성

 

 

3. 레지스트리 변경

1) 드라이브 설치했다고 변경 (아래 표내의 글을 복사해서 drive.reg 파일로 저장해서 더블클릭 해도 됨)

 Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]
"Oracle in InstantClient_11_1"="Installed"

 

2) Oracle in InstantClient_11_1 세부내역 추가 (아래글을 복사해서 dddd.reg 파일로 저장해 더블클릭 해도 됨)

 Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Oracle in InstantClient_11_1]
"APILevel"="1"
"CPTimeout"="60"
"ConnectFunctions"="YYY"
"Driver"="d:\\Oracle\\instantclient_11_1\\SQORA32.DLL"
"DriverODBCVer"="03.51"
"FileUsage"="0"
"Setup"="d:\\Oracle\\instantclient_11_1\\SQORAS32.DLL"
"SQLLevel"="1"

 

3. TNS 서비스 파일 등록

아래 내용을 tnsnames.ora 파일을 작성하여 d:\Oracle\instantclient_11_1 디렉토리에 저장

 

 oracleTest1 =

(DESCRIPTION =
     (ADDRESS_LIST =
          (ADDRESS = 
               (PROTOCOL = TCP)
                    (HOST = xxx.xxx.xxx.xxx)
                    (PORT = 1521)
                )
          )
     (CONNECT_DATA =
          (SERVICE_NAME = DB_NAME)
     )

)

 

oracleTest1 : 사용할 TNS 서비스명으로 임의로 자기가 설정

xxx.xxx.xxx.xxx : oracle이 설치된 서버 IP 주소

1521: 포트번호

DB_NAME : 접속할 DB명

 

 

여기까지 진행이 되었으면 컴퓨터를 재부팅 함... (환경변수 등이 반영되도록...)

 

 

4. ODBC 데이터 원본 관리자 실행

시작-> 제어판-> 데이터 원본 (ODBC) - 추가



드라이버를 선택 - 하단 그림은 Oracle in OraClient10g로 되어 있으나 위에 레지스트리를 정상적으로 적용했다면 Oracle in InstantClient_11_1로 나옴...



드라이버 정보 입력 - TNS Service Name이 중요함




비밀번호를 입력하고....





접속 성공...


'Programing > 오라클&SQL' 카테고리의 다른 글

저장프로시져  (0) 2016.11.30
저장프로시져  (0) 2016.11.30
오라클 ODBC 연결 프로그램  (0) 2016.11.30

+ Recent posts