zoukankan      html  css  js  c++  java
  • 在SQL中调用动态链接库中的函数

     在SQL中调用动态链接库中的函数   
      代码示例:   
      ALTER   PROCEDURE   dbo.StoredProcedure2   
      /*   
      (   
      @parameter1   datatype   =   default   value,   
      @parameter2   datatype   OUTPUT   
      )   
      */   
      AS   
      /*   SET   NOCOUNT   ON   */   
      declare   @ErrorCode   int                     --//错误码   
      declare   @object         int                       --//令牌   
      declare   @Source     varchar   (255)         --   //返回错误信息   
      declare   @Dest         varchar   (255)   
      declare   @dk_str   varchar(255)                       --传入的参数   
      select   @ErrorCode   =@@Error   
      if   @ErrorCode   =   0   
            exec   @ErrorCode   =   sp_OACreate   'DK_DLL.Hourse'/*dll名称和类名称*/,@Object   Output   
      if   @ErrorCode   =0   
      select   @dk_str   ='d://test.txt'                     --为参数赋值   
      exec   @ErrorCode=sp_OAMethod   @Object   ,'OutFile'/*方法名称*/   ,NULL,@dk_str/*@ourValue   Output*/   
                                                                                                                --(这里一定要有@符号,文档有错误)   
        if   @ErrorCode<>0   
            exec   sp_OAGetErrorInfo   @Object   ,@Source   output,@Dest   output   
            set   @Dest   ='Error   ('+Convert   (varchar   ,@ErrorCode)   
                                                    +','+@Source   +   '):'+@Dest   
                                                    Raiserror   (@Dest,16,1)   
      exec   sp_OADestroy   @Object   
      /*sp_OAMethod   的用法:   ObjPointer   int   IN,   MethodName   varchar   IN   [,   @returnval   <any>   OUT   [,   additional   IN,   OUT,   or   BOTH   params]]   
          
      */   
      RETURN    

     

    http://blog.csdn.net/fengloveyun/article/details/4062772

  • 相关阅读:
    [USACO17FEB]Why Did the Cow Cross the Road III S
    [POI2015]PIE
    GSS3
    Bzoj3203: [Sdoi2013]保护出题人 凸包 + 三分
    斜率优化
    fread优化读入
    [USACO09JAN]安全出行Safe Travel 最短路,并查集
    zookeeper单机模式实现分布式,开发部署测试模式机器有限情况
    解决 jmeter An error occurred: Error while processing samples:Mismatch
    python 垃圾回收解析
  • 原文地址:https://www.cnblogs.com/Areas/p/2734241.html
Copyright © 2011-2022 走看看