SQL Procedure示例程式03

2021-06-03 12:17:09 字數 2347 閱讀 6933

alter procedure [dbo].[assignarearighttousers] 

asbegin

-- set nocount on added to prevent extra result sets from

-- interfering with select statements.

set nocount on;

declare @customerid varchar(50)

declare custcurosr cursor for

select oid from tbl_customdata where newflag=0

open custcurosr

fetch next from custcurosr

into @customerid

while @@fetch_status = 0

begin

exec [assignarearighttousersbyoid] @customerid

fetch next from custcurosr

into @customerid

end

close custcurosr

deallocate custcurosr

end

alter procedure [dbo].[assignarearighttousersbyoid] 

@oid varchar(40)

asbegin

-- set nocount on added to prevent extra result sets from

-- interfering with select statements.

set nocount on;

declare @areaid varchar(50)

declare @raoid varchar(50)

declare @righteeoid varchar(50) --使用者id

--獲取客戶所屬區域

select @areaid=tbl_saleorg_oid from tbl_customdata where oid =@oid

print '@areaid=' + @areaid

--根據區域找到有該區域許可權的的使用者

declare mycurosr cursor for

select distinct oid,righteeoid from tbl_rightaction

where oid

in(select a.raoid from tblarearights a, tbl_saleorg b where a.tbl_saleorg_oid = b.oid

and b.oid =@areaid

and b.sog_status = 'usage'

) open mycurosr

fetch next from mycurosr

into @raoid,@righteeoid

--給這些使用者賦擁有這個客戶的許可權

begin try

begin transaction

--先刪除該客戶對應的區域許可權

delete from tblarearights where tbl_saleorg_oid=lower(@oid)

while @@fetch_status = 0

begin

print '@raoid=' + @raoid

print '@righteeoid=' + @righteeoid

insert into tblarearights (tbl_saleorg_oid,raoid,ars_rights) values(lower(@oid),@raoid,'browse| | |')

fetch next from mycurosr

into @raoid,@righteeoid

endupdate tbl_customdata set newflag=1 where oid = @oid

commit transaction

end try

begin catch

rollback transaction

end catch

close mycurosr

deallocate mycurosr

end

EXT JS 6示例程式 Login示例程式

1.用sencha cmd生成應用程式模版 2.建立login view元件 資料夾下,有預設的 main 資料夾,這個資料夾包含了檔案main.js,maincontroller.js,和 mainmodel.js 資料夾下建立乙個資料夾 login 在 login 資料夾下,新建兩個檔案 log...

UDP Socket示例程式

通常我們涉及到的網路程式設計,也稱為socket程式設計,多數是tcp和udp協議的程式設計,二者最大的區別就是 1.tcp是可靠的傳輸,需要三次握手建立連線再傳資料,而udp是無連線的,即使沒有接收方,也可以乙個勁往乙個位址發資料,所以說是不可靠的傳輸模式。2.tcp是基於流模式的,udp是基於資...

爬蟲示例程式

importrequests frombs4importbeautifulsoup try importxml.etree.celementtreeaset exceptimporterror importxml.etree.elementtreeaset base url response req...