1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-18 22:10:06 +00:00

add authdomain for odbc connection

This commit is contained in:
Rud Faden
2023-10-17 13:13:03 +02:00
parent 592f477063
commit 0a24f3ff7b

View File

@@ -31,41 +31,41 @@
@version 9.2
@author Allan Bowe
**/
**/
%macro mm_assigndirectlib(
%macro mm_assigndirectlib(
libref
,open_passthrough=
,sql_options=
,mDebug=0
,mAbort=0
)/*/STORE SOURCE*/;
)/*/STORE SOURCE*/;
%local mD;
%if &mDebug=1 %then %let mD=;
%else %let mD=%str(*);
%&mD.put Executing mm_assigndirectlib.sas;
%&mD.put _local_;
%local mD;
%if &mDebug=1 %then %let mD=;
%else %let mD=%str(*);
%&mD.put Executing mm_assigndirectlib.sas;
%&mD.put _local_;
%if &mAbort=1 %then %let mAbort=;
%else %let mAbort=%str(*);
%if &mAbort=1 %then %let mAbort=;
%else %let mAbort=%str(*);
%&mD.put NOTE: Creating direct (non META) connection to &libref library;
%&mD.put NOTE: Creating direct (non META) connection to &libref library;
%local cur_engine;
%let cur_engine=%mf_getengine(&libref);
%if &cur_engine ne META and &cur_engine ne %then %do;
%local cur_engine;
%let cur_engine=%mf_getengine(&libref);
%if &cur_engine ne META and &cur_engine ne %then %do;
%put NOTE: &libref already has a direct (&cur_engine) libname connection;
%return;
%end;
%else %if %upcase(&libref)=WORK %then %do;
%end;
%else %if %upcase(&libref)=WORK %then %do;
%put NOTE: We already have a direct connection to WORK :-) ;
%return;
%end;
%end;
/* need to determine the library ENGINE first */
%local engine;
data _null_;
/* need to determine the library ENGINE first */
%local engine;
data _null_;
length lib_uri engine $256;
call missing (of _all_);
/* get URI for the particular library */
@@ -75,10 +75,10 @@ data _null_;
putlog "mm_assigndirectlib for &libref:" rc1= lib_uri= rc2= engine=;
call symputx("liburi",lib_uri,'l');
call symputx("engine",engine,'l');
run;
run;
/* now obtain engine specific connection details */
%if &engine=BASE %then %do;
/* now obtain engine specific connection details */
%if &engine=BASE %then %do;
%&mD.put NOTE: Retrieving BASE library path;
data _null_;
length up_uri $256 path cat_path $1024;
@@ -112,8 +112,8 @@ run;
libname &libref &filepath filelockwait=5;
%end;
%end;
%else %if &engine=REMOTE %then %do;
%end;
%else %if &engine=REMOTE %then %do;
data x;
length rcCon rcProp rc k 3 uriCon uriProp PropertyValue PropertyName
Delimiter $256 properties $2048;
@@ -143,9 +143,9 @@ run;
libname &libref &engine &properties slibref=&libref;
%end;
%end;
%else %if &engine=OLEDB %then %do;
%else %if &engine=OLEDB %then %do;
%&mD.put NOTE: Retrieving OLEDB connection details;
data _null_;
length domain datasource provider properties schema
@@ -208,11 +208,11 @@ run;
%end;
connection=shared;
%end;
%end;
%else %if &engine=ODBC %then %do;
%end;
%else %if &engine=ODBC %then %do;
&mD.%put NOTE: Retrieving ODBC connection details;
data _null_;
length connx_uri conprop_uri value datasource up_uri schema $256.;
length domprop_uri authdomain connx_uri conprop_uri value datasource up_uri schema $256.;
call missing (of _all_);
/* get source connection ID */
rc=metadata_getnasn("&liburi",'LibraryConnection',1,connx_uri);
@@ -226,11 +226,18 @@ run;
rc4=metadata_getattr(conprop_uri,'DefaultValue',datasource);
rc2=-1;
end;
end;
/* get auth domain */
autrc=metadata_getnasn(connx_uri,"Domain",1,domprop_uri);
arc=metadata_getattr(domprop_uri,"Name",authdomain);
call symputx('authdomain',authdomain,'l');
/* get SCHEMA */
rc6=metadata_getnasn("&liburi",'UsingPackages',1,up_uri);
rc7=metadata_getattr(up_uri,'SchemaName',schema);
&mD.put rc= connx_uri= rc2= conprop_uri= rc3= value= rc4= datasource=
&mD.put rc= connx_uri= rc2= conprop_uri= rc3= value= rc4= autrc= arc= datasource=
rc6= up_uri= rc7= schema=;
call symputx('SQL_schema',schema,'l');
@@ -243,10 +250,10 @@ run;
(INSERT_SQL=YES DATASRC=&sql_dsn. CONNECTION=global);
%end;
%else %do;
libname &libref ODBC DATASRC=&sql_dsn SCHEMA=&sql_schema;
libname &libref ODBC DATASRC=&sql_dsn SCHEMA=&sql_schema AUTHDOMAIN=&authdomain;
%end;
%end;
%else %if &engine=POSTGRES %then %do;
%end;
%else %if &engine=POSTGRES %then %do;
%put NOTE: Obtaining POSTGRES library details;
data _null_;
length database ignore_read_only_columns direct_exe preserve_col_names
@@ -344,8 +351,8 @@ run;
&preserve_col_names &preserve_tab_names &server &schema &authdomain
&user &password;
%end;
%end;
%else %if &engine=ORACLE %then %do;
%end;
%else %if &engine=ORACLE %then %do;
%put NOTE: Obtaining &engine library details;
data _null_;
length assocuri1 assocuri2 assocuri3 authdomain path schema $256;
@@ -372,8 +379,8 @@ run;
%put NOTE- authdomain=&authdomain;
%put NOTE-;
libname &libref ORACLE path=&path schema=&schema authdomain=&authdomain;
%end;
%else %if &engine=SQLSVR %then %do;
%end;
%else %if &engine=SQLSVR %then %do;
%put NOTE: Obtaining &engine library details;
data _null;
length assocuri1 assocuri2 assocuri3 authdomain path schema userid
@@ -404,8 +411,8 @@ run;
%put NOTE-;
libname &libref SQLSVR datasrc=&path schema=&schema user="&user" pass="&pass";
%end;
%else %if &engine=TERADATA %then %do;
%end;
%else %if &engine=TERADATA %then %do;
%put NOTE: Obtaining &engine library details;
data _null;
length assocuri1 assocuri2 assocuri3 authdomain path schema userid
@@ -444,18 +451,18 @@ run;
%put NOTE-;
libname &libref TERADATA server="&path" schema=&schema authdomain=&authdomain;
%end;
%else %if &engine= %then %do;
%end;
%else %if &engine= %then %do;
%put NOTE: Libref &libref is not registered in metadata;
%&mAbort.mp_abort(
msg=%str(ERR)OR: Libref &libref is not registered in metadata
,mac=mm_assigndirectlib.sas);
%return;
%end;
%else %do;
%end;
%else %do;
%put %str(WARN)ING: Engine &engine is currently unsupported;
%put %str(WARN)ING- Please contact your support team.;
%return;
%end;
%end;
%mend mm_assigndirectlib;
%mend mm_assigndirectlib;