1 CREATE PROCEDURE Delete_date2 (3 @applycode nvarchar4 )5 as6--declaring variable definition variables separated by commas7declare @applycode_var nvarchar ( -),8@instanceid_var nvarchar ( -),9@t_ywsloid_var nvarchar ( -),Ten@areaPart_oid nvarchar ( -), One@areaPartoid nvarchar ( -) A begin ---Identify workflow Instances - Select@instanceid_var =instanceid fromT_ywslwhereApplycode=@applycode the--Delete a task table for a workflow instance (Todo and done) -Delete fromAssigntaskwhereAssigntask.instanceid=@instanceid_var - Commit ---Query Business Handling OID + Select@t_ywsloid_var =t_ywsloid fromT_ywslwhereApplycode=@applycode - +--loop to delete the corresponding coordinate range A--SQL Server at--Defining Cursors - DECLARE my_cursor cursor ---reading data into the cursor - for(SelectAreapartoid fromAreapartwhereT_ywsloid=@t_ywsloid_var) ---Open Cursor - Open My_cursor in--reads the first row of data in the collection -FETCH NEXT frommy_cursor into @areaPart_oid to--global variable, 0 means the fetch statement succeeds;-1 indicates that the statement failed or the row is not in the result set;2 rows that are fetched do not exist + while@ @FETCH_STATUS =0 - begin theDelete fromAreapointswhereAreapartoid=@areaPart_oid * Commit $--Read Next linePanax NotoginsengFETCH NEXT frommy_cursor into @areaPart_oid - End the Close My_cursor + deallocate my_cursor A the--delete the corresponding parcel list +Delete fromAreapartwhereT_ywsloid=@t_ywsloid_var - Commit $--Delete the corresponding attachment management $Delete fromFilemanagewheret_ywsl_fk=@t_ywsloid_var - Commit ---Approval Comments theDelete fromSpyjwheret_ywsl_fk=@t_ywsloid_var - CommitWuyi--Process Advice the--Workflow Instance Notebook -Delete fromFlowinstancewhereInstanceid=@instanceid_var; Wu Commit ---Active Transition Condition set AboutDECLARE t_cursor cursor for $ SelectTaskticketoid fromTaskticketwhereInstanceid=@instanceid_var - Open T_cursor -FETCH NEXT fromt_cursor into @areaPartoid - while@ @FETCH_STATUS =0 A begin +Delete fromTransconditionexwheretaskticket_fk=@areaPartoid the Commit -FETCH NEXT fromt_cursor into @areaPartoid $ End the Close T_cursor the deallocate t_cursor the--Task Table theDelete fromTaskticketwhereInstanceid=@instanceid_var - Commit in--Business Acceptance Form theDelete fromT_ywslwhereApplycode=@applycode the Commit AboutEnd
View Code
SQL Server Stored Procedures