今天图老师小编要跟大家分享Oracle调用外部程序C++常见问题解决,精心挑选的过程简单易学,喜欢的朋友一起来学习吧!
【 tulaoshi.com - 编程语言 】
创建的 library
   createorreplacelibraryMYLIB
  as'D:installedoracleora92bintest1.dll';
dll 中定义了一个方法 int fnTest1(void) 返回一个数字
函数
   CREATEORREPLACEFUNCTIONmytest1RETURNDOUBLEPRECISIONAS
  LANGUAGECNAME"fnTest1"
  LIBRARYMYLIB
  PARAMETERS(RETURNDOUBLE);
说明:
ORA-28575:unabletoopenRPCconnectiontoexternalprocedureagent
解决:
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/bianchengyuyan/)   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
来源:http://www.tulaoshi.com/n/20160219/1617993.html
看过《Oracle调用外部程序C++常见问题解决》的人还看了以下文章 更多>>