order by ft.table_name,fo.user_name,fkc.primary_column_id
end
go
CREATE procedure dbo.sp_pkeys(
in @table_name char(128),
in @table_owner char(128) default NULL,
in @table_qualifier char(128) default NULL
)
result (
table_qualifier char(128),
table_owner char(128),
table_name char(128),
column_name char(128),
key_seq smallint )
begin
if @table_owner is null then
set @table_owner = '%'
end if;
select
current database,
user_name,
table_name,
column_name,
column_id
from SYS.SYSTABLE t, SYS.SYSCOLUMN c, SYS.SYSUSERPERM u
where t.table_id = c.table_id
and t.creator = u.user_id
and table_name like @table_name
and user_name like @table_owner
and pkey = 'Y'
order by table_name,user_name,column_id
end
go
create procedure dbo.sp_serverinfo
@request varchar(30) = NULL
as
declare @db_collation_name char(30)
select @db_collation_name = (select default_collation from SYS.SYSINFO)
if (@db_collation_name is null)
begin
select @db_collation_name = 'internal'
end
-- If the collation information does not exist, use the default
if not exists ( select * from SYS.SYSCOLLATIONMAPPINGS
where collation_label = @db_collation_name )
begin
select @db_collation_name = 'internal'
end
if (@request = 'server_soname')
if( (select case_sensitivity from SYS.SYSINFO) = 'N' )
-- Case insensitive sort order
select so_caseless_label from SYS.SYSCOLLATIONMAPPINGS
where collation_label = @db_collation_name
else
-- Case sensitive sort order
select so_case_label from SYS.SYSCOLLATIONMAPPINGS
where collation_label = @db_collation_name
else if (@request = 'server_csname')
select cs_label from SYS.SYSCOLLATIONMAPPINGS
where collation_label = @db_collation_name
go
CREATE procedure dbo.sp_server_info(
in @attribute_id int default NULL
)
begin
call sp_tsql_feature_not_supported()
end
go
CREATE procedure dbo.sp_special_columns(
in @table_name char(128),
in @table_owner char(128) default NULL,
in @table_qualifier char(128) default NULL,
in @col_type char(1) default 'R'
)
result (
scope int ,
column_name char(128),
data_type smallint,
type_name char(128),
"precision" int,
length int,
scale smallint
)
begin
declare @indid int;
declare @full_table_name long varchar;
declare objid int;
declare indexid int;
if @table_owner is null then
set @full_table_name = @table_name
else
set @full_table_name = @table_owner || '.' || @table_name
end if;
set objid = object_id(@full_table_name);
if objid is null then
return
end if;
if @col_type = 'V' then
select
0,
column_name,
d.type_id,
d.domain_name,
isnull(d."precision",width),
width,
scale
from SYS.SYSCOLUMN c, SYS.SYSDOMAIN d
where table_id = objid - 100000
and c.domain_id = d.domain_id
and ("default" = 'autoincrement' or "default" = 'timestamp');
return
end if;
if exists (select * from SYS.SYSCOLUMN
where table_id = objid - 100000 and pkey = 'Y') then
select
0,
column_name,
d.type_id,
d.domain_name,
isnull(d."precision",width),
width,
scale
from SYS.SYSCOLUMN c, SYS.SYSDOMAIN d
where table_id = objid - 100000
and c.domain_id = d.domain_id
and pkey = 'Y'
order by column_id;
return
end if;
set indexid = (select min(index_id) from SYS.SYSINDEX
where table_id = objid - 100000 and "unique" = 'U');
if indexid is not null then
select
0,
column_name,
d.type_id,
d.domain_name,
isnull(d."precision",width),
width,
scale
from SYS.SYSCOLUMN c, SYS.SYSDOMAIN d, SYS.SYSINDEX ix, SYS.SYSIXCOL ic
where c.table_id = objid - 100000
and c.domain_id = d.domain_id
and ix.table_id = c.table_id
and ix.index_id = indexid
and ic.table_id = ix.table_id
and ic.index_id = ix.index_id
order by ic.sequence;
return
end if;
end
go
CREATE procedure dbo.sp_sproc_columns(
in @sp_name char(128),
in @sp_owner char(128) default NULL,
in @sp_qualifier char(128) default NULL,
in @column_name char(128) default NULL
)
result (
procedure_qualifier char(128),
procedure_owner char(128),
procedure_name char(128),
column_name char(128),
column_type smallint,
data_type smallint,
type_name char(128),
"precision" int,
length int,
scale smallint,
radix smallint,
nullable smallint,
remarks varchar(254),
ss_data_type smallint,
colid smallint
)
begin
declare @full_sp_name long varchar;
declare objid int;
if @sp_owner is null then
set @full_sp_name = @sp_name
else
set @full_sp_name = @sp_owner || '.' || @sp_name
end if;
if @column_name is null then
set @column_name = '%'
end if;
set objid = object_id( @full_sp_name );
select
current database,
user_name,
proc_name,
parm_name,
0,
d.type_id,
domain_name,
d."precision",
width,
scale,
if locate(d.domain_name,'char') = 0
and locate(d.domain_name,'binary') = 0
and locate(d.domain_name,'time') = 0
and locate(d.domain_name,'date') = 0
then 10 else NULL endif,
if "default" is not null then 1 else 0 endif,
null,
pp.domain_id,
parm_id
from SYS.SYSPROCEDURE p, SYS.SYSPROCPARM pp, SYS.SYSDOMAIN d,
SYS.SYSUSERPERM u
where p.proc_id = objid - 200000
and p.proc_id = pp.proc_id
and pp.domain_id = d.domain_id
and p.creator = u.user_id
and pp.parm_type = 0
and parm_name like @column_name
end
go
CREATE procedure dbo.sp_statistics(
in @table_name char(128) default '%',
in @table_owner char(128) default '%',
in @table_qualifier char(128) default '%',
in @index_name char(128) default '%',
in @is_unique char(1) default 'N')
result (
table_qualifier varchar(32),
table_owner varchar(32),
table_name varchar(32),
non_unique smallint,
index_qualifier varchar(32),
index_name varchar(32),
"type" smallint,
seq_in_index smallint,
collation char(1),
cardinality integer,
pages integer)
begin
declare @full_table_name long varchar;
if @table_owner='%' then
set @full_table_name=@table_name
else
set @full_table_name=@table_owner||'.'||@table_name
end if;
select convert(varchar(32),db_name(*)) as table_qualifier,
convert(varchar(32),user_name(tab.creator)) as table_owner,
convert(varchar(32),tab.table_name) as table_name,
convert(smallint,null) as non_unique,
convert(varchar(32),null) as index_qualifier,
convert(varchar(32),null) as index_name,
convert(smallint,0) as "type",
convert(smallint,0) as seq_in_index,
convert(char(1),null) as collation,
convert(integer,tab."count") as cardinality,
convert(integer,tab."count") as pages
from SYS.SYSTABLE as tab
where tab.table_id=(object_id(@full_table_name)-100000)
union all
select convert(varchar(32),db_name(*)) as table_qualifier,
convert(varchar(32),user_name(tab.creator)) as table_owner,
convert(varchar(32),tab.table_name) as table_name,
convert(smallint,if "unique"='Y' then 0 else 1 endif) as non_unique,
convert(varchar(32),tab.table_name) as index_qualifier,
convert(varchar(32),ind.index_name) as index_name,
convert(smallint,3) as "type",
convert( smallint ,ixcol.column_id) as seq_in_index,
convert(char(1),ixcol."order") as collation,
convert(integer,tab."count") as cardinality,
convert(integer,tab."count") as pages
from SYS.SYSTABLE as tab,sysindex as ind,sysixcol as ixcol
where tab.table_id=(object_id(@full_table_name)-100000)
and ind.table_id=tab.table_id
and ixcol.index_id=ind.index_id
and ixcol.table_id=ind.table_id
and ind."unique"<>'U'
and ind.index_name like @index_name
and(@is_unique='Y' or ind."unique"='N')
order by 4 asc,7 asc,6 asc,8 asc
end
go
CREATE procedure dbo.sp_stored_procedures(
in @sp_name char(128) default NULL,
in @sp_owner char(128) default NULL,
in @sp_qualifier char(128) default NULL
)
result (
procedure_qualifier char(128),
procedure_owner char(128),
procedure_name char(128),
num_input_params int,
num_output_params int,
num_result_sets int,
remarks varchar(254) )
begin
if @sp_name is null then
set @sp_name = '%'
else
if (@sp_owner is null) and (charindex('%', @sp_name) = 0) then
if exists (select * from SYS.SYSPROCEDURE, SYS.SYSUSERPERMS
where creator = user_id
and user_name = user
and proc_name = @sp_name ) then
set @sp_owner = user
end if
end if
end if;
if @sp_owner is null then
set @sp_owner = '%'
end if;
select
current database,
user_name,
proc_name,
(select count(*) from SYS.SYSPROCPARM
where parm_mode_in = 'Y'
and parm_type = 0
and proc_id = p.proc_id),
(select count(*) from SYS.SYSPROCPARM
where parm_mode_out = 'Y'
and parm_type = 0
and proc_id = p.proc_id),
if exists (select * from SYS.SYSPROCPARM
where parm_type = 1
and proc_id = p.proc_id) then 1 else 0 endif,
null
from SYS.SYSPROCEDURE p, SYS.SYSUSERPERM u
where proc_name like @sp_name
and user_name like @sp_owner
and p.creator = u.user_id
end
go
CREATE procedure dbo.sp_table_privileges(
in @table_name char(128),
in @table_owner char(128) default NULL,
in @table_qualifier char(128) default NULL
)
begin
call sp_tsql_feature_not_supported()
end
go
CREATE procedure dbo.sp_tables(
in @table_name char(128) default '%',
in @table_owner char(128) default '%',
in @table_qualifier char(128) default '%',
in @table_type char(128) default '%')
result (
table_qualifier varchar(30),
table_owner varchar(30),
table_name varchar(30),
table_type varchar(30),
remarks varchar(254))
begin
select cast(current database as varchar(30)),
cast(creator as varchar(30)),
cast(tname as varchar(30)),
cast((if tabletype='VIEW' then
'VIEW'
else
if creator='SYS' and tabletype='TABLE' then
'SYSTEM TABLE'
else
'TABLE'
endif
endif) as varchar(30)),
cast(null as varchar(254))
from SYS.SYSCATALOG
where (creator like @table_owner)
and (tname like @table_name)
and( @table_type='%'
or(locate(@table_type,'''TABLE''')<>0
and tabletype<>'VIEW' and creator<>'SYS')
or(locate(@table_type,'''VIEW''')<>0
and tabletype='VIEW')
or(locate(@table_type,'''SYSTEM TABLE''')<>0
and tabletype<>'VIEW' and creator='SYS'))
and(current database like @table_qualifier)
end
go
CREATE procedure dbo.sp_tsql_environment()
begin
if db_property( 'IQStore' ) = 'OFF' then
-- ASA datastore
SET TEMPORARY OPTION TSQL_VARIABLES='ON';
SET TEMPORARY OPTION ANSI_BLANKS='ON';
SET TEMPORARY OPTION TSQL_HEX_CONSTANT='ON';
SET TEMPORARY OPTION CHAINED='OFF';
SET TEMPORARY OPTION QUOTED_IDENTIFIER='OFF';
SET TEMPORARY OPTION ALLOW_NULLS_BY_DEFAULT='OFF';
SET TEMPORARY OPTION AUTOMATIC_TIMESTAMP='ON';
SET TEMPORARY OPTION ANSINULL='OFF';
SET TEMPORARY OPTION CONTINUE_AFTER_RAISERROR='ON';
SET TEMPORARY OPTION FLOAT_AS_DOUBLE='ON';
SET TEMPORARY OPTION ISOLATION_LEVEL='1';
SET TEMPORARY OPTION DATE_FORMAT='YYYY-MM-DD';
SET TEMPORARY OPTION TIMESTAMP_FORMAT='YYYY-MM-DD HH:NN:SS.SSS';
SET TEMPORARY OPTION TIME_FORMAT='HH:NN:SS.SSS';
SET TEMPORARY OPTION DATE_ORDER='MDY';
SET TEMPORARY OPTION ESCAPE_CHARACTER='OFF';
end if;
end
go
CREATE procedure dbo.sp_login_environment()
begin
if connection_property( 'CommProtocol' ) = 'TDS' then
call dbo.sp_tsql_environment();
end if;
end
go
CREATE function dbo.col_length(
in @object_name char(128),
in @column_name char(128)
)
returns integer
on exception resume
begin
declare sz integer;
declare objid integer;
set objid = object_id( @object_name );
select width into sz
from SYS.SYSCOLUMN
where table_id = objid - 100000
and column_name = @column_name;
return( sz );
end
go
CREATE function dbo.col_name(
in @object_id integer,
in @column_id integer,
in @database_id integer default NULL
)
returns char(128)
on exception resume
begin
declare cname char(128);
select "name" into cname
from dbo.syscolumns
where id = @object_id
and colid = @column_id;
if SQLCODE <> 0 then
return( NULL )
end if;
return( cname );
end
go
CREATE function dbo.index_col(
in @object_name char(128),
in @index_id integer,
in @key_# integer,
in @user_id integer default NULL
)
returns char(128)
on exception resume
begin
declare cname char(128);
declare objid integer;
declare indid integer;
set objid = object_id( @object_name );
if objid is null then return( NULL ) end if;
select column_name into cname
from SYS.SYSCOLUMN, SYS.SYSIXCOL
where SYSIXCOL.table_id = objid - 100000
and index_id = @index_id
and sequence = @key_#
and SYSIXCOL.table_id=SYSCOLUMN.table_id
and SYSIXCOL.column_id=SYSCOLUMN.column_id;
return( cname );
end
go
CREATE function dbo.object_id(
in @object_name char(128)
)
returns integer
on exception resume
begin
declare obj_owner char(128);
declare obj_name char(128);
declare id integer;
declare posn integer;
set posn = locate(@object_name,'.');
if( posn <> 0 ) then
set obj_owner = substr(@object_name,1,posn-1);
set obj_name = substr(@object_name,posn+1);
select o.id into id
from dbo.sysobjects o, SYS.SYSUSERPERMS p
where o."name"=obj_name
and o.uid=p.user_id
and p.user_name=obj_owner;
else
select o.id into id
from dbo.sysobjects o
where "name"=@object_name;
end if;
return( id );
end
go
CREATE function dbo.object_name(
in @object_id integer,
in @database_id integer default NULL
)
returns char(128 )
on exception resume
begin
declare obj_name char(128);
select "name" into obj_name
from dbo.sysobjects
where id = @object_id;
return( obj_name );
end
go
CREATE function dbo.proc_role(
in @role_type char(10)
)
returns integer
on exception resume
begin
return( 0 );
end
go
CREATE function dbo.show_role()
returns char(128)
on exception resume
begin
return( NULL );
end
go
CREATE function dbo.xp_startmail(
in mail_user char(254) default null,
in mail_password char(254) default null )
returns int
external name 'xp_startmail@dbextf6.dll;Windows3x:xp_startmail@dbextf6w.dll'
go
CREATE function dbo.xp_stopmail()
returns int
external name 'xp_stopmail@dbextf6.dll;Windows3x:xp_stopmail@dbextf6w.dll'
go
CREATE function dbo.xp_sendmail(
in recipient char(254),
in subject char(254) default null,
in cc_recipient char(254) default null,
in bcc_recipient char(254) default null,
in query char(254) default null,
in "message" char(254) default null,
in attachname char(254) default null,
in attach_result int default 0,
in echo_error int default 1,
in include_file char(254) default null,
in no_column_header int default 0,
in no_output int default 0,
in width int default 80,
in separator char(1) default '\t',
in dbuser char(254) default 'guest',
in dbname char(254) default 'master',
in type char(254) default null,
in include_query int default 0 )
returns int
external name 'xp_sendmail@dbextf6.dll;Windows3x:xp_sendmail@dbextf6w.dll'
go
CREATE function dbo.xp_cmdshell(
in command char(254) default null,
in redir_output char(254) default 'no_output' )
returns int
external name 'xp_cmdshell@dbextf6.dll;Netware:xp_cmdshell;Windows3x:xp_cmdshell@dbextf6w.dll'
go
CREATE procedure dbo.xp_sprintf(
out output_buffer char(254),
in format char(254),
in parm1 char(254) default null,
in parm2 char(254) default null,
in parm3 char(254) default null,
in parm4 char(254) default null,
in parm5 char(254) default null,
in parm6 char(254) default null,
in parm7 char(254) default null,
in parm8 char(254) default null,
in parm9 char(254) default null,
in parm10 char(254) default null,
in parm11 char(254) default null,
in parm12 char(254) default null,
in parm13 char(254) default null,
in parm14 char(254) default null,
in parm15 char(254) default null,
in parm16 char(254) default null,
in parm17 char(254) default null,
in parm18 char(254) default null,
in parm19 char(254) default null,
in parm20 char(254) default null,
in parm21 char(254) default null,
in parm22 char(254) default null,
in parm23 char(254) default null,
in parm24 char(254) default null,
in parm25 char(254) default null,
in parm26 char(254) default null,
in parm27 char(254) default null,
in parm28 char(254) default null,
in parm29 char(254) default null,
in parm30 char(254) default null,
in parm31 char(254) default null,
in parm32 char(254) default null,
in parm33 char(254) default null,
in parm34 char(254) default null,
in parm35 char(254) default null,
in parm36 char(254) default null,
in parm37 char(254) default null,
in parm38 char(254) default null,
in parm39 char(254) default null,
in parm40 char(254) default null,
in parm41 char(254) default null,
in parm42 char(254) default null,
in parm43 char(254) default null,
in parm44 char(254) default null,
in parm45 char(254) default null,
in parm46 char(254) default null,
in parm47 char(254) default null,
in parm48 char(254) default null,
in parm49 char(254) default null,
in parm50 char(254) default null )
external name 'OS2:xp_sprintf[varargs]@dbextf6.dll;Windows95:xp_sprintf[varargs]@dbextf6.dll;WindowsNT:xp_sprintf[varargs]@dbextf6.dll;Netware:xp_sprintf[varargs];Windows3x:xp_sprintf[varargs]@dbextf6w.dll'
go
CREATE procedure dbo.xp_scanf(
in input_buffer char(254),
in format char(254),
out parm1 char(254) default null,
out parm2 char(254) default null,
out parm3 char(254) default null,
out parm4 char(254) default null,
out parm5 char(254) default null,
out parm6 char(254) default null,
out parm7 char(254) default null,
out parm8 char(254) default null,
out parm9 char(254) default null,
out parm10 char(254) default null,
out parm11 char(254) default null,
out parm12 char(254) default null,
out parm13 char(254) default null,
out parm14 char(254) default null,
out parm15 char(254) default null,
out parm16 char(254) default null,
out parm17 char(254) default null,
out parm18 char(254) default null,
out parm19 char(254) default null,
out parm20 char(254) default null,
out parm21 char(254) default null,
out parm22 char(254) default null,
out parm23 char(254) default null,
out parm24 char(254) default null,
out parm25 char(254) default null,
out parm26 char(254) default null,
out parm27 char(254) default null,
out parm28 char(254) default null,
out parm29 char(254) default null,
out parm30 char(254) default null,
out parm31 char(254) default null,
out parm32 char(254) default null,
out parm33 char(254) default null,
out parm34 char(254) default null,
out parm35 char(254) default null,
out parm36 char(254) default null,
out parm37 char(254) default null,
out parm38 char(254) default null,
out parm39 char(254) default null,
out parm40 char(254) default null,
out parm41 char(254) default null,
out parm42 char(254) default null,
out parm43 char(254) default null,
out parm44 char(254) default null,
out parm45 char(254) default null,
out parm46 char(254) default null,
out parm47 char(254) default null,
out parm48 char(254) default null,
out parm49 char(254) default null,
out parm50 char(254) default null )
external name 'OS2:xp_scanf[varargs]@dbextf6.dll;Windows95:xp_scanf[varargs]@dbextf6.dll;WindowsNT:xp_scanf[varargs]@dbextf6.dll;Netware:xp_scanf[varargs];Windows3x:xp_scanf[varargs]@dbextf6w.dll'
go
CREATE function dbo.xp_msver(
in the_option char(254) default 'ProductName' )
returns char( 254 )
begin
declare r char( 254 );
declare s char( 254 );
case the_option
when 'ProductName' then
select property( 'ProductName' ) into r from dummy;
when 'ProductVersion' then
select property( 'ProductVersion' ) into r from dummy;
when 'CompanyName' then
select property( 'CompanyName' ) into r from dummy;
when 'LegalCopyright' then
select property( 'LegalCopyright' ) into r from dummy;
when 'LegalTrademarks' then
select property( 'LegalTrademarks' ) into r from dummy;
when 'FileDescription' then
select property( 'ProductName' ) into r from dummy;
select property( 'Platform' ) into s from dummy;
set r = r || ' ' || s
else
set r = '<unknown>'
end case ;
return( r );
end
go
CREATE procedure dbo.sa_db_info( IN dbidparm int default NULL )
result (
Number int,
Alias varchar(255),
File varchar(255),
ConnCount int,
PageSize int,
LogName varchar(255)
)
begin
declare dbid int;
declare local temporary table t_db_info(
Number int null,
Alias varchar(255) null,
File varchar(255) null,
ConnCount int null,
PageSize int null,
LogName varchar(255) null
) in SYSTEM on commit preserve rows;
if( dbidparm is not NULL ) then
set dbid = dbidparm;
else
set dbid = next_database( NULL );
end if;
lbl:
loop
if dbid is NULL then
leave lbl;
end if;
insert into t_db_info values (
dbid,
db_property( 'Alias', dbid ),
db_property( 'File', dbid ),
db_property( 'ConnCount', dbid ),
db_property( 'PageSize', dbid ),
db_property( 'LogName', dbid ),
);
if( dbidparm is not NULL ) then
leave lbl;
else
set dbid = next_database( dbid );
end if;
end loop lbl;
select * from t_db_info;
end
go
CREATE procedure dbo.sa_conn_info( IN connidparm int default NULL )
result (
Number int,
Name varchar(255),
Userid varchar(255),
DBNumber int,
LastReqTime varchar(255),
ProcessTime varchar(255),
Port int,
ReqType varchar(255),
CommLink varchar(255),
NodeAddr varchar(255),
LastIdle int,
CurrTaskSw int,
BlockedOn int,
UncmtOps int
)
begin
declare connid int;
declare local temporary table t_conn_info(
Number int null,
Name varchar(255) null,
Userid varchar(255) null,
DBNumber int null,
LastReqTime varchar(255) null,
ProcessTime varchar(255) null,
Port int null,
ReqType varchar(255) null,
CommLink varchar(255) null,
NodeAddr varchar(255) null,
LastIdle int null,
CurrTaskSw int null,
BlockedOn int null,
UncmtOps int null
) in SYSTEM on commit preserve rows;
if( connidparm is not NULL ) then
set connid = connidparm;
else
set connid = next_connection( connid, NULL );
end if;
lbl:
loop
if connid is NULL then
leave lbl
end if;
insert into t_conn_info values (
connid,
connection_property( 'Name', connid ),
connection_property( 'Userid', connid ),
connection_property( 'DBNumber', connid ),
connection_property( 'LastReqTime', connid ),
connection_property( 'ProcessTime', connid ),
connection_property( 'Port', connid ),
connection_property( 'ReqType', connid ),
connection_property( 'CommLink', connid ),
connection_property( 'NodeAddress', connid ),
connection_property( 'LastIdle', connid ),
connection_property( 'CurrTaskSw', connid ),
connection_property( 'BlockedOn', connid ),
connection_property( 'UncmtOps', connid )
);
if( connidparm is not NULL ) then
leave lbl;
else
set connid = next_connection( connid, NULL );
end if;
end loop lbl;
select * from t_conn_info;
end
go
CREATE procedure dbo.sa_eng_properties()
result (
PropNum int,
PropName varchar(255),
PropDescription varchar(255),
Value varchar(255)
)
begin
declare i int;
declare local temporary table t_eng_properties(
PropNum int null,
PropName varchar(255) null,
PropDescription varchar(255) null,
Value varchar(255) null
) in SYSTEM on commit preserve rows;
set i = 0;
proploop:
loop
if( property( i ) is not NULL ) then
insert into t_eng_properties values (
i,
property_name( i ),
property_description( i ),
property( i )
);
else
if( i > 200 ) then
leave proploop;
end if;
end if;
set i = i + 1;
end loop proploop;
select * from t_eng_properties;
end
go
CREATE procedure dbo.sa_db_properties( IN dbidparm int default NULL )
result (
Number int,
PropNum int,
PropName varchar(255),
PropDescription varchar(255),
Value varchar(255)
)
begin
declare dbid int;
declare i int;
declare local temporary table t_db_properties(
Number int null,
PropNum int null,
PropName varchar(255) null,
PropDescription varchar(255) null,
Value varchar(255) null
) in SYSTEM on commit preserve rows;
if( dbidparm is not NULL ) then
set dbid = dbidparm;
else
set dbid = next_database( NULL );
end if;
dbloop:
loop
if dbid is NULL then
leave dbloop;
end if;
set i = 0;
proploop:
loop
if( db_property( i, dbid ) is not NULL ) then
insert into t_db_properties values (
dbid,
i,
property_name( i ),
property_description( i ),
db_property( i, dbid )
);
else
if( i > 200 ) then
leave proploop;
end if;
end if;
set i = i + 1;
end loop proploop;
if( dbidparm is not NULL ) then
leave dbloop;
else
set dbid = next_database( dbid );
end if;
end loop dbloop;
select * from t_db_properties;
end
go
CREATE procedure dbo.sa_conn_properties( IN connidparm int default NULL )
result (
Number int,
PropNum int,
PropName varchar(255),
PropDescription varchar(255),
Value varchar(255)
)
begin
declare connid int;
declare i int;
declare local temporary table t_conn_properties(
Number int null,
PropNum int null,
PropName varchar(255) null,
PropDescription varchar(255) null,
Value varchar(255) null
) in SYSTEM on commit preserve rows;
if( connidparm is not NULL ) then
set connid = connidparm;
else
set connid = next_connection( NULL );
end if;
connloop:
loop
if connid is NULL then
leave connloop;
end if;
set i = 0;
proploop:
loop
if( connection_property( i, connid ) is not NULL ) then