unexpected results !

It makes you cry! It makes you claim you have found a bug! but it is working as specified! 1) subquery refers to a column of the main query select * from emp where ename in (select ename from dept where deptno=10); the query does not complain that column does not exist in dept. It […]

order by to_number ?

to_number is often subject to generate ORA-01722: invalid number. When I deal with integers, I prefer lpad. ex: sort pseudo-numeric select * from t order by lpad(col,20); 1 2 10 It performs well, and do not generate ora-01722. ora-01722 does not mean that I have bad data. select name,value from v$parameter where name like ‘%pool_size’ […]

shell + sqlplus

How to send commands to sqlplus ? Use stdin $ ( echo prompt $(hostname) $(date); echo desc emp ) | sqlplus -s scott/tiger dbsrv85a Mon Jun 6 17:01:46 CEST 2005 Name Null? Typ —- —– — EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) How […]


sys_connect_by_path is the only function provided by Oracle to get the the hierarchy path in one field, and it is only concatenating. I just found out a way of doing a sum of the path : let’s imagine I want the sum of the salary of all my hierarchy. select ename, sys_connect_by_path(ename,’/’) hierarchy, length(replace(sys_connect_by_path(lpad(‘ ‘,sal/10),’/’),’/’))*10 […]