Collected posts: Oracle, SQL, PL/SQL, Performance, Security...(More than 300 blogs)

jeudi 14 juillet 2022

ORACLE PIVOT FUNCTION & ORA-00918

First we create a view v_emp

create or replace view scott.v_emp as
select a.empno,a.sal,b.dname from scott.emp a, scott.dept b
where a.deptno=b.deptno;


Case One:



We get this error because we are pivoting multiple columns without giving alias for each column, we should give alias at least for one column.




Case Two:



In the second case, we still get the same error even if we have added an alias of at least of one of pivoted column.




The length of the name of the last department was 28 , Oracle reconstruct the name for column name as below : 'name_of_department'_NAME_OF_PIVOTING_COLUMN' ==> This gives  
'S013456789013456789013456789'_SAL; it length is 34 . This will be truncated and get 'S013456789013456789013456789'_ with length 30 characters.

The max size of column is 30 characters.

Now try with department_name =S013456789013456789013456788












Aucun commentaire:

Enregistrer un commentaire