sasjs / core

Macros for SAS® App Developers
https://core.sasjs.io
MIT License
119 stars 17 forks source link

bug in mp_lockanytable.sas #339

Closed allanbowe closed 1 year ago

allanbowe commented 1 year ago

The bug is in the first proc sql noprint; part below:

%else %if &ACTION=UNLOCK %then %do;
  %local status;
  proc sql noprint;
  select LOCK_STATUS_CD into: status from &ctl_ds
    where LOCK_LIB ="&lib" and LOCK_DS="&ds";
  quit;
  %if &syscc>0 %then %put syscc=&syscc sqlrc=&sqlrc;
  %if &sqlobs=0 %then %do;
    %put %str(WAR)NING: &lib..&ds has never been locked!;
  %end;
  %else %if &status=LOCKED %then %do;
    data _null_;
      putlog "&sysmacroname: unlocking &lib..&ds:";
    run;
    proc sql;
    update &ctl_ds
      set LOCK_STATUS_CD='UNLOCKED'
        , LOCK_END_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt
        , LOCK_USER_NM="&user"
        , LOCK_PID="&sysjobid"
        , LOCK_REF="&ref"
      where LOCK_LIB ="&lib" and LOCK_DS="&ds";
    quit;
  %end;
  %else %if &status=UNLOCKED %then %do;
    %put %str(WAR)NING: &lib..&ds is already unlocked!;
  %end;
  %else %do;
    %put NOTE: Unrecognised STATUS_CD (&status) in &ctl_ds;
    %let abortme=1;
  %end;
%end;

I suspect that the noprint option is suppressing the value of sqlobs when no rows are returned.

Can be easily fixed by doing an actual query instead. Log below (redacted):

</font>MP_LOCKANYTABLE entry vars:
ACTION =UNLOCK
CTL_DS =DCxxxx.mpe_lockanytable
DS =xxxx
LIB =xxxx
LOOPS =25
LOOP_SECS =1
REF =xxxx
<font color=blue>NOTE: There were 7 observations read from the data set SASHELP.VMACRO.
      WHERE scope='MP_LOCKANYTABLE';
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

NOTE: No rows were selected.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

NOTE: Unrecognised STATUS_CD () in DCxxxx.mpe_lockanytable
NOTE: ///  mp_abort macro executing //

System: Linux Version: 9.04.01M7P080520

sasjsbot commented 1 year ago

:tada: This issue has been resolved in version 4.46.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: