For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Hi there, I have the following problem since version 21.X. I have a procedure / function which I export with XY. Procedure: If I export and import this with a SQLCL version 21.x, the last line is always shifted directly behind the previous one. -> Version sqlcl_21.4.1 lb genschema -grants File: lb update -changelog controller.xml Result on the Database: In this case it is ugly but valid. But what about types? The object becomes invalid. The problem did not exist in older versions. So I'm assuming it's a bug and I hope it gets fixed.
best regards Thomas
HR%xe> select department_id 2 , ltrim(max(sys_connect_by_path(last_name, ' ' )), ' ') scbp 3 from ( select department_id 4 , to_clob(last_name) last_name 5 , row_number() over (partition by department_id order by last_name) rn 6 from employees 7 ) 8 start with rn = 1 9 connect by prior rn=rn-1 10 and prior department_id = department_id 11 group by department_id 12 order by department_id; from employees * FOUT in regel 6: .ORA-30004: when using SYS_CONNECT_BY_PATH function, cannot have seperator as part of column value HR%xe> select department_id 2 , ltrim(max(sys_connect_by_path(last_name, ',' )), ',') scbp 3 from ( select department_id 4 , to_clob(last_name) last_name 5 , row_number() over (partition by department_id order by last_name) rn 6 from employees 7 ) 8 start with rn = 1 9 connect by prior rn=rn-1 10 and prior department_id = department_id 11 group by department_id 12 order by department_id; DEPARTMENT_ID SCBP ------------- -------------------------------------------------- 10 Whalen 20 Fay,Hartstein 30 Baida,Colmenares,Himuro,Khoo,Raphaely,Tobias 40 Mavris 50 Atkinson,Bell,Bissot,Bull,Cabrio,Chung,Davies,Dell inger,Dilly,Everett,Feeney,Fleaur,Fripp,Gates,Gee, Geoni,Grant,Jones,Kaufling,Ladwig,Landry,Mallin,Ma rkle,Marlow,Matos,McCain,Mikkilineni,Mourgos,Nayer ,OConnell,Olson,Patel,Perkins,Philtanker,Rajs,Roge rs,Sarchand,Seo,Stiles,Sullivan,Taylor,Vargas,Voll man,Walsh,Weiss 60 Austin,Ernst,Hunold,Lorentz,Pataballa 70 Baer 80 Abel,Ande,Banda,Bates,Bernstein,Bloom,Cambrault,Ca mbrault,Doran,Errazuriz,Fox,Greene,Hall,Hutton,Joh nson,King,Kumar,Lee,Livingston,Marvins,McEwen,Olse n,Ozer,Partners,Russell,Sewall,Smith,Smith,Sully,T aylor,Tucker,Tuvault,Vishney,Zlotkey 90 De Haan,King,Kochhar 100 Chen,Faviet,Greenberg,Popp,Sciarra,Urman 110 Gietz,Higgins Grant 12 rijen zijn geselecteerd. HR%xe>
HR%xe> select department_id 2 , ltrim(max(sys_connect_by_path(last_name, ',' )), ',') scbp 3 from ( select department_id 4 , to_clob(rpad(last_name, 5000, '*')) last_name 5 , row_number() over (partition by department_id order by last_name) rn 6 from employees 7 ) 8 start with rn = 1 9 connect by prior rn=rn-1 10 and prior department_id = department_id 11 group by department_id 12 order by department_id; from employees * FOUT in regel 6: .ORA-01489: result of string concatenation is too long
VARIABLE n NUMBER EXEC :n := 2; WITH got_rnum AS ( SELECT deptno , ename , ROW_NUMBER () OVER ( PARTITION BY deptno ORDER BY ename ) AS rnum FROM scott.emp ) , got_short_path AS ( SELECT deptno , CEIL (rnum / :n) AS n_num , SYS_CONNECT_BY_PATH (ename, ',') AS short_path FROM got_rnum WHERE CONNECT_BY_ISLEAF = 1 START WITH MOD (rnum, :n) = 1 CONNECT BY rnum = PRIOR rnum + 1 AND deptno = PRIOR deptno AND MOD (rnum, :n) != 1 ) SELECT deptno , TO_CLOB (MAX (CASE WHEN n_num = 1 THEN short_path END)) || TO_CLOB (MAX (CASE WHEN n_num = 2 THEN short_path END)) || TO_CLOB (MAX (CASE WHEN n_num = 3 THEN short_path END)) || TO_CLOB (MAX (CASE WHEN n_num = 4 THEN short_path END)) || TO_CLOB (MAX (CASE WHEN n_num = 5 THEN short_path END)) AS path FROM got_short_path GROUP BY deptno;
CREATE OR REPLACE PACKAGE Hierarchy IS TYPE BranchTableVarchar2Type IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER; BranchTableVarchar2 BranchTableVarchar2Type; TYPE BranchTableClobType IS TABLE OF CLOB INDEX BY BINARY_INTEGER; BranchTableClob BranchTableClobType; FUNCTION Branch( p_Level IN NUMBER, p_Value IN VARCHAR2, p_Delimiter IN VARCHAR2 DEFAULT CHR(0) ) RETURN VARCHAR2; PRAGMA RESTRICT_REFERENCES(Branch,WNDS); FUNCTION Branch( p_Level IN NUMBER, p_Value IN CLOB, p_Delimiter IN VARCHAR2 DEFAULT CHR(0) ) RETURN CLOB; PRAGMA RESTRICT_REFERENCES(Branch,WNDS); END Hierarchy; / CREATE OR REPLACE PACKAGE BODY Hierarchy IS ReturnValueVarchar2 VARCHAR2(4000); ReturnValueClob CLOB; FUNCTION Branch( p_Level IN NUMBER, p_Value IN VARCHAR2, p_Delimiter IN VARCHAR2 DEFAULT CHR(0) ) RETURN VARCHAR2 IS BEGIN BranchTableVarchar2(p_Level) := p_Value; ReturnValueVarchar2 := p_Value; FOR I IN REVERSE 1..p_Level - 1 LOOP ReturnValueVarchar2 := BranchTableVarchar2(I)|| p_Delimiter || ReturnValueVarchar2; END LOOP; RETURN ReturnValueVarchar2; END Branch; FUNCTION Branch( p_Level IN NUMBER, p_Value IN CLOB, p_Delimiter IN VARCHAR2 DEFAULT CHR(0) ) RETURN CLOB IS BEGIN BranchTableClob(p_Level) := p_Value; ReturnValueClob := p_Value; FOR I IN REVERSE 1..p_Level - 1 LOOP ReturnValueClob := BranchTableClob(I)|| p_Delimiter || ReturnValueClob; END LOOP; RETURN ReturnValueClob; END Branch; END Hierarchy; /
SQL> select sys_connect_by_path(ename,',') ename 2 from ( 3 select to_clob(rpad(ename,1000,'*')) ename, 4 empno, 5 mgr 6 from emp 7 ) 8 where connect_by_isleaf = 1 9 and rownum = 1 10 start with mgr is null 11 connect by mgr = prior empno 12 / from emp * ERROR at line 6: ORA-01489: result of string concatenation is too long SQL> set long 10000 SQL> select hierarchy.branch(level,ename,',') ename 2 from ( 3 select to_clob(rpad(ename,1000,'*')) ename, 4 empno, 5 mgr 6 from emp 7 ) 8 where connect_by_isleaf = 1 9 and rownum = 1 10 start with mgr is null 11 connect by mgr = prior empno 12 / ENAME -------------------------------------------------------------------------------- KING**************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ENAME -------------------------------------------------------------------------------- ******************************************************************************** ****************************************,CLARK********************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ENAME -------------------------------------------------------------------------------- ******************************************************************************** ******************************************************************************** ******************************************************************************** *,FORD************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ENAME -------------------------------------------------------------------------------- ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************,ADAMS******************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ENAME -------------------------------------------------------------------------------- ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** *** SQL>
ENAME - 1 rows returned in 0,00 seconds
set long 10000
SELECT deptno , ename FROM scott.emp WHERE ROWNUM <= 5;
GRANT SELECT ON scott.emp TO PUBLIC;
SQL> create table emp1 as select to_clob(ename) ename_clob,deptno from emp 2 / Table created. SQL> select deptno,max(ename_clob) from emp1 group by deptno 2 / select deptno,max(ename_clob) from emp1 group by deptno * ERROR at line 1: ORA-00932: inconsistent datatypes: expected - got CLOB SQL>
select deptno, scbp from ( select deptno, hierarchy.branch(level,ename_clob,' ' ) scbp, rn, cnt from ( select deptno, to_clob(ename) ename_clob, row_number() over(partition by deptno order by ename) rn, count(*) over(partition by deptno) cnt from emp ) start with rn = 1 connect by prior rn = rn - 1 and prior deptno = deptno ) where rn = cnt order by deptno / DEPTNO SCBP ---------- -------------------------------------------------------------------------------- 10 CLARK KING MILLER 20 ADAMS FORD JONES SCOTT SMITH 30 ALLEN BLAKE JAMES MARTIN TURNER WARD SQL>