Tuesday, 22 May 2012

Explain why the following code generates a compilation error. | PL SQL

Declare
v_emp_joining date;
Begin
v_emp_joining := '1 April 1985';
End;

¦ The given code creates a compilation error because the v_empJoining variable is declared as the date datatype but has been  assigned a character value. To correct the code, you should use the conversion function, to_date, as follows:
 Declare
v_emp_joining date;
Begin
v_emp_joining := to_date('1 April1985', 'DD month yyyy');
End;