Oracle 创建自定义的流水号 - Oracle / 开发
要做个发货单,用的触发器来创建自定义流水号,如果公司A在2010年5月发的第一张单,则单据号是A-2010-05-1, 第10张单的话是A-2010-05-10,每次新建是在本月本单位的最大号上加1.
我写的是这样子的,但有问题
SQL code:
create table OutgoingNotice (
OutgoingNoticeId NVARCHAR2(15) not null,
CompanyId CHAR(32) not null,
DateCreated Date,
constraint PK_OUTGOINGNOTICE primary key (OutgoingNoticeId)
);
create trigger Trigger_OGNotice_Insert before insert
on OutgoingNotice for each row
declare
newid nvarchar(15);
curMonthMaxId nvarchar(15);
begin
select og.OutgoingNoticeId into curMonthMaxId from OutgoingNotice og order by OutgoingNoticeId
where TO_CHAR(og.datecreated, 'YYYY-MM') = TO_CHAR(:new.datecreated, 'YYYY-MM') and og.CompanyId = :new.CompanyId and rownum = 1
if curMonthMaxId is null
then
newid = CONCAT(TO_CHAR(:new.datecreated, 'YYYY-MM'), '01')
else
newid = CONCAT(TO_CHAR(:new.datecreated, 'YYYY-MM'), TO_CHAR(TO_NUMBER(SUBSTR(curMonthMaxId, 6), '9999'), '9999'))
end if;
:new.OutgoingNoticeId = newid;
end;
什么问题?
是“表已经发生变化,触发器不能读取”问题吗?
楼主 你太让我失望了,好多错误哦,
首先语句结束要用";"结束
其次,赋值语句未&q
相关问答:
exp user/password@dbname file=c:\table.dmp tables=jbitaku,jbitakum grants=y
然後按回車鍵 說明: user/password@dbname 分別表示用戶名,密碼和服務名 f ......
各位大哥,帮个忙。
下个Oracle for vista 版本的安装试试
10G和11G的
http://www.oracle.com/technology/software/products/database/index.html
------------------------------------------- ......
假设table01 中有 以下资料
emp_no emp_name
------- ------------
0001 TOM
0002 JOHN
0003 MARY
常用电话
而我们要得到以下的OUTPUT (或是各种其他的output)
0001,TOM
0002,JOHN
......
服务器后台的数据库是oracle,在今天系统登录的时候报“登录不了数据库,IO异常”,结果是全公司都登不上去,我重启了一下服务器才好了,我想可能是用户并发量太大的缘故,不知道各位大虾认同不?有什么解决办法没? ......
SELECT * from (SELECT A.*, ROWNUM RN from (SELECT * from t_out_logon) A WHERE ROWNUM <= 30)WHERE RN >= 21
SELECT A.* from (SELECT t.*,rownum rn from t_out_logon t WHERE ROWNUM <= 30) A WHERE ......