如何创建Sybase存储过程

时间:2015-01-26 21:23:24

标签: stored-procedures sybase

我是Sybase的新手,我需要创建一个存储过程来收集空间,基本上将它们转换为一个过程:

create proc sp_maint
  @dbname varchar(30), @segname varchar(30),
  @devname varchar(30), @devsize int,
  @freesize int, @free_percentage int 
as declare @sizeinpg float,

1 个答案:

答案 0 :(得分:1)

create proc sp_maint
  @dbname varchar(30),
  @segname varchar(30),
  @devname varchar(30),
  @devsize int,
  @freesize int,
  @free_percentage int 
as
declare @sizeinpg float,
        @perc     float,
        @segbit   int,
        @seg      int,
        @pagefl   float
BEGIN
/* for all segments */
  select @seg = segment
  from syssegments
  where name = @segname
select DATE=convert(char(8),getdate(),1),
        DB_NAME=db,
        SEGMENT_NAME=seg,
        Allocated_Space=convert(int,(round(size,0))),
        Free_Space=convert(int,round(MBfree,0)),
        Free_Percent=convert(int,(round(((MBfree/size)*100),1))),
/* get rid of blanks */
  select @dbname = ltrim(rtrim(@dbname))
  select @segname = ltrim(rtrim(@segname))
**strong text**