WEB开发网
开发学院数据库Oracle Oracle调用外部程序C++常见问题解决 阅读

Oracle调用外部程序C++常见问题解决

 2008-09-19 12:55:40 来源:WEB开发网   
核心提示:创建的 library createorreplacelibraryMYLIBas'D:installedoracleora92bintest1.dll';dll 中定义了一个方法 int fnTest1(void) 返回一个数字函数 CREATEORREPLACEFUNCTIONmytest1RETU

创建的 library  

   createorreplacelibraryMYLIB
  as'D:installedoracleora92bintest1.dll';

dll 中定义了一个方法 int fnTest1(void) 返回一个数字

函数

   CREATEORREPLACEFUNCTIONmytest1RETURNDOUBLEPRECISIONAS
  LANGUAGECNAME"fnTest1"
  LIBRARYMYLIB
  PARAMETERS(RETURNDOUBLE);

说明: 

   ORA-28575:unabletoopenRPCconnectiontoexternalprocedureagent

解决:  

   1.tnsnames.ora需要配置EXTPROC_CONNECTION_DATA
  EXTPROC_CONNECTION_DATA=
  (DESCRIPTION=
  (ADDRESS_LIST=
  (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
  (ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))
  )
  (CONNECT_DATA=
  (SID=PLSExtProc)
  (PRESENTATION=RO)
  )
  (CONNECT_DATA=
  (SID=ora10g)
  (PRESENTATION=RO)
  )
  )

2. listener.ora 需要配置 (PROGRAM = extproc) 

   SID_LIST_LISTENER=
  (SID_LIST=
  (SID_DESC=
  (SID_NAME=PLSExtProc)
  (ORACLE_HOME=D:oracleproduct10.2.0db_1)
  (PROGRAM=extproc)
  )
  (SID_DESC=
  (SID_NAME=ora10g)
  (ORACLE_HOME=D:oracleproduct10.2.0db_1)
  )
  )
  ORA6521PL/SQL:Errormappingfunction

解决:

   Note:297906.1 
  Cause 
  UsageofC++file(*.cpp)insteadofCfile(*.c)assourceforbuildingtheDLL 
  Thelibrarygeneratedcontainsthefunctionwiththedecoratednamewhichismangledbydefault 
  Solution 
  Toimplementthesolution,pleaseusethefollowingcodeforthe*.cppcode: 
  #ifdef__cplusplus 
  extern"C"{ 
  #endif 
  int__declspec(dllexport)square_of(intx) 
  { 
  return(x*x); 
  } 
  #ifdef__cplusplus 
  } 
  #endif

Tags:Oracle 调用 外部

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接