当前位置:网站首页>达梦数据库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配置工具说明
- Le cours d'apprentissage de la machine 2022 de l'équipe Wunda arrive.
- ConvMAE(2022-05)
- Huaxia Fund: sharing of practical achievements of digital transformation in the fund industry
- About Statistical Power(统计功效)
- 瀚升优品app翰林优商系统开发功能介绍
- Various pits of vs2017 QT
- Memory leak of viewpager + recyclerview
- Is it safe to open an account, register and dig money? Is there any risk? Is it reliable?
- sample_ What is the relationship between rate, sample and duration
猜你喜欢

Record a case of using WinDbg to analyze memory "leakage"

Sophon CE Community Edition is online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool

vulnhub之darkhole_2

buuctf-pwn write-ups (9)

Privacy computing helps secure data circulation and sharing

ViewPager + RecyclerView的内存泄漏

SAP 特征 特性 说明

第十一届中国云计算标准和应用大会 | 云计算国家标准及白皮书系列发布 华云数据全面参与编制

如何写出好代码 - 防御式编程

瀚升优品app翰林优商系统开发功能介绍
随机推荐
Multithreading (I) processes and threads
让更多港澳青年了解南沙特色文创产品!“南沙麒麟”正式亮相
Use of websocket tool
怎么自动安装pythn三方库
The 11th China cloud computing standards and Applications Conference | China cloud data has become the deputy leader unit of the cloud migration special group of the cloud computing standards working
瀚升优品app翰林优商系统开发功能介绍
第十届全球云计算大会 | 华云数据荣获“2013-2022十周年特别贡献奖”
About Statistical Power(统计功效)
【在優麒麟上使用Electron開發桌面應】
Generate classes from XML schema
Use of print function in MATLAB
rust统计文件中单词出现的次数
JVM third talk -- JVM performance tuning practice and high-frequency interview question record
金太阳开户安全吗?万一免5开户能办理吗?
U-Net: Convolutional Networks for Biomedical Images Segmentation
U-Net: Convolutional Networks for Biomedical Images Segmentation
Login and connect CDB and PDB
最大人工岛[如何让一个连通分量的所有节点都记录总节点数?+给连通分量编号]
Check namespaces and classes
buuctf-pwn write-ups (9)