错误:文件 XXXX 是连续的此任务需要以随机顺序读取观察结果,但引擎只允许顺序访问

问题描述

我正在尝试更新 oracle 表。

我在运行以下数据步骤时遇到此错误

data oracle.have(drop=_:);
    modify oracle.have end=last;
    if _n_=1 then do;
        declare hash h1(dataset:'_update');
        declare hiter hh1('h1');
        _rc = h1.defineKey('id','tid','valid_to');
        _rc = h1.defineData('valid_from');
        _rc = h1.defineDone();
    end;

    if h1.find()=0 then do;
        replace;
        _rc = h1.remove();
    end;
run;

错误文件 ORACLE.HAVE.DATA 是连续的。 此任务需要以随机顺序读取观察结果,但是 引擎只允许顺序访问。

有没有办法绕过这个错误

解决方法

显然,修改语句仅适用于 SAS 数据集。

我使用的解决方法如下:

proc sql;
update have t1
       set valid_from = (select valid_from from _update t2
                         where t1.id = t2.id
                            and t1.tid = t2.tid
                            and t1.valid_to = t2.valid_to
                            and t2.dim="FROM")
      where catx('#',id,tid,valid_to) in (select catx('#',valid_to)
                                            from _update t3
                                            where t3.dim="FROM");
quit;