fix(derived): guard the bitemporal cut-off, coalesce the selectbox seed

mpe_derived used &dc_dttmtfmt in its where= but the guard only checked libds and
dclib, so an unset value turned the filter into 'lt tx_to' and the control-table
step failed with a syntax error a long way from the cause.  It is now part of
the guard, named in the message.

The 7.19 migration took max(selectbox_rk) into a macro variable, which is
missing on an install whose MPE_SELECTBOX is still empty - %eval(&maxrk+1) then
fails.  coalesce(max(selectbox_rk),0) makes the first row start at 1.
This commit is contained in:
dc committed 2026-10-27 20:41:21 +00:00
1 parent 469229aecb
commit 7fb981daa9
2 files changed
+12 -4

No files matched your search

@@ -61,7 +61,9 @@ quit;
* further down, mirror the MPE_DERIVED rows in mpe_makedata.sas - keep the two
* in step, or an upgraded install and a freshly seeded one behave differently. */
proc sql noprint;
select max(selectbox_rk) into: maxrk from &dclib..mpe_selectbox;
/* coalesce: an install with no selectbox rows yet returns a missing value,
and %eval(&maxrk+1) below would then fail */
select coalesce(max(selectbox_rk),0) into: maxrk from &dclib..mpe_selectbox;
quit;
%let rk1=%eval(&maxrk+1);
+9 -3
View File
@@ -85,9 +85,12 @@
them whatever MPE_TABLES calls them */
%let reserved=%str(_____DELETE__THIS__RECORD_____);
%mp_abort(iftrue= (%length(&libds)=0 or %length(&dclib)=0)
/* dc_dttmtfmt is the bitemporal cut-off used in the where= below - callers get
it from %mpeinit(). Unset, the filter degenerates to "lt tx_to" and the
control-table step fails with a syntax error a long way from the cause. */
%mp_abort(iftrue= (%length(&libds)=0 or %length(&dclib)=0 or %length(&dc_dttmtfmt)=0)
,mac=&sysmacroname
,msg=%str(Missing: libds dclib)
,msg=%str(Missing: libds dclib dc_dttmtfmt)
)
/* A format catalog is addressed as LIBREF.CATALOGNAME-FC (the form
@@ -97,13 +100,16 @@
variable list and an empty statement file instead, and leave outview alone:
a caller only reads the view when the list is not empty. */
%if %length(&libds)>3 and "%upcase(%substr(&libds,%length(&libds)-2,3))"="-FC" %then %do;
/* the file has to exist even though it stays empty - callers %include it
unconditionally, and a fileref with no file behind it fails there */
%if &outref ne 0 %then %do;
filename &outref temp lrecl=32767;
data _null_;
file &outref;
run;
%end;
/* same idiom as the engine, so the dataset has the column and no rows */
/* the same shape the engine builds before it returns: one NAME column and no
rows, so a caller that reads NAME (all of them do) sees nothing */
data &outvars(keep=name);
length name $32;
name='';