热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在SQLite中创建自定义函数-HowtocreatecustomfunctionsinSQLite

CanyoucreatefunctionsinSQLitelikeyoucaninMSSQL?您可以像在MSSQL中一样在SQLite中创建函数吗?Ifso,how?W

Can you create functions in SQLite like you can in MSSQL?

您可以像在MSSQL中一样在SQLite中创建函数吗?

If so, how? What is the syntax?

如果是这样,怎么样?语法是什么?

Thanks

谢谢

2 个解决方案

#1


40  

SQLite does not have a stored function/stored procedure language. So CREATE FUNCTION does not work. What you can do though is map functions from a c library to SQL functions (user-defined functions). To do that, use SQLite's C API (see: http://www.sqlite.org/c3ref/create_function.html)

SQLite没有存储的函数/存储过程语言。所以CREATE FUNCTION不起作用。你可以做的是从c库到SQL函数(用户定义函数)的映射函数。为此,请使用SQLite的C API(请参阅:http://www.sqlite.org/c3ref/create_function.html)

If you're not using the C API, your wrapper API may define something that allows you access to this feature, see for example:

如果您没有使用C API,您的包装器API可能会定义允许您访问此功能的内容,例如,请参阅:

  • PHP sqlite_create_function() (http://www.php.net/manual/en/function.sqlite-create-function.php)
  • PHP sqlite_create_function()(http://www.php.net/manual/en/function.sqlite-create-function.php)
  • Python sqlite3.create_function() (http://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.create_function)
  • Python sqlite3.create_function()(http://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.create_function)
  • Perl $dbh->func(_$name,_$argc,_$func_ref,_"create_function") (https://metacpan.org/pod/DBD::SQLite#dbh-sqlite_create_function-name-argc-code_ref)
  • Perl $ dbh-> func(_ $ name,_ $ argc,_ $ func_ref,_“create_function”)(https://metacpan.org/pod/DBD::SQLite#dbh-sqlite_create_function-name-argc-code_ref)

#2


0  

This could be useful to many: in SQLiteStudio it is possible to define new functions and collations easily from interface through a sql built-in plugin for example.

这对许多人来说可能很有用:在SQLiteStudio中,可以通过sql内置插件轻松地从界面定义新的函数和排序规则。

https://github.com/pawelsalawa/sqlitestudio/wiki/Official_plugins#sql-built-in

https://github.com/pawelsalawa/sqlitestudio/wiki/Official_plugins#sql-built-in

Through the function editor.

通过功能编辑器。


推荐阅读
author-avatar
淡忘那曾经的你_953
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有