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= (only PGSQL supported at this time)
8  @li &schema= (optional, if target schema is needed)
9 
10  <h4> SAS Macros </h4>
11  @li mf_getuser.sas
12  @li mp_abort.sas
13  @li mp_getddl.sas
14  @li mp_lib2inserts.sas
15  @li mp_streamfile.sas
16  @li mpe_getgroups.sas
17 
18  @version 9.2
19  @author 4GL Apps Ltd
20  @copyright 4GL Apps Ltd. This code may only be used within Data Controller
21  and may not be re-distributed or re-sold without the express permission of
22  4GL Apps Ltd.
23 
24 **/
25 
26 %mpeinit()
27 
28 %global flavour schema;
29 /* if no flavour is specified, default to SAS */
30 %let flavour=%sysfunc(coalescec(&flavour,SAS));
31 
32 /* if no schema var provided, DC Libref is used */
33 %let schema=%sysfunc(coalescec(&schema,&dc_libref));
34 
35 /* check user is in admin group */
36 %mpe_getgroups(user=%mf_getuser(),outds=work.usergroups)
37 
38 data work.admins;
39  set work.usergroups;
40  put (_all_)(=);
41 run;
42 
43 %let cnt=0;
44 proc sql noprint;
45 select count(*) into:cnt
46  from usergroups
47  where groupname="&mpeadmins";
48 %put &=cnt;
49 %mp_abort(iftrue= (&cnt=0)
50  ,mac=&_program
51  ,msg=%str(The &DC_LIBREF library can only be exported by &mpeadmins members)
52 )
53 
54 %mp_getddl(&DC_LIBREF
55  ,flavour=&flavour
56  ,schema=&schema
57  ,applydttm=YES
58  ,fref=tmpref
59 )
60 
61 %mp_lib2inserts(&DC_LIBREF,flavour=&flavour,schema=&schema, outref=tmpref)
62 
63 %mp_streamfile(contenttype=TEXT
64  ,inref=tmpref
65  ,outname=&dc_libref..ddl
66 )