--this is a single line comments
/* this is a multi
lines comments
*/
declare
v_first_name employees.first_name%type;
v_last_name employees.last_name%type;
v_sal number;
"hire date" date; --this is not recommended from oracle
begin
select first_name, last_name, salary,hire_date
into v_first_name,v_last_name,v_sal,"hire date"
from employees
where employee_id=100;
dbms_output.put_line('the employee first name is '||v_first_name ) ;
dbms_output.put_line('the employee last name is '||v_last_name ) ;
dbms_output.put_line('the employee salary is '||v_sal ) ;
dbms_output.put_line('the employee hire date is '||"hire date" );
dbms_output.put_line('the employee first name lenght is '||length(v_first_name) ) ;
dbms_output.put_line('the first 3 letters of first name is '||substr(v_first_name,1,3) );
end;
---------------------------------
declare
v_date date:=sysdate;
v_sal number:=5000;
begin
dbms_output.put_line(v_date);
dbms_output.put_line(v_date+8);
dbms_output.put_line(v_date-3);
dbms_output.put_line(to_char(v_date,'dd-mm-yyyy hh:mi:ss am') );
dbms_output.put_line(add_months(v_date,2) );
dbms_output.put_line(to_char(v_sal,'$999,999' ) );
end;
----------------------------------------------------------------------------------------------------------------------------
declare
v_global varchar2(100):='this is a global variable';
begin
declare
v_local varchar2(100):='this is a local variable';
begin
dbms_output.put_line(v_global);
dbms_output.put_line(v_local);
end;
dbms_output.put_line(v_global);
---dbms_output.put_line(v_local); you can not do this
end;
----------------------------------------------------------
declare
v_father_name varchar2(100):='khaled';
v_birthday date:='20-Jul-1981';
begin
declare
v_child varchar2(100):='Layal';
v_birthday date:='5-Apr-2013';
begin
dbms_output.put_line('the father name is ' ||v_father_name);
dbms_output.put_line('the father birthday is '||v_birthday);
dbms_output.put_line('the child name is '||v_child);
dbms_output.put_line('the child birthday is '||v_birthday);
end;
end;
-----------------------------------------------------------
begin <<outer>>
declare
v_father_name varchar2(100):='khaled';
v_birthday date:='26-Jul-1981';
begin
declare
v_child varchar2(100):='Layal';
v_birthday date:='5-Apr-2013';
begin
dbms_output.put_line('the father name is ' ||v_father_name);
dbms_output.put_line('the father birthday is '||outer.v_birthday);
dbms_output.put_line('the child name is '||v_child);
dbms_output.put_line('the child birthday is '||v_birthday);
end;
end;
end outer;
No comments:
Post a Comment