319 lines
7.2 KiB
Plaintext
319 lines
7.2 KiB
Plaintext
-- [CREA*.SQL]
|
|
--
|
|
-- Script tbv het aanmaken van de Facilitor omgeving in Oracle
|
|
-- Copyright 1996-2004 Dijkoraad IT bv/Facilitor Software Nederland bv.
|
|
-- All rights reserved!
|
|
|
|
/*
|
|
* $History: FCLT.SRC $
|
|
*
|
|
* ***************** Version 46 *****************
|
|
* User: Pf Date: 8-09-04 Time: 13:16
|
|
* Updated in $/Facilitor/SRC/SQL
|
|
*
|
|
*/
|
|
|
|
#include "modules.h"
|
|
#ifdef MS_SQL
|
|
#include "MSSQLFNS.sql"
|
|
#endif
|
|
#include "comsql.h"
|
|
|
|
_SET_SQLS(NOCOUNT ON)
|
|
/* _SET_SQLS(IMPLICIT_TRANSACTIONS ON) */
|
|
_SET_SQLS(ANSI_NULL_DFLT_OFF OFF)
|
|
_SET_SQLS(ANSI_NULL_DFLT_ON ON)
|
|
_SET_SQLS(CONCAT_NULL_YIELDS_NULL OFF)
|
|
|
|
SPOOL crea1
|
|
PROMPT [CREA1.LST]
|
|
PROMPT
|
|
PROMPT Copyright 1996-2004 Dijkoraad IT bv/Facilitor Software Nederland bv
|
|
PROMPT
|
|
PROMPT Dit script is de gegenereerde list-file van *.SQL welke
|
|
PROMPT is gebruikt om de Facilitor(r) omgeving in Oracle aan te
|
|
PROMPT maken.
|
|
PROMPT
|
|
PROMPT Dit script is gerund in user:
|
|
SHOW USER _GO
|
|
PROMPT
|
|
PROMPT
|
|
|
|
SET ECHO ON
|
|
set lines 500
|
|
|
|
/* TABLES */
|
|
#include "fac_tab.src"
|
|
#include "alg_tab.src"
|
|
#include "ins_tab.src"
|
|
#include "prs_tab.src"
|
|
#include "mld_tab.src"
|
|
#include "mrk_tab.src"
|
|
#include "cad_tab.src"
|
|
#include "res_tab.src"
|
|
#include "bez_tab.src"
|
|
#include "web_tab.src"
|
|
#include "cnt_tab.src"
|
|
#include "bes_tab.src"
|
|
#include "pra_tab.src"
|
|
#include "sch_tab.src"
|
|
|
|
COMMIT;
|
|
|
|
/* UNIQUES */
|
|
#include "fac_uni.src"
|
|
#include "alg_uni.src"
|
|
#include "ins_uni.src"
|
|
#include "prs_uni.src"
|
|
#include "mld_uni.src"
|
|
#include "mrk_uni.src"
|
|
#include "cad_uni.src"
|
|
#include "res_uni.src"
|
|
#include "bez_uni.src"
|
|
#include "web_uni.src"
|
|
#include "cnt_uni.src"
|
|
#include "bes_uni.src"
|
|
#include "pra_uni.src"
|
|
#include "sch_uni.src"
|
|
|
|
COMMIT;
|
|
|
|
#ifndef MS_SQL
|
|
|
|
/* SEQUENCES */
|
|
#include "fac_seq.src"
|
|
#include "alg_seq.src"
|
|
#include "ins_seq.src"
|
|
#include "prs_seq.src"
|
|
#include "mld_seq.src"
|
|
#include "mrk_seq.src"
|
|
#include "cad_seq.src"
|
|
#include "res_seq.src"
|
|
#include "bez_seq.src"
|
|
#include "web_seq.src"
|
|
#include "cnt_seq.src"
|
|
#include "bes_seq.src"
|
|
#include "pra_seq.src"
|
|
#include "sch_seq.src"
|
|
COMMIT;
|
|
|
|
#endif
|
|
|
|
/* PACKAGES 1
|
|
*
|
|
* Deze packages bevatten code welke in views worden gebruikt
|
|
*/
|
|
/* VIEWS 1 */
|
|
#include "fac_vie.src"
|
|
#include "alg_vie.src"
|
|
#include "ins_vie.src"
|
|
#include "prs_vie1.src"
|
|
#include "prs_pac.src"
|
|
#include "prs_vie2.src"
|
|
#include "mld_vie.src"
|
|
#include "mrk_vie.src"
|
|
#include "cad_vie1.src"
|
|
#include "res_vie.src"
|
|
#include "bez_vie.src"
|
|
#include "web_vie.src"
|
|
#include "cnt_vie.src"
|
|
#include "bes_vie.src"
|
|
#include "pra_vie.src"
|
|
#include "sch_vie.src"
|
|
COMMIT;
|
|
|
|
/* PACKAGES 2 */
|
|
/* 22-05-96/KTH
|
|
* Let op: Packages komen voor triggers want er zijn triggers
|
|
* die refereren naar packages. Ze komen na tables etc. want packages
|
|
* zullen refereren naar tables en views.
|
|
*/
|
|
|
|
#include "cnt_pac.src"
|
|
#include "mld_pac.src"
|
|
#include "mrk_pac.src"
|
|
#include "fac_pac.src"
|
|
#include "ins_pac.src"
|
|
/* #include "prs_pac.src" */
|
|
/* #include "prs_vie2.src" */
|
|
#include "cad_pac.src"
|
|
#include "res_pac.src"
|
|
#include "bez_pac.src"
|
|
#include "web_pac.src"
|
|
#include "bes_pac.src"
|
|
#include "pra_pac.src"
|
|
#include "sch_pac.src"
|
|
|
|
COMMIT;
|
|
|
|
/* VIEWS 2
|
|
*
|
|
* Deze views komen na de packages want ze gebruiken stored functions uit packages
|
|
*/
|
|
#include "cad_vie2.src"
|
|
#include "mld_vie2.src"
|
|
|
|
COMMIT;
|
|
|
|
/* INDICES */
|
|
#include "fac_ind.src"
|
|
#include "alg_ind.src"
|
|
#include "ins_ind.src"
|
|
#include "prs_ind.src"
|
|
#include "mld_ind.src"
|
|
#include "mrk_ind.src"
|
|
#include "cad_ind.src"
|
|
#include "res_ind.src"
|
|
#include "bez_ind.src"
|
|
#include "web_ind.src"
|
|
#include "cnt_ind.src"
|
|
#include "bes_ind.src"
|
|
#include "pra_ind.src"
|
|
#include "sch_ind.src"
|
|
COMMIT;
|
|
|
|
/* TRIGGERS */
|
|
#include "fac_tri.src"
|
|
#include "alg_tri.src"
|
|
#include "ins_tri.src"
|
|
#include "prs_tri.src"
|
|
#include "cnt_tri.src"
|
|
#include "mld_tri.src"
|
|
#include "mrk_tri.src"
|
|
#include "cad_tri.src"
|
|
#include "res_tri.src"
|
|
#include "bez_tri.src"
|
|
#include "web_tri.src"
|
|
#include "bes_tri.src"
|
|
#include "pra_tri.src"
|
|
#include "sch_tri.src"
|
|
|
|
COMMIT;
|
|
|
|
/* INITIALISATIES */
|
|
#include "fac_ini.src"
|
|
#include "alg_ini.src"
|
|
#include "ins_ini.src"
|
|
#include "prs_ini.src"
|
|
#include "mld_ini.src"
|
|
#include "mrk_ini.src"
|
|
#include "cad_ini.src"
|
|
#include "res_ini.src"
|
|
#include "bez_ini.src"
|
|
#include "web_ini.src"
|
|
#include "cnt_ini.src"
|
|
#include "bes_ini.src"
|
|
#include "pra_ini.src"
|
|
#include "sch_ini.src"
|
|
|
|
COMMIT;
|
|
|
|
/* DIVERSEN */
|
|
[skip]
|
|
#ifndef MS_SQL
|
|
|
|
#include "cad/cad_rol.src" /* ROLEs en GRANTs (hierin wordt ook geSPOOLed!) */
|
|
#include "fac/fac_rol.src" /* ROLEs en GRANTs (hierin wordt ook geSPOOLed!) */
|
|
#include "mld/mld_rol.src" /* ROLEs en GRANTs (hierin wordt ook geSPOOLed!) */
|
|
#include "res/res_rol.src" /* ROLEs en GRANTs (hierin wordt ook geSPOOLed!) */
|
|
#include "bez/bez_rol.src"
|
|
#include "web/web_rol.src"
|
|
#include "cnt/cnt_rol.src" /* ROLEs en GRANTs (hierin wordt ook geSPOOLed!) */
|
|
#include "bes/bes_rol.src" /* ROLEs en GRANTs (hierin wordt ook geSPOOLed!) */
|
|
#include "pra/pra_rol.src" /* ROLEs en GRANTs (hierin wordt ook geSPOOLed!) */
|
|
#include "sch/sch_rol.src" /* ROLEs en GRANTs (hierin wordt ook geSPOOLed!) */
|
|
|
|
|
|
#endif
|
|
[/skip]
|
|
|
|
COMMIT;
|
|
|
|
#ifdef MS_SQL
|
|
[skip]
|
|
|
|
IF EXISTS(SELECT 1
|
|
FROM INFORMATION_SCHEMA.routines
|
|
WHERE routine_NAME LIKE 'make_views'
|
|
and routine_schema like user)
|
|
drop procedure make_views
|
|
go
|
|
|
|
create procedure make_views as
|
|
begin
|
|
DECLARE query CURSOR FOR
|
|
select p.fac_package_name,o.table_name
|
|
from fac_package p
|
|
,information_schema.tables o
|
|
where o.table_schema=user
|
|
and not exists(select 1
|
|
from information_schema.tables o2
|
|
where o2.table_schema like p.fac_package_name
|
|
and o2.table_name=o.table_name);
|
|
|
|
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 = 'create view '+@pk+'.'+@vw
|
|
+ ' as select * from '+user+'.'+@vw;
|
|
exec(@sql);
|
|
FETCH NEXT FROM query INTO @pk,@vw;
|
|
END;
|
|
CLOSE query;
|
|
DEALLOCATE query;
|
|
end
|
|
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
|
|
|
|
PROMPT -- Creatie van Facilitor-user gereed; bekijk *.LST voor evt. errors!!
|