IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[sys_Sql_getval_global]') AND type = 'P')
DROP PROCEDURE [dbo].[sys_Sql_getval_global]
GO
create procedure [dbo].[sys_Sql_getval_global](
@parseid int,
@proctype varchar(50),
@script varchar(4000) output
) as
begin

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
--java调用的存储过程，在web缓存取数据，通过参数传递到存储过程
if (@proctype='java')
return

-- datatype:1 整数   2：浮点数  3：字符串
Declare @globalname varchar(50),@gid int,@gname varchar(50),@gval varchar(500),@datatype int,@cnt int
select @script='',@cnt=0

Declare gc Cursor static For
select c.g_id, c.g_name,c.g_value
from sys_sql_global a,sys_sql_inf b,mps_global c
where a.parseid=1 and a.parseid=b.parseid and b.cmpid=c.g_cmpid
and (a.globalname=c.g_name or a.globalname=c.g_caption)
open gc
fetch next from gc into @gid,@gname,@gval
while (@@fetch_status=0)
begin
select @script=@script +
'select @gl_'+convert(varchar(10),@gid) + '= g_val' +
'   from mps_global ' +
'   where g_id=' + convert(varchar(10),@gid) + char(13)

fetch next from gc into @gid,@gname,@gval
end

close gc
deallocate gc

end