
Such as this one date in the table corresponding to the four records, bitwise or, composed of a record in table 2, finally also can according to the new type of field, translate the original value of the corresponding type

Simple said is multiple records become a, to preserve the original information, how to implement? Or is there a better way? Under the ac
CodePudding user response:
Can't directly comma splice type field? Is feasible listagg (type, ', ') within group (order by 1) the from tt group by dateCodePudding user response:
Write is wrong, ignore the first floor,CodePudding user response:
SQL>
SQL> Create table test (id, type)
2 as
3 select 1, 2 from dual union all
4 select 2, 8 from dual union all
5 the select 3, 16 from dual union all
6 select 4, 32 from dual;
The Table created
SQL> The create or replace function bitor (p varchar2)
2 return number is
3 prev number:=0;
4 the result number;
5 the begin
6 for x in (select regexp_substr (p, '[^,] +' 1, level) + 0 value
7 the from dual
8 connect by rownum & lt;=regexp_count (p, ', ') + 1
9)
10 loop
Result: 11=(prev + x.v alue) - bitand (prev, x.v alue);
12 prev:=the result;
13 end loop;
14 the return result;
15 the end;
16/
The Function created
SQL> The select bitor (listagg (type, ', ') within group (order by id)) from the test.
BITOR (LISTAGG (TYPE, ', ') WITHING
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
58
SQL> The drop function bitor;
The Function dropped
SQL> Drop table test purge;
Table dropped
SQL>
CodePudding user response:
If the date out a certain type of the bitand off is neededCodePudding user response: