火鸟常数值
是否可以拥有数据库范围的常量? 我想要的是定义一个常量,例如:
- UPDATE_CONSTANT = 1
- INSERT_CONSTANT = 2
- DELETE_CONSTANT = 3
,然后在例如触发器中使用它,例如:
CREATE TRIGGER AD_PRJ_PROJECTS FOR PRJ_PROJECT
ACTIVE AFTER DELETE
POSITION 1
AS
BEGIN
EXECUTE PROCEDURE SP_ADD_HISTORY 'PRJ_PROJECT', DELETE_CONSTANT;
END;
Is it possible to have database wide constants?
What I want is to define a constant like:
- UPDATE_CONSTANT = 1
- INSERT_CONSTANT = 2
- DELETE_CONSTANT = 3
and then use it in for example a trigger like:
CREATE TRIGGER AD_PRJ_PROJECTS FOR PRJ_PROJECT
ACTIVE AFTER DELETE
POSITION 1
AS
BEGIN
EXECUTE PROCEDURE SP_ADD_HISTORY 'PRJ_PROJECT', DELETE_CONSTANT;
END;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用生成器:
更新:是的,为此目的使用生成器是危险的,因为它们可以更改。
但是,在 FireBird 3.0 Alpha 1 中,可以使用访问权限消除此风险: 授予访问权限发电机。
You could use a generator:
Update: yes, using a generator for this purpose is dangerous, as they can be changed.
However, in FireBird 3.0 Alpha 1 this risk can be eliminated using access rights: Grants access on generators.
我认为没有一种简单的方法来声明常量。
我可以通过为用户定义的函数创建自己的 DLL,并为每个常量创建一个函数来完成。
我认为使用生成器作为“全局”常量的想法非常出色。
但是您可以创建一个“局部常量”以使代码更具可读性:
I don't think there is an easy way for declaring constants.
I could be done by creating you own DLL for user defined function, and lmake a function for each constant.
I Think the Idea using generators as "global" constants is briliant.
But you can make a "local constant" to make your code a bit more readable:
使用带有触发器的单行表来防止插入和删除。必须读取它当然不会使代码更清晰,但它有助于实现这样的“常量”。同时删除除 sysdba 之外的所有人的写入权限
Use a single row table with triggers that prevent insertion and deletion from it. Having to read from it certainly does not makes code clearer but it helps to implement such "constants". Also remove write permissions from everybody but sysdba
实现一些简单的脚本预处理器,将常量转换为值
。
您可以
You can implement some simple preprocesor of yours scripts that converts constants to values..
triggers.presql
triggers.sql