Skip to content

Commit

Permalink
feat: Postgres support for getddl macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan Bowe committed Jul 29, 2020
1 parent 98a0d18 commit 53865a3
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
65 changes: 65 additions & 0 deletions base/mp_getddl.sas
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,72 @@ run;
run;
%end;
%end;
%else %if &flavour=PGSQL %then %do;
/* if schema does not exist, set to be same as libref */
%local schemaactual;
proc sql noprint;
select sysvalue into: schemaactual
from dictionary.libnames
where libname="&libref" and engine='POSTGRES';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));

%do x=1 %to %sysfunc(countw(&dsnlist));
%let curds=%scan(&dsnlist,&x);
data _null_;
file &fref mod;
put "/* Postgres Flavour DDL for &schema..&curds */";
data _null_;
file &fref mod;
set &colinfo (where=(upcase(memname)="&curds")) end=last;
length fmt $32;
if _n_=1 then do;
if memtype='DATA' then do;
put "CREATE TABLE &schema..&curds (";
end;
else do;
put "CREATE VIEW &schema..&curds (";
end;
put " "@@;
end;
else put " ,"@@;
format=upcase(format);
if 1=0 then; /* dummy if */
%if &applydttm=YES %then %do;
else if format=:'DATETIME' then fmt=' TIMESTAMP ';
%end;
else if type='num' then fmt=' DOUBLE PRECISION';
else fmt='VARCHAR('!!cats(length)!!')';
if notnull='yes' then notnul=' NOT NULL';
put name fmt notnul;
run;
data _null_;
length ds $128;
set &idxinfo (where=(memname="&curds"));
file &fref mod;
by idxusage indxname;
if unique='yes' then uniq=' unique';
ds=cats(libname,'.',memname);
if first.indxname then do;
if unique='yes' and nomiss='yes' then do;
put ' ,PRIMARY KEY ';
end;
else if unique='yes' then do;
/* add nonclustered in case of multiple unique indexes */
put ' ,UNIQUE ';
end;
put ' (' name ;
end;
else put ' ,' name ;
if last.indxname then do;
put ' )';
end;
run;
data _null_;
file &fref mod;
put ');';
run;
%end;
%end;
%if &showlog=YES %then %do;
options ps=max;
data _null_;
Expand Down
2 changes: 1 addition & 1 deletion doxy/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ doxygen Doxyfile
# refresh github pages site
git clone [email protected]:sasjs/core.github.io.git
cd core.github.io
git rm -r *
rm -r *
mv $BUILD_FOLDER/out/doxy/* .
echo 'core.sasjs.io' > CNAME
git add *
Expand Down
7 changes: 4 additions & 3 deletions meta/mm_adduser2group.sas
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/**
@file
@file mm_adduser2group.sas
@brief Adds a user to a group
@details Adds a user to a metadata group. The macro first checks whether the
user is in that group, and if not, the user is added.
Usage:
%mm_adduser2group(user=sasdemo
,group=someGroup)
%mm_adduser2group(user=sasdemo
,group=someGroup)
@param user= the user name (not displayname)
@param group= the group to which to add the user
@param mdebug= set to 1 to show debug info in log
@warning the macro does not check inherited group memberships - it looks at
direct members only
Expand Down

0 comments on commit 53865a3

Please sign in to comment.