SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
declare gr number := 1; s varchar2 (32767); n number; r rowid; tot number := 0; fast number := 1; begin with a as ( select max(rowid) rid from tmp_test group by dbms_rowid.ROWID_BLOCK_NUMBER(rowid) ), b as ( select rid, rownum rn from a ) select rid into r from b where rn = gr; for x in 1 .. 1e1 loop s := 'select sum (%1) from tmp_test where rowid = :1 /*%2*/'; for c in 1 .. 20 loop if bitand (x, power (2, c-1)) > 0 or fast=1 then s := replace (s, '%1', 'n' || lpad(c, 2, '0') || '+%1'); end if; end loop; if instr(s, '+%1') > 0 then s := replace (s, '+%1'); if fast=1 then s := replace (s, '%2', gr); end if; --DBMS_OUTPUT.PUT_LINE(s); execute immediate s into n using r; tot := tot + n; end if; end loop; DBMS_OUTPUT.PUT_LINE(tot); -- 572966090 end; /
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear