SQL> --write an anonymous block that will print "big" is a number is greater than 100. SQL> set serveroutput on SQL> --the above statement is an sqlplus command that allows the package dbms_output to send the output to your screen SQL> --lets start with someting simple SQL> rem thýs ýs also a comment SQL> --print welcome rahila on screen SQL> begin 2 dbms_output.put_line('welcome to EMU Rahila'); 3 end; 4 5 6 / welcome to EMU Rahila PL/SQL procedure successfully completed. SQL> ed Wrote file afiedt.buf 1 begin 2 dbms_output.put_line('welcome to EMU Rahila'); 3* end; 4 / welcome to EMU Rahila PL/SQL procedure successfully completed. SQL> --what if i make a mistake typing and i want to get out of the edit mode SQL> begin 2 dbms_output.put_line('welcome to EMU Rahila'); 3 dfkjghdf 4 ed 5 ed 6 qwhdfkþajegblþsrjgHÝRY 7 / ed * ERROR at line 4: ORA-06550: line 4, column 1: PLS-00103: Encountered the symbol "ED" when expecting one of the following: := . ( @ % ; SQL> begin 2 dbms_output.put_line('welcome to EMU Rahila'); 3 dfkjghdf 4 ed 5 ed 6 qwhdfkþajegblþsrjgHÝRY 7 . SQL> begin 2 dbms_output.put_line('welcome to EMU Rahila'); 3 end; 4 / welcome to EMU Rahila PL/SQL procedure successfully completed. SQL> --modify the program to read a n ame from keybopard SQL> ed Wrote file afiedt.buf 1 declare 2 yourname char2(10); 3 begin 4 yourname := 'Rahila'; 5 dbms_output.put_line('welcome to EMU ',yourname); 6* end; SQL> / yourname char2(10); * ERROR at line 2: ORA-06550: line 2, column 11: PLS-00201: identifier 'CHAR2' must be declared ORA-06550: line 2, column 11: PL/SQL: Item ignored ORA-06550: line 4, column 2: PLS-00320: the declaration of the type of this expression is incomplete or malformed ORA-06550: line 4, column 2: PL/SQL: Statement ignored ORA-06550: line 5, column 41: PLS-00320: the declaration of the type of this expression is incomplete or malformed ORA-06550: line 5, column 2: PL/SQL: Statement ignored SQL> ed Wrote file afiedt.buf 1 declare 2 yourname varchar2(10); 3 begin 4 yourname := 'Rahila'; 5 dbms_output.put_line('welcome to EMU ',yourname); 6* end; SQL> / dbms_output.put_line('welcome to EMU ',yourname); * ERROR at line 5: ORA-06550: line 5, column 2: PLS-00306: wrong number or types of arguments in call to 'PUT_LINE' ORA-06550: line 5, column 2: PL/SQL: Statement ignored SQL> --put_lýne accepts only 1 (strýng) argument SQL> ed Wrote file afiedt.buf 1 declare 2 yourname varchar2(10); 3 begin 4 yourname := 'Rahila'; 5 dbms_output.put_line('welcome to EMU '||yourname); 6* end; SQL> / welcome to EMU Rahila PL/SQL procedure successfully completed. SQL> SQL> / welcome to EMU Rahila PL/SQL procedure successfully completed. SQL> ed Wrote file afiedt.buf 1 declare 2 yourname varchar2(10); 3 begin 4 yourname := &aname; 5 dbms_output.put_line('welcome to EMU '||yourname); 6* end; SQL> / Enter value for aname: 'ayse' old 4: yourname := &aname; new 4: yourname := 'ayse'; welcome to EMU ayse PL/SQL procedure successfully completed. SQL> -ýn the above example &aname is called a substitution variable SP2-0734: unknown command beginning "-ýn the ab..." - rest of line ignored. SQL> --it is used to get a value from keyboard. SQL> list 1 declare 2 yourname varchar2(10); 3 begin 4 yourname := &aname; 5 dbms_output.put_line('welcome to EMU '||yourname); 6* end; SQL> / Enter value for aname: fuatcan old 4: yourname := &aname; new 4: yourname := fuatcan; yourname := fuatcan; * ERROR at line 4: ORA-06550: line 4, column 14: PLS-00201: identifier 'FUATCAN' must be declared ORA-06550: line 4, column 2: PL/SQL: Statement ignored SQL> / Enter value for aname: 'fuatcan' old 4: yourname := &aname; new 4: yourname := 'fuatcan'; welcome to EMU fuatcan PL/SQL procedure successfully completed. SQL> ed Wrote file afiedt.buf 1 declare 2 yourname varchar2(10); 3 begin 4 yourname := '&aname'; 5 dbms_output.put_line('welcome to EMU '||yourname); 6* end; SQL> / Enter value for aname: fuatcan old 4: yourname := '&aname'; new 4: yourname := 'fuatcan'; welcome to EMU fuatcan PL/SQL procedure successfully completed. SQL> --write an anonymous block that will print "big" is a number is greater than 100. SQL> --read the number from keyboard SQL> ed Wrote file afiedt.buf 1 declare 2 x number; 3 begin 4 x := &a_number; 5 if x > 100 then 6 dbms_output.put_line('big'); 7 end if; 8* end; SQL> r 1 declare 2 x number; 3 begin 4 x := &a_number; 5 if x > 100 then 6 dbms_output.put_line('big'); 7 end if; 8* end; Enter value for a_number: 3 old 4: x := &a_number; new 4: x := 3; PL/SQL procedure successfully completed. SQL> / Enter value for a_number: 120 old 4: x := &a_number; new 4: x := 120; big PL/SQL procedure successfully completed. SQL> --write an anonymous block that will print "big" if a number is greater than 100. and small otherwise SQL> ed Wrote file afiedt.buf 1 declare 2 x number; 3 begin 4 x := &a_number; 5 if x > 100 then 6 dbms_output.put_line('big'); 7 else 8 dbms_output.put_line('small'); 9 end if; 10* end; SQL> / Enter value for a_number: 154 old 4: x := &a_number; new 4: x := 154; big PL/SQL procedure successfully completed. SQL> / Enter value for a_number: 5 old 4: x := &a_number; new 4: x := 5; small PL/SQL procedure successfully completed. SQL> / Enter value for a_number: 100 old 4: x := &a_number; new 4: x := 100; small PL/SQL procedure successfully completed. SQL> --modify the program to print big if the number is greater than 100 SQL> --small if it is equal to 0 or above but less than or equal to 100 SQL> -- and negative otherwise SQL> ed Wrote file afiedt.buf 1 declare 2 x number; 3 begin 4 x := &a_number; 5 if x > 100 then 6 dbms_output.put_line('big'); 7 elsif x>=0 then 8 dbms_output.put_line('small'); 9 else 10 dbms_output.put_line('negative'); 11 end if; 12* end; 13 / Enter value for a_number: 150 old 4: x := &a_number; new 4: x := 150; big PL/SQL procedure successfully completed. SQL> / Enter value for a_number: 80 old 4: x := &a_number; new 4: x := 80; small PL/SQL procedure successfully completed. SQL> / Enter value for a_number: -5 old 4: x := &a_number; new 4: x := -5; negative PL/SQL procedure successfully completed. SQL> ed Wrote file afiedt.buf 1 declare 2 x number; 3 begin 4 x := &a_number; 5 if x > 100 then 6 dbms_output.put_line('big'); 7 elsif x>=0 then 8 dbms_output.put_line('small'); 9 else 10 dbms_output.put_line('negative'); 11 end if; 12* end; SQL> spool off