mirror of
https://github.com/sasjs/core.git
synced 2026-07-23 15:35:29 +00:00
Merge pull request #429 from sasjs/mp_retainedkey
chore: adding new test to mp_retainedkey
This commit is contained in:
@@ -12184,7 +12184,8 @@ https://blogs.sas.com/content/sastraining/2012/08/14/jedi-sas-tricks-reset-sas-s
|
|||||||
%mp_abort(iftrue=(&iserr=1),mac=mp_retainedkey,msg=%superq(msg))
|
%mp_abort(iftrue=(&iserr=1),mac=mp_retainedkey,msg=%superq(msg))
|
||||||
|
|
||||||
proc sql noprint;
|
proc sql noprint;
|
||||||
select sum(max(&retained_key),0) into: maxkey from &base_libds;
|
select sum(max(&retained_key),0) format=32. into: maxkey trimmed
|
||||||
|
from &base_libds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get base table RK and bus field values for lookup
|
* get base table RK and bus field values for lookup
|
||||||
@@ -12253,19 +12254,19 @@ quit;
|
|||||||
insert into &maxkeytable
|
insert into &maxkeytable
|
||||||
set keytable="&base_libds"
|
set keytable="&base_libds"
|
||||||
,keycolumn="&retained_key"
|
,keycolumn="&retained_key"
|
||||||
,max_key=%eval(&maxkey+&newkey_cnt)
|
,max_key=%sysevalf(&maxkey+&newkey_cnt)
|
||||||
,processed_dttm="%sysfunc(datetime(),%mf_fmtdttm())"dt;
|
,processed_dttm="%sysfunc(datetime(),%mf_fmtdttm())"dt;
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
update &maxkeytable
|
update &maxkeytable
|
||||||
set max_key=%eval(&maxkey+&newkey_cnt)
|
set max_key=%sysevalf(&maxkey+&newkey_cnt)
|
||||||
,processed_dttm="%sysfunc(datetime(),%mf_fmtdttm())"dt
|
,processed_dttm="%sysfunc(datetime(),%mf_fmtdttm())"dt
|
||||||
where keytable="&base_libds";
|
where keytable="&base_libds";
|
||||||
%end;
|
%end;
|
||||||
%mp_lockanytable(UNLOCK
|
%mp_lockanytable(UNLOCK
|
||||||
,lib=%scan(&maxkeytable,1,.)
|
,lib=%scan(&maxkeytable,1,.)
|
||||||
,ds=%scan(&maxkeytable,2,.)
|
,ds=%scan(&maxkeytable,2,.)
|
||||||
,ref=Updating maxkeyvalues with maxkey=%eval(&maxkey+&newkey_cnt)
|
,ref=Updating maxkeyvalues with maxkey=%sysevalf(&maxkey+&newkey_cnt)
|
||||||
,ctl_ds=&locktable
|
,ctl_ds=&locktable
|
||||||
)
|
)
|
||||||
%end;
|
%end;
|
||||||
@@ -12273,7 +12274,7 @@ quit;
|
|||||||
/* fill in the missing retained key values */
|
/* fill in the missing retained key values */
|
||||||
%let tempvar=%mf_getuniquename();
|
%let tempvar=%mf_getuniquename();
|
||||||
data &outds(drop=&tempvar);
|
data &outds(drop=&tempvar);
|
||||||
retain &tempvar %eval(&maxkey+1);
|
retain &tempvar %sysevalf(&maxkey+1);
|
||||||
set &tempds2;
|
set &tempds2;
|
||||||
if &retained_key =. then &retained_key=&tempvar;
|
if &retained_key =. then &retained_key=&tempvar;
|
||||||
&tempvar=&tempvar+1;
|
&tempvar=&tempvar+1;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_assert.sas
|
@li mp_assert.sas
|
||||||
@li mp_assertcolvals.sas
|
@li mp_assertcolvals.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
@li mp_retainedkey.sas
|
@li mp_retainedkey.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@@ -127,6 +128,8 @@ data work.appendtable3;
|
|||||||
if _n_<7;
|
if _n_<7;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
|
||||||
%mp_retainedkey(
|
%mp_retainedkey(
|
||||||
base_lib=X
|
base_lib=X
|
||||||
,base_dsn=targetds3
|
,base_dsn=targetds3
|
||||||
@@ -140,6 +143,11 @@ run;
|
|||||||
,outds=work.APPEND3
|
,outds=work.APPEND3
|
||||||
,filter_str=
|
,filter_str=
|
||||||
)
|
)
|
||||||
|
|
||||||
|
%mp_assertscope(COMPARE,
|
||||||
|
desc=Checking macro scope leakage in mp_retainedkey (test 3)
|
||||||
|
)
|
||||||
|
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
iftrue=(&syscc=0),
|
iftrue=(&syscc=0),
|
||||||
desc=Checking errors in test 3 (large numeric RK),
|
desc=Checking errors in test 3 (large numeric RK),
|
||||||
|
|||||||
Reference in New Issue
Block a user