use student
go/****** 物件: storedprocedure [dbo].[sp_menutree_sort] 指令碼日期: 11/29/2011 20:37:04 ******/
set ansi_nulls on
goset quoted_identifier on
goalter proc [dbo].[sp_menutree_sort]
(-- @siteid varchar(50),
@menuid varchar(20),
@sortdir bit)as
declare @parentid varchar(20)
declare @menuid2 varchar(20)
declare @menuorder1 int
declare @menuorder2 int
select @parentid = parentid,@menuorder1 = menuorder from tb_menutree where menuid = @menuid
if @sortdir = 1
begin
select top 1 @menuid2 = menuid,@menuorder2 = menuorder from tb_menutree where menuorder < @menuorder1 and parentid = @parentid order by menuorder desc
endelse
begin
select top 1 @menuid2 = menuid,@menuorder2 = menuorder from tb_menutree where menuorder > @menuorder1 and parentid = @parentid order by menuorder asc
endbegin tran
update tb_menutree set menuorder = @menuorder1 where menuid = @menuid2
update tb_menutree set menuorder = @menuorder2 where menuid = @menuid
if @@error = 0
commit tran
else
rollback tran
分頁儲存過程 排序
用途 支援任意排序的分頁儲存過程 說明 create procedure up getrecordbypageorder tblname varchar 255 表名 fldname varchar 255 顯示欄位名 orderfldname varchar 255 排序欄位名 statfldna...
通過儲存過程實現排序
通過儲存過程實現排序 create or replace procedure sort node www.2cto.com node xlid in varchar2 as v start node varchar2 100 v node1 varchar2 100 v node2 varchar2...
帶排序的oracle分頁儲存過程
create or replace package pager istype curs is ref cursor procedure pagination inpagesize in integer,每頁記錄數 inpageindex in integer,當前頁數 intablename in ...