mirror of
https://github.com/sasjs/core.git
synced 2026-01-05 08:30:06 +00:00
Fix: previous changes restored
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
@li mp_getconstraints.sas
|
@li mp_getconstraints.sas
|
||||||
|
|
||||||
@param lib libref of the library to create DDL for. Should be assigned.
|
@param lib libref of the library to create DDL for. Should be assigned.
|
||||||
@param ds dataset to create ddl for
|
@param ds dataset to create ddl for (optional)
|
||||||
@param fref= the fileref to which to write the DDL. If not preassigned, will
|
@param fref= the fileref to which to write the DDL. If not preassigned, will
|
||||||
be assigned to TEMP.
|
be assigned to TEMP.
|
||||||
@param flavour= The type of DDL to create (default=SAS). Supported=TSQL
|
@param flavour= The type of DDL to create (default=SAS). Supported=TSQL
|
||||||
@@ -98,6 +98,10 @@ create table _data_ as
|
|||||||
column_name=catt('[',column_name,']');
|
column_name=catt('[',column_name,']');
|
||||||
constraint_name=catt('[',constraint_name,']');
|
constraint_name=catt('[',constraint_name,']');
|
||||||
%end;
|
%end;
|
||||||
|
%else %if &flavour=PGSQL %then %do;
|
||||||
|
column_name=catt('"',column_name,'"');
|
||||||
|
constraint_name=catt('"',constraint_name,'"');
|
||||||
|
%end;
|
||||||
if first.constraint_name then do;
|
if first.constraint_name then do;
|
||||||
constraints_used = catx(' ', constraints_used, constraint_name_orig);
|
constraints_used = catx(' ', constraints_used, constraint_name_orig);
|
||||||
put " ,CONSTRAINT " constraint_name ctype "(" ;
|
put " ,CONSTRAINT " constraint_name ctype "(" ;
|
||||||
@@ -272,7 +276,9 @@ run;
|
|||||||
from dictionary.libnames
|
from dictionary.libnames
|
||||||
where libname="&libref" and engine='POSTGRES';
|
where libname="&libref" and engine='POSTGRES';
|
||||||
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
|
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
|
||||||
|
data _null_;
|
||||||
|
file &fref mod;
|
||||||
|
put "CREATE SCHEMA &schema;";
|
||||||
%do x=1 %to %sysfunc(countw(&dsnlist));
|
%do x=1 %to %sysfunc(countw(&dsnlist));
|
||||||
%let curds=%scan(&dsnlist,&x);
|
%let curds=%scan(&dsnlist,&x);
|
||||||
data _null_;
|
data _null_;
|
||||||
@@ -300,7 +306,9 @@ run;
|
|||||||
else if type='num' then fmt=' DOUBLE PRECISION';
|
else if type='num' then fmt=' DOUBLE PRECISION';
|
||||||
else fmt='VARCHAR('!!cats(length)!!')';
|
else fmt='VARCHAR('!!cats(length)!!')';
|
||||||
if notnull='yes' then notnul=' NOT NULL';
|
if notnull='yes' then notnul=' NOT NULL';
|
||||||
put name fmt notnul;
|
/* quote column names in case they represent reserved words */
|
||||||
|
name2=quote(trim(name));
|
||||||
|
put name2 fmt notnul;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* Extra step for data constraints */
|
/* Extra step for data constraints */
|
||||||
@@ -319,10 +327,10 @@ run;
|
|||||||
by idxusage indxname;
|
by idxusage indxname;
|
||||||
/* ds=cats(libname,'.',memname); */
|
/* ds=cats(libname,'.',memname); */
|
||||||
if first.indxname then do;
|
if first.indxname then do;
|
||||||
put 'CREATE UNIQUE INDEX ' indxname "ON &schema..&curds (" ;
|
put 'CREATE UNIQUE INDEX "' indxname +(-1) '" ' "ON &schema..&curds (" ;
|
||||||
put ' ' name ;
|
put ' "' name +(-1) '"' ;
|
||||||
end;
|
end;
|
||||||
else put ' ,' name ;
|
else put ' ,"' name +(-1) '"';
|
||||||
*else put ' ,' name ;
|
*else put ' ,' name ;
|
||||||
if last.indxname then do;
|
if last.indxname then do;
|
||||||
put ');';
|
put ');';
|
||||||
|
|||||||
Reference in New Issue
Block a user