database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
ㆍOracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
Oracle Q&A 18608 게시물 읽기
No. 18608
MS-SQL과 Oracle의 연동 관련
작성자
사람
작성일
2004-05-24 10:43
조회수
13,326

MS-SQL이랑 Oracle로 이것 저것 해보다가 질문이 몇가지 생겨서 써봅니다.
당연히 둘을 연동하는 얘기인데

일단 Oracle에서 MS-SQL을 보려면 GateWay라는 게 필요하다는건 알았는데 어떻게 설치해서
어떻게 사용하는건지 자료를 찾기가 힘들더군요...^^;;;
설명을 해주실 수 있으면 좋고 관련 자료가 있으면 알려주시면 감사하겠습니다.

그래서 MS-SQL에서 Oracle로 연결된 서버를 이용해서 이것 저것 해보았습니다.

우선 MSDAORA 로 연결해서 질의를 만들어 보았습니다.

select * from oracle1..test.testtable
insert into oracle1..test.testtable values(1, 'test')

같은 질의 들이 잘 되더군요.
그런데 문제는 begin tran, rollback, commit 등을 사용하여 만든 질의에 대해서는

서버: 메시지 7391, 수준 16, 상태 1, 줄 3
OLE/DB 공급자 'MSDAORA'이(가) 분산 트랜잭션을 시작할 수 없으므로 작업을 수행할 수 없습니다.
OLE DB 오류 추적 [OLE/DB Provider 'MSDAORA' ITransactionJoin::JoinTransaction returned 0x8004d01b].

라는 메시지가 나왔습니다. 분산 트랜잭션이 안된다는 걸 보면
Oracle에서 MSDTC인가 하는 것과 비슷한 것이 있어서
그걸 설치 해야 한다거나 아니면 MSDAORA로는 분산 트랜잭션이 안된다거나 하는 걸꺼라고
추측하고 있는데 어떤 것인지 모르겠군요.
그런게 아니면 분산 트랜잭션을 수행하려면 어떻게 해야 하는지 알려 주시면 감사하겠습니다.

다음으로 OraOLEDB.Oracle로 연결된 서버를 만들어서 질의를 해보았습니다.

위와 같인 그냥 select를 수행해보았는데

서버: 메시지 7356, 수준 16, 상태 1, 줄 1
OLE DB 공급자 'OraOLEDB.Oracle.1'이(가) 열에 대해 일관성 없는 메타데이터를 제공했습니다. 런타임 시 메타데이
터 정보가 변경되었습니다.
OLE DB 오류 추적 [Non-interface error: Column 'NAME' (compile-time ordinal 2) of object test.testtable' was
reported to have a DBTYPE of 129 at compile time and 130 at run time].

같은 메시지가 출력되었습니다.

그래서

select * from openquery(oracle, 'select * from "TEST"."TABLE"')

와 같이 질의를 던졌더니.

서버: 메시지 7320, 수준 16, 상태 2, 줄 1
OLE DB 공급자 'OraOLEDB.Oracle.1'에 대해 쿼리를 실행할 수 없습니다.
OLE DB 오류 추적 [OLE/DB Provider 'OraOLEDB.Oracle.1' ICommandText::Execute returned 0x80040155].

라는 메시지가 나오는 군요.

insert, transaction은 어떻게 해야 하는지도 몰라서 해보지도 못했구염..;;;

프로바이더가 이상하게 설치 되었거나 하지는 않았을거 같은게
C++에서
dbSource.Open(_T("OraOLEDB.Oracle.1"), _T("svr"), _T("id"), _T("pass"));
같은 식으로 접속해서 위의 select를 하니 잘 되는군요...;;;

그래서 이것 저것 적었는데 알고 싶은 걸 정리하면

gateway의 설치 방법 및 사용법
ms-sql의 연결된 서버 MSDAORA 사용시 분산 트랜잭션 사용법
ms-sql의 연결된 서버 OraOLEDB.Oracle.1 사용시 질의 방법 및 분산 트랜잭션 사용법

정도 되겠습니다.

즐거운 하루 되세요

이 글에 대한 댓글이 총 3건 있습니다.

ODBC를 이용한 방법을 해보세요.

 

PURPOSE
-------
 
This article documents setting up and troubleshooting Heterogeneous Services, 
also referred to as "Generic Connectivity", to Microsoft SQL Server 
using ODBC on Windows NT.
 
 
SCOPE & APPLICATION
-------------------
 
This bulletin describes a setup of Oracle 8.1.6 running on Windows
NT 4.0 to access a MS SQL Server database using the Microsoft Data 
Access Components (MDAC)SDK ODBC driver.
 
The bulletin assumes the Microsoft SQL Server system is already established on
a Windows NT Network.
 
-------------------------------------------------------------------
1) Install the Microsoft Data Access Components (MDAC)SDK ODBC driver. This can 
   be downloaded from http://www.microsoft.com/data
 
2) Install the Oracle Server. 
  
   A "Typical Installation" will include "Generic Connectivity using ODBC".
   If performing a "Custom Installation", do not omit this component.
   Directory "ORACLE_HOME/HS" is created during the installation which includes
   sample files.
     
3) Ensure CATHS has been run. 
   
   Oracle Generic Connectivity feature requires the data dictionary objects 
   created by script "ORACLE_HOME\RDBMS\ADMIN\CATHS.SQL".
 
   To test whether CATHS has run, do a "describe" of one of the HS objects. For 
   example, connect to the Oracle server as schema "SYSTEM" and do 
   "DESCRIBE SYS.HS_FDS_CLASS". If it does not exist, connect as SYS (or 
   internal) and run the CATHS script.
 
 
4) Configure an ODBC System Data Source.
   
   From the Control panel select "Data Sources (ODBC)". Click the "System DSN"
   tab. Click the "Add" button. Select the "SQL Server" driver. In the 
   configuration panel, key a name and description of your choice. Remember the 
   name, it is required later - on my system I called it "sstest". Select a SQL
   Server from the drop-down menu. Choose your preference for
   authentication. I chose "SQL Server authentication" and specified userid
   "SA" (you can guess the password). Click "Next". I didn't change any
   further options on the next two panels. Click "Finish", you get a button to
   "test data source", which worked for me, then clicked "ok" twice to finish.
   
5) Configure tnsnames.ora. This file is in ORACLE_HOME\NETWORK\ADMIN.
   Add an entry, e.g.:
 
   hsodbc.uk.oracle.com  = 
      (DESCRIPTION=
        (ADDRESS=
           (PROTOCOL=tcp)
           (HOST=<HOSTNAME>)           |<- adjust hostname for your system
           (PORT=1521)                 |<- adjust port if not using 1521 
        )  
        (CONNECT_DATA=
           (SID=hsodbc)
        )
        (HS=)
      )    
 
 
  Note, a sample file is located in ORACLE_HOME\HS\ADMIN.
 
6) Configure listener.ora. This file is also in ORACLE_HOME\NETWORK\ADMIN.
   Add the following line to the SID_List of the listener.ora 
 
        (SID_DESC=
           (SID_NAME=hsodbc)
           (ORACLE_HOME=d:\oracle\ora81)  |<- adjust Oracle_Home directory
           (PROGRAM=hsodbc)
         )
   
   Note, a sample file is located in ORACLE_HOME\HS\ADMIN.
 
7) Restart the Oracle listener: 
   In an MSDOS window, issue commands "LSNRCTL STOP" then LSNRCTL START".
   Do "LSNRCTL STATUS" to check there is a service handler for your hsodbc 
   entry.
 
8) Adjust the configuration file of the gateway.  It is located in 
   ORACLE_HOME\HS\ADMIN. The name depends on the SID you use for the 
   Heterogeneous Service.
   In my example the listener SID is "hsodbc", thus the configuration file 
   is inithsodbc.ora:
 
   # This is a sample agent init file that contains the HS parameters that are
   # needed for an ODBC Agent. 
   #
   # HS init parameters
   #
   HS_FDS_CONNECT_INFO = sstest    |<- ODBC Data Source Name configured in step 4
   HS_FDS_TRACE_LEVEL = 0          |<- trace levels are from 0 to 4 (4 is maximum)
   HS_FDS_TRACE_FILE_NAME = sstest.trc |<- adjust as required  
 
   The trace file specification can be commented out if not required. 
   Trace files are generated with default names in the ORACLE_HOME/HS/TRACE 
   directory if trace level is not zero. 
 
9) In an SQL*Plus session, create a database link. E.g.:
 
   create database link hsodbc using 'hsodbc';
 
 
10) Test the connection. E.g.:
 
    select * from authors@hsodbc;    
 
 
ODBC PROBLEM DETERMINATION
--------------------------
 
If problems are encountered, (e.g. ORA-9100 errors), please check the ODBC 
configuration and obtain the following information prior to reporting the problem 
to Oracle Support Services:
 
1.  You should be using an MS SQL ODBC Driver.
    a. What is the DSN (Data Source Name)?  This can be determined by
       clicking on 'Control Panel' then click on 'ODBC' then click on
       the 'System DSN' tab.
 
    b. What is the SQL Driver Version?  Click on the '32 bit Administrator'
       icon in the Oracle group, Click on the 'Driver' button then Click on 
       the SQL Server driver and choose 'About'.
 
    c. Obtain an ODBC trace:
        Run REGEDT32, click on 'hkey_local_machine', choose
        software, odbc, odbc.ini. Change the value of the 
        TRACE parameter to 1 and provide a valid trace file
        name in the TRACEFILE parameter. 

장시영(sironge)님이 2004-05-24 12:45에 작성한 댓글입니다.

답변 감사 합니다.

그런데 위 방법의 해결책을 아시는 분이 계시면 알려 주셨으면 합니다.

어떻게 해야 하는건지 궁금해서리...^^;;;

 

사람님이 2004-05-24 20:52에 작성한 댓글입니다. Edit
select * from openquery(oracle, 'select * from "TEST"."TABLE"')

쿼리는 아래와 같이 수정하시면 됩니다.

 

select * from openquery(oracle, 'select * from 스키마.테이블명')

 

"TEST"."TABLE" -> TEST.TABLE

"" ->요것만 빼주시면 돼요

지나가다님이 2006-06-25 19:44에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
18611URL을 Encode하는 함수는?
URL
2004-05-24
1504
18610스케줄러 질문입니다(초보임다)..
이동진
2004-05-24
1499
18609날짜계산--->>분 [1]
초보
2004-05-24
2137
18608MS-SQL과 Oracle의 연동 관련 [3]
사람
2004-05-24
13326
18606jsp(ejb를 이용한) 에서 oracle 9i의 procedure를 부르고 싶을때.
천사태지
2004-05-24
1542
18605두 DB의 동기화 방법에 대해서.... [5]
완전초보
2004-05-24
2003
18603디스크가 깨지는 바람에 dbf file이 날아갔는데... [7]
cc
2004-05-23
2012
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2025 DSN, All rights reserved.
작업시간: 0.010초, 이곳 서비스는
	PostgreSQL v17.5로 자료를 관리합니다