当前位置:网站首页>达梦数据库udf实现
达梦数据库udf实现
2022-07-05 18:24:00 【Q446512799】
官方介绍的很简单,其实有点小坑
头文件引用
//-I/dm/dmdbms/include/
#include "de_pub.h"
库文件引用
-L/dm/dmdbms/bin/ -ldmde字符串拼接代码(函数名必须是大写,否则创建成功,调用报错【[-7095]:外部函数加载失败.】)
de_data C_CONCAT(de_args *args)
{
de_data de_ret;
char* str1;
char* str2;
char* str3;
int len1;
int len2;
str1 = (char*)de_get_str(args, 0); /*从参数列表中取第0个参数*/
str2 = (char*)de_get_str_with_len(args, 1, (udint4*)&len2); /*从参数列表中取第1个参数的值以及长度*/
len1 = strlen(str1);
str3 = (char*)malloc(len1 + len2);
memcpy(str3, str1, len1);
memcpy(str3 + len1, str2, len2);
de_str_free((sdbyte*)str1); /*调用get函数得到字符串之后,需要调用此函数释放字符串空间*/
de_str_free((sdbyte*)str2);
de_ret = de_return_str_with_len((udbyte*)str3, len1 + len2); /*返回字符串*/
free(str3);
return de_ret;
}编译生成动态库
创建函数
CREATE OR REPLACE FUNCTION C_CONCAT(A VARCHAR, B VARCHAR)
RETURN VARCHAR
EXTERNAL '/dm/dmdbms/bin/libtestudf.so' C_CONCAT USING C;
/实际项目使用

注:因为c编写达梦udf走的是dmap代理(/dm/dmdbms/bin/dmap),所以首先需要启动代理。如果库依赖外部环境变量,需要在配置环境变量的控制台手工启动dmap,而不是在运行disql命令行控制台配置,否则环境变量不能正常识别。
边栏推荐
- Record eval() and no in pytoch_ grad()
- Generate XML schema from class
- Various pits of vs2017 QT
- 吳恩達團隊2022機器學習課程,來啦
- Numerical calculation method chapter8 Numerical solutions of ordinary differential equations
- ClickHouse(03)ClickHouse怎么安装和部署
- U-Net: Convolutional Networks for Biomedical Images Segmentation
- Nanjing University: Discussion on the training program of digital talents in the new era
- [use electron to develop desktop on youqilin]
- Crontab 日志:如何记录我的 Cron 脚本的输出
猜你喜欢

Fix vulnerability - mysql, ES

How to obtain the coordinates of the aircraft passing through both ends of the radar

Privacy computing helps secure data circulation and sharing

第十届全球云计算大会 | 华云数据荣获“2013-2022十周年特别贡献奖”

《力扣刷题计划》复制带随机指针的链表

爬虫01-爬虫基本原理讲解

ConvMAE(2022-05)

The 2022 China Xinchuang Ecological Market Research and model selection evaluation report released that Huayun data was selected as the mainstream manufacturer of Xinchuang IT infrastructure!

About Estimation with Cross-Validation

Thoroughly understand why network i/o is blocked?
随机推荐
快速生成ipa包
文章中的逻辑词
Is it safe to open an account, register and dig money? Is there any risk? Is it reliable?
Thoroughly understand why network i/o is blocked?
Introduction to Resampling
基于can总线的A2L文件解析(3)
爱因斯坦求和einsum
Maximum artificial island [how to make all nodes of a connected component record the total number of nodes? + number the connected component]
音视频包的pts,dts,duration的由来.
《力扣刷题计划》复制带随机指针的链表
Is it safe for golden sun to open an account? Can I open an account free of 5 in case?
Tupu software digital twin | visual management system based on BIM Technology
Matlab built-in function how different colors, matlab subsection function different colors drawing
Memory management chapter of Kobayashi coding
[use electron to develop desktop on youqilin]
Memory leak of viewpager + recyclerview
关于服装ERP,你想知道的都在这里了
Personal understanding of convolutional neural network
小林coding的内存管理章节
第十一届中国云计算标准和应用大会 | 云计算国家标准及白皮书系列发布 华云数据全面参与编制