June 13, 2011

Pl/Sql program to check for department of employee,Replace string with your column name

Replace string with your column name 

 Replace '2011-06-20T00:00-04:00' with your column name.  
 SELECT SUBSTR('2011-06-20T00:00-04:00',1,INSTR('2011-06-20T00:00-04:00','T')-1)||' '||SUBSTR('2011-06-20T00:00-04:00',INSTR('2011-06-20T00:00-04:00','T')+1,LENGTH('2011-06-20T00:00-04:00'));  
Pl/Sql program to check for department of employee

 create or Replace Function valid_deptid  
 (tmp_deptid departments.Department_id%type)  
 Return Number  
 Rtn_Deptno number;  
 dbms_output.put_line('Inside Function');  
 select department_id into rtn_deptno from departments  
 where department_id=tmp_deptid;  
 if sql%FOUND then  
 dbms_output.put_line('Valid Deptno');  
 end if ;  
 return rtn_deptno;  
 when no_data_found then  
 dbms_output.put_line ( ' sorry incorrect departmentno' ) ;  
 return -- it will return the null. it's a good programming pratice --- to return the value frm function  
 end valid_deptid