今天儲存過程被卡

2021-04-08 21:10:13 字數 2186 閱讀 7832

create

procedure

sp_updatebulletinbyworkid

@workid

varchar(6

),@id

int,

@retflag

intout

asdeclare

@pointerprev

intdeclare

@pointercurr

intdeclare

@workreader

varchar

(100

)declare

@temp

varchar(10

)set

@pointerprev=1

set@pointercurr=1

begin

transaction

setnocount 

onif

exists

(select

@workreader

=workidreader  

from

bulletin 

whereid=

@id)

begin

set@pointercurr

=charindex('

,'

,@workreader

,@pointerprev+1

)set

@temp

=cast

(substring

(@workreader

,@pointerprev

,@pointercurr

-@pointerprev

) as

varchar)if

@temp

=@workid

begin

set@retflag=0

return

endset

@pointerprev

=@pointercurr

while

(@pointerprev+1

<

len(

@workreader

))begin

set@pointercurr

=charindex('

,'

,@workreader

,@pointerprev+1

)if

(@pointercurr

>0)

begin

set@temp

=cast

(substring

(@workreader

,@pointerprev+1

,@pointercurr

-@pointerprev-1

) as

varchar)if

@temp

=@workid

begin

set@retflag=0

return

endend

endset

@temp

=cast

(substring

(@workreader

,@pointerprev+1

,len

(@workreader)-

@pointerprev

) as

varchar)if

@temp

=@workid

begin

set@retflag=0

return

endend

update

bulletin 

setworkidreader

=workidreader+'

,'

+@workid

select

*from

bulletin 

whereid=

@idset

nocount 

offbegin

set@retflag=1

return

endif

@@error=0

begin

commit

transaction

endelse

begin

rollback

transaction

endgo

17行出錯,問題沒有解決

sql第18天 儲存過程和函式

層次查詢 函式儲存過程是乙個有名字的plsql 塊 他沒有返回值但是有輸出引數,可以將資料傳給外部程式 引數型別有三種 in,out,inout 儲存過程建立之後會儲存到資料庫中 當資料庫啟動時,自動的載入到記憶體中 一次建立,多次使用 create or replace procedure 儲存過...

ORACLE儲存過程被鎖

1.檢視是哪乙個儲存過程被鎖住 查v db object cache檢視 select from v db object cache where owner 過程的所屬使用者 and locks 0 2.檢視是哪乙個sid,通過sid可以知道是哪乙個session 查v access檢視 selec...

很久沒寫儲存過程,今天寫個儲存下

goset ansi nulls on goif exists select from dbo.sysobjects where id object id n dbo p police binding statistics and objectproperty id,n isprocedure 1 ...