drop_views toegevoegd voor SQLS

svn path=/Database/trunk/; revision=8306
This commit is contained in:
Jos Groot Lipman
2003-08-12 15:24:42 +00:00
parent 4246fd8157
commit da7fe595d6

View File

@@ -251,6 +251,47 @@ go
make_views
go
/*
* drop_views is used in UPDATE scripts. Whenever any VIEW has been changed
* the combination drop_views/make_views must be used to ensure all dependant
* views are recreated.
*/
IF EXISTS(SELECT 1
FROM INFORMATION_SCHEMA.routines
WHERE routine_NAME LIKE 'drop_views'
and routine_schema like user)
drop procedure make_views
go
create procedure drop_views as
begin
DECLARE query CURSOR FOR
select distinct p.fac_package_name, o2.name
from sysobjects o1, fac_package p, sysobjects o2, sysdepends d
where
(o1.type = 'FN' or o1.type = 'P')
and o1.uid = user_id(p.fac_package_name)
and d.id = o1.id
and d.depid = o2.id
and (o2.type = 'U' or o2.type = 'V')
order by 1
declare @pk varchar(500);
declare @vw varchar(500);
declare @sql varchar(500);
OPEN query;
FETCH NEXT FROM query INTO @pk,@vw;
WHILE (@@FETCH_STATUS <> -1 ) BEGIN
set @sql = 'drop view '+@pk+'.'+@vw;
exec(@sql);
FETCH NEXT FROM query INTO @pk,@vw;
END;
CLOSE query;
DEALLOCATE query;
end
[/skip]
#endif