当前位置:网站首页>达梦数据库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命令行控制台配置,否则环境变量不能正常识别。
边栏推荐
- 【HCIA-cloud】【1】云计算的定义、什么是云计算、云计算的架构与技术说明、华为云计算产品、华为内存DDR配置工具说明
- LeetCode 6111. 螺旋矩阵 IV
- 生词生词生词生词[2]
- [QNX hypervisor 2.2 user manual]6.3.2 configuring VM
- Simulate the hundred prisoner problem
- Gimp 2.10 tutorial "suggestions collection"
- Logical words in Articles
- ViewPager + RecyclerView的内存泄漏
- sample_rate(采樣率),sample(采樣),duration(時長)是什麼關系
- Electron installation problems
猜你喜欢

LeetCode 6109. Number of people who know the secret

Reptile 01 basic principles of reptile

Record eval() and no in pytoch_ grad()

vulnhub之darkhole_2

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!

Use of websocket tool

LeetCode 6109. 知道秘密的人数

《ClickHouse原理解析与应用实践》读书笔记(5)

Introduction to the development function of Hanlin Youshang system of Hansheng Youpin app

吴恩达团队2022机器学习课程,来啦
随机推荐
What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
[paddlepaddle] paddedetection face recognition custom data set
Reading notes of Clickhouse principle analysis and Application Practice (5)
Is it safe for Apple mobile phone to speculate in stocks? Is it a fraud to get new debts?
About Statistical Power(统计功效)
《力扣刷题计划》复制带随机指针的链表
基于can总线的A2L文件解析(3)
记录Pytorch中的eval()和no_grad()
ConvMAE(2022-05)
jdbc读大量数据导致内存溢出
Xiaobai getting started with NAS - quick building private cloud tutorial series (I) [easy to understand]
c期末复习
【pm2详解】
图像分类,看我就够啦!
How can cluster deployment solve the needs of massive video access and large concurrency?
Crontab 日志:如何记录我的 Cron 脚本的输出
项目中遇到的问题 u-parse 组件渲染问题
生词生词生词生词[2]
The 11th China cloud computing standards and Applications Conference | cloud computing national standards and white paper series release, and Huayun data fully participated in the preparation
U-Net: Convolutional Networks for Biomedical Images Segmentation