当前位置:网站首页>FIREBIRD使用经验总结
FIREBIRD使用经验总结
2022-07-04 14:54:00 【全栈程序员站长】
最近在改写一段ms sql的存储过程到firebird, 总结了一些经验, firebird可以说是这个世界上最小的又支持存储过程的数据库的, 才2.3M而已,如果做小型的应用,比ms sql桌面版也有70多M(+sp3), mysql也有20-30M,太不方便。
1.自定义函数问题.Access to UDF library “rfunc.dll” is denied by server administrator 花了很长时间,不明白为何,将rfunc.dll拷到udf目录,bin目录,windows\system32目录都不能解决问题,google一下,网上有同样的问题,但没有解决方案,结果我重装了一下firebird就解决了.
2.存储过程中变量的定义 ms sql存储过程中无论在哪都可以定义新的变量,但在firebird中,只能在as 与begin之间进行定义.firebird的变量不能用@符号,我将@全部变成a就好了.
3.存储过程中变量的使用 select @i=count(*) from table1 //ms sqlselect count(*) from table1 into :i//firebird引用变量使用冒号 4.嵌入式sql, firebird支持select * from table exists (select …) 或 select * from table in (select …) 但不支持select * from (select * from …) a, 我是将这类改写成视图解决的
5.case语句 mssql 可使用field= case (),但firebbird仅支持case () as field, 6.mssql getdate()变成CURRENT_DATE+CURRENT_TIME select * from snartleave where dt_starttime<CURRENT_DATE+CURRENT_TIME 或 select * from snartleave where dt_starttime<CURRENT_DATE||’ ‘ ||CURRENT_TIME
7.返回数据集的存储过程写法(firebird写法有点麻烦) CREATE PROCEDURE SPVARTST2 ( VAR_IPTARTNO CHAR(6))RETURNS ( VAR_ARTNAME CHAR(10))ASbeginfor select v_name1 from snart where v_artNo=:var_iptartno into :var_artname dosuspend;end
8.自动增长字段的使用(autoincrement) firebird有个发生器(generator)的东东,在发生器里记录值的增长, 再用触发器实现 beginif (new.i_seqno is null) thenbegin NEW.i_seqno = GEN_ID(GEN_T_DB_ARTSEQNO_ID,1);endend //GEN_T_DB_ARTSEQNO_ID就是创建的发生器,看到没有,也就是说不同的表不同的字段可以共用一个发生器,gen_id相当于identity,看起来比mssql复杂,其实也很简单。
9.发生器重置 mssql里自动增加的字段要重置好像很麻烦,较难控制, firebird可以这样(存储过程中) agenerator=Gen_ID(GEN_T_DB_ARTSEQNO_ID,Gen_ID(GEN_T_DB_ARTSEQNO_ID,0)*-1+1); //agenerator是一个整形变量,好像一定要装gen_id的值符给一个变量才行,不知道有没有更好的办法,不用定义一个多余的变量 可参考如下网址:http://www.fingerbird.de/generatorguide_body.htm
10 通过一个表更改另一个表的数据 mssql:update table1 set cname=b.cname from table1 a inner join table2 as b where a.id=b.id firebird:update table1 a set cname=(select cname from table 2 b where b where a.id=b.id) 11.如何选择前几条记录 mssql: select top 10 * from table1 firebird:select first 10 * from table1 IB:select * from table rows 10 12.Firebird存存储过程中的事务 在存储过程 ib/fb 不支持开事务或者结束事务。提交是由调用者提交的。也就是,fb/ib存储过程应该设计在一个事务里。 在sql server里,存储过程或以开这样的事务: begin trancstion commit trancstion 但在fb/ib里没有这样的事务 需要在调的程序中开事务 如: pFIBDtbsMain.StartTransaction; pFIBDtbsMain.Commit;
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/110912.html原文链接:https://javaforall.cn
边栏推荐
- Can I "reverse" a Boolean value- Can I 'invert' a bool?
- ~89 deformation translation
- Research Report on market supply and demand and strategy of surgical stapler industry in China
- Laravel simply realizes Alibaba cloud storage + Baidu AI Cloud image review
- After the eruption of Tonga volcano, we analyzed the global volcanic distribution and found that the area with the most volcanoes is here!
- Communication mode based on stm32f1 single chip microcomputer
- c# 实现定义一套中间SQL可以跨库执行的SQL语句
- 科普达人丨一文看懂阿里云的秘密武器“神龙架构”
- Common knowledge of unity Editor Extension
- Scientific research cartoon | what else to do after connecting with the subjects?
猜你喜欢

Cut! 39 year old Ali P9, saved 150million
![[tutorial] yolov5_ DeepSort_ The whole process of pytoch target tracking and detection](/img/a7/92d670776e3fd3d5add3aa144617c7.jpg)
[tutorial] yolov5_ DeepSort_ The whole process of pytoch target tracking and detection

The vscode waveform curve prompts that the header file cannot be found (an error is reported if the header file exists)

Understand Alibaba cloud's secret weapon "dragon architecture" in the article "science popularization talent"

《吐血整理》保姆级系列教程-玩转Fiddler抓包教程(2)-初识Fiddler让你理性认识一下

Model fusion -- stacking principle and Implementation

A trap used by combinelatest and a debouncetime based solution

MFC implementation of ACM basic questions encoded by the number of characters
![[North Asia data recovery] a database data recovery case where the partition where the database is located is unrecognized due to the RAID disk failure of HP DL380 server](/img/21/513042008483cf21fc66729ae1d41f.jpg)
[North Asia data recovery] a database data recovery case where the partition where the database is located is unrecognized due to the RAID disk failure of HP DL380 server

What is torch NN?
随机推荐
[tutorial] yolov5_ DeepSort_ The whole process of pytoch target tracking and detection
Expression #1 of ORDER BY clause is not in SELECT list, references column ‘d.dept_ no‘ which is not i
C language: implementation of daffodil number function
Accounting regulations and professional ethics [8]
The vscode waveform curve prompts that the header file cannot be found (an error is reported if the header file exists)
Cut! 39 year old Ali P9, saved 150million
Go deep into the details of deconstruction and assignment of several data types in JS
科普达人丨一文看懂阿里云的秘密武器“神龙架构”
Accounting regulations and professional ethics [7]
~89 deformation translation
QT graphical view frame: element movement
实战:fabric 用户证书吊销操作流程
Application of clock wheel in RPC
Function test - knowledge points and common interview questions
Find numbers
Using celery in projects
China's roof ladder market trend report, technological innovation and market forecast
[North Asia data recovery] a database data recovery case where the disk on which the database is located is unrecognized due to the RAID disk failure of HP DL380 server
Research Report on plastic recycling machine industry - market status analysis and development prospect forecast
Preliminary practice of niuke.com (10)