1
0
mirror of https://github.com/sasjs/core.git synced 2025-12-11 06:24:35 +00:00

fix: ensuring upcase comparisons for dictionary tables

This commit is contained in:
Allan Bowe
2021-09-27 13:04:32 +01:00
parent a69db2ebfb
commit 6506993704
4 changed files with 28 additions and 28 deletions

28
all.sas
View File

@@ -3371,8 +3371,8 @@ run;
%let nvars=0; %let nvars=0;
proc sql noprint; proc sql noprint;
select count(*) into: nvars from dictionary.columns select count(*) into: nvars from dictionary.columns
where libname="%scan(%upcase(&base_ds),1)" where upcase(libname)="%scan(%upcase(&base_ds),1)"
and memname="%scan(%upcase(&base_ds),2)"; and upcase(memname)="%scan(%upcase(&base_ds),2)";
%if &nvars=0 %then %do; %if &nvars=0 %then %do;
%put %str(WARN)ING: Dataset &base_ds has no variables, will not be converted.; %put %str(WARN)ING: Dataset &base_ds has no variables, will not be converted.;
%return; %return;
@@ -3428,8 +3428,8 @@ proc sql
reset outobs=max; reset outobs=max;
create table datalines1 as create table datalines1 as
select name,type,length,varnum,format,label from dictionary.columns select name,type,length,varnum,format,label from dictionary.columns
where libname="%upcase(%scan(&base_ds,1))" where upcase(libname)="%upcase(%scan(&base_ds,1))"
and memname="%upcase(%scan(&base_ds,2))"; and upcase(memname)="%upcase(%scan(&base_ds,2))";
/** /**
Due to long decimals cannot use best. format Due to long decimals cannot use best. format
@@ -4412,21 +4412,21 @@ run;
/* must use SQL as proc datasets does not support length changes */ /* must use SQL as proc datasets does not support length changes */
proc sql noprint; proc sql noprint;
create table &outds as create table &outds as
select a.TABLE_CATALOG as libref select upcase(a.TABLE_CATALOG) as libref
,a.TABLE_NAME ,upcase(a.TABLE_NAME) as TABLE_NAME
,a.constraint_type ,a.constraint_type
,a.constraint_name ,a.constraint_name
,b.column_name ,b.column_name
from dictionary.TABLE_CONSTRAINTS a from dictionary.TABLE_CONSTRAINTS a
left join dictionary.constraint_column_usage b left join dictionary.constraint_column_usage b
on a.TABLE_CATALOG=b.TABLE_CATALOG on upcase(a.TABLE_CATALOG)=upcase(b.TABLE_CATALOG)
and a.TABLE_NAME=b.TABLE_NAME and upcase(a.TABLE_NAME)=upcase(b.TABLE_NAME)
and a.constraint_name=b.constraint_name and a.constraint_name=b.constraint_name
where a.TABLE_CATALOG="&lib" where upcase(a.TABLE_CATALOG)="&lib"
and b.TABLE_CATALOG="&lib" and upcase(b.TABLE_CATALOG)="&lib"
%if "&ds" ne "" %then %do; %if "&ds" ne "" %then %do;
and a.TABLE_NAME="&ds" and upcase(a.TABLE_NAME)="&ds"
and b.TABLE_NAME="&ds" and upcase(b.TABLE_NAME)="&ds"
%end; %end;
; ;
@@ -4977,7 +4977,7 @@ run;
proc sql noprint; proc sql noprint;
select sysvalue into: schemaactual select sysvalue into: schemaactual
from dictionary.libnames from dictionary.libnames
where libname="&libref" and engine='SQLSVR'; where upcase(libname)="&libref" and engine='SQLSVR';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref)); %let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
%do x=1 %to %sysfunc(countw(&dsnlist)); %do x=1 %to %sysfunc(countw(&dsnlist));
@@ -5070,7 +5070,7 @@ run;
proc sql noprint; proc sql noprint;
select sysvalue into: schemaactual select sysvalue into: schemaactual
from dictionary.libnames from dictionary.libnames
where libname="&libref" and engine='POSTGRES'; where upcase(libname)="&libref" and engine='POSTGRES';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref)); %let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
data _null_; data _null_;
file &fref mod; file &fref mod;

View File

@@ -58,8 +58,8 @@
%let nvars=0; %let nvars=0;
proc sql noprint; proc sql noprint;
select count(*) into: nvars from dictionary.columns select count(*) into: nvars from dictionary.columns
where libname="%scan(%upcase(&base_ds),1)" where upcase(libname)="%scan(%upcase(&base_ds),1)"
and memname="%scan(%upcase(&base_ds),2)"; and upcase(memname)="%scan(%upcase(&base_ds),2)";
%if &nvars=0 %then %do; %if &nvars=0 %then %do;
%put %str(WARN)ING: Dataset &base_ds has no variables, will not be converted.; %put %str(WARN)ING: Dataset &base_ds has no variables, will not be converted.;
%return; %return;
@@ -115,8 +115,8 @@ proc sql
reset outobs=max; reset outobs=max;
create table datalines1 as create table datalines1 as
select name,type,length,varnum,format,label from dictionary.columns select name,type,length,varnum,format,label from dictionary.columns
where libname="%upcase(%scan(&base_ds,1))" where upcase(libname)="%upcase(%scan(&base_ds,1))"
and memname="%upcase(%scan(&base_ds,2))"; and upcase(memname)="%upcase(%scan(&base_ds,2))";
/** /**
Due to long decimals cannot use best. format Due to long decimals cannot use best. format

View File

@@ -39,21 +39,21 @@
/* must use SQL as proc datasets does not support length changes */ /* must use SQL as proc datasets does not support length changes */
proc sql noprint; proc sql noprint;
create table &outds as create table &outds as
select a.TABLE_CATALOG as libref select upcase(a.TABLE_CATALOG) as libref
,a.TABLE_NAME ,upcase(a.TABLE_NAME) as TABLE_NAME
,a.constraint_type ,a.constraint_type
,a.constraint_name ,a.constraint_name
,b.column_name ,b.column_name
from dictionary.TABLE_CONSTRAINTS a from dictionary.TABLE_CONSTRAINTS a
left join dictionary.constraint_column_usage b left join dictionary.constraint_column_usage b
on a.TABLE_CATALOG=b.TABLE_CATALOG on upcase(a.TABLE_CATALOG)=upcase(b.TABLE_CATALOG)
and a.TABLE_NAME=b.TABLE_NAME and upcase(a.TABLE_NAME)=upcase(b.TABLE_NAME)
and a.constraint_name=b.constraint_name and a.constraint_name=b.constraint_name
where a.TABLE_CATALOG="&lib" where upcase(a.TABLE_CATALOG)="&lib"
and b.TABLE_CATALOG="&lib" and upcase(b.TABLE_CATALOG)="&lib"
%if "&ds" ne "" %then %do; %if "&ds" ne "" %then %do;
and a.TABLE_NAME="&ds" and upcase(a.TABLE_NAME)="&ds"
and b.TABLE_NAME="&ds" and upcase(b.TABLE_NAME)="&ds"
%end; %end;
; ;

View File

@@ -211,7 +211,7 @@ run;
proc sql noprint; proc sql noprint;
select sysvalue into: schemaactual select sysvalue into: schemaactual
from dictionary.libnames from dictionary.libnames
where libname="&libref" and engine='SQLSVR'; where upcase(libname)="&libref" and engine='SQLSVR';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref)); %let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
%do x=1 %to %sysfunc(countw(&dsnlist)); %do x=1 %to %sysfunc(countw(&dsnlist));
@@ -304,7 +304,7 @@ run;
proc sql noprint; proc sql noprint;
select sysvalue into: schemaactual select sysvalue into: schemaactual
from dictionary.libnames from dictionary.libnames
where libname="&libref" and engine='POSTGRES'; where upcase(libname)="&libref" and engine='POSTGRES';
%let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref)); %let schema=%sysfunc(coalescec(&schemaactual,&schema,&libref));
data _null_; data _null_;
file &fref mod; file &fref mod;