Loading...
Searching...
No Matches
exportdb.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Exports the data controller library in DB specific DDL
4 @details If user is in the administrator group, they can call this
5 service directly adding the following URL params:
6
7 @li &flavour= (SAS, PGSQL or TSQL - defaults to SAS)
8 @li &schema= (optional, if target schema is needed)
9
10 Data inserts are generated for the SAS and PGSQL flavours only; the TSQL
11 export contains DDL without inserts.
12
13 <h4> SAS Macros </h4>
14 @li mf_getuser.sas
15 @li mp_abort.sas
16 @li mp_ds2ddl.sas
17 @li mp_lib2inserts.sas
18 @li mp_streamfile.sas
19 @li mpe_getgroups.sas
20
21 @version 9.2
22 @author 4GL Apps Ltd
23 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
24 and may not be re-distributed or re-sold without the express permission of
25 4GL Apps Ltd.
26
27**/
28
29%mpeinit()
30
31%global flavour schema;
32/* if no flavour is specified, default to SAS */
33%let flavour=%sysfunc(coalescec(&flavour,SAS));
34
35/* if no schema var provided, DC Libref is used */
36%let schema=%sysfunc(coalescec(&schema,&dc_libref));
37
38/* check user is in admin group */
39%mpe_getgroups(user=%mf_getuser(),outds=work.usergroups)
40
41data work.admins;
42 set work.usergroups;
43 put (_all_)(=);
44run;
45
46%let cnt=0;
47proc sql noprint;
48select count(*) into:cnt
49 from usergroups
50 where groupname="&mpeadmins";
51%put &=cnt;
52%mp_abort(iftrue= (&cnt=0)
53 ,mac=&_program
54 ,msg=%str(The &DC_LIBREF library can only be exported by &mpeadmins members)
55)
56
57%mp_ds2ddl(&DC_LIBREF
58 ,flavour=&flavour
59 ,schema=&schema
60 ,applydttm=YES
61 ,showlog=NO
62 ,fref=tmpref
63)
64
65%mp_lib2inserts(&DC_LIBREF,flavour=&flavour,schema=&schema, outref=tmpref)
66
67%mp_streamfile(contenttype=TEXT
68 ,inref=tmpref
69 ,outname=&dc_libref..ddl
70)