妖
妖刀
Unregistered / Unconfirmed
GUEST, unregistred user!
没怎么用过sql server +手上的事一大堆,汗。
请哪位帮帮忙。对于sql server 熟的兄弟来说。不是什么问题d说。hoho
这个是一个oracle数据库中取单据号的过程。现在想把他移植到sql server数据库。但是偶对sql server不熟啊。
Create or Replace procedure
get_billno(p_inbilltype in varchar2,p_outbillno out varchar2) //一个参数是单据类型,另外一个输出单据号
is
ls_billno varchar2(20);
ls_month varchar2(4);
ll_hour number(2);
error
EXCEPTION;
begin
select f_val into ll_hour from lsconf where f_vkey='失效时间'; //
if ll_hour is null then
ll_hour:=24;
end if;
update billno set use_flag='N',use_date=null where use_flag='1' and bill_type=p_inbilltype and use_date<=sysdate - ll_hour/24;
select substr(pickmonth,3,2)||substr(pickmonth,6,2) into ls_month from p_pick_month where pickflag='F';
select min(to_number(bill_no)) into ls_billno from billno where use_flag='N' and bill_type=p_inbilltype;
if ls_billno is null then
select max(to_number(bill_no)) into ls_billno from billno where bill_type=p_inbilltype;
if ls_billno is null then
ls_billno:='0';
end if;
ls_billno:=to_char(to_number(ls_billno) + 1);
insert into billno values(p_inbilltype,ls_billno,'1',sysdate);
else
lno set use_flag='1',use_date=sysdate where bill_no=ls_billno and bill_type=p_inbilltype;
end if;
p_outbillno:=ls_month||lpad(ls_billno,4,'0');
EXCEPTION WHEN
error THEN
p_outbillno:=p_inbilltype;
end get_billno;
调试通过马上结扎。谢谢
请哪位帮帮忙。对于sql server 熟的兄弟来说。不是什么问题d说。hoho
这个是一个oracle数据库中取单据号的过程。现在想把他移植到sql server数据库。但是偶对sql server不熟啊。
Create or Replace procedure
get_billno(p_inbilltype in varchar2,p_outbillno out varchar2) //一个参数是单据类型,另外一个输出单据号
is
ls_billno varchar2(20);
ls_month varchar2(4);
ll_hour number(2);
error
EXCEPTION;
begin
select f_val into ll_hour from lsconf where f_vkey='失效时间'; //
if ll_hour is null then
ll_hour:=24;
end if;
update billno set use_flag='N',use_date=null where use_flag='1' and bill_type=p_inbilltype and use_date<=sysdate - ll_hour/24;
select substr(pickmonth,3,2)||substr(pickmonth,6,2) into ls_month from p_pick_month where pickflag='F';
select min(to_number(bill_no)) into ls_billno from billno where use_flag='N' and bill_type=p_inbilltype;
if ls_billno is null then
select max(to_number(bill_no)) into ls_billno from billno where bill_type=p_inbilltype;
if ls_billno is null then
ls_billno:='0';
end if;
ls_billno:=to_char(to_number(ls_billno) + 1);
insert into billno values(p_inbilltype,ls_billno,'1',sysdate);
else
lno set use_flag='1',use_date=sysdate where bill_no=ls_billno and bill_type=p_inbilltype;
end if;
p_outbillno:=ls_month||lpad(ls_billno,4,'0');
EXCEPTION WHEN
error THEN
p_outbillno:=p_inbilltype;
end get_billno;
调试通过马上结扎。谢谢