Chapter2 - Example Exercise
Chapter2 - Example Exercise
1) This is the example how can you use both bind variables that you declare
BEFORE the block and regular scalar ones that you declare within the block.
You can print bind variables outside the block with the PRINT command.
SET SERVEROUTPUT ON
DECLARE
today DATE := SYSDATE;
tomorrow today%TYPE;
BEGIN
:basic_percent := 45
:calc := :basic_percent/3;
Hello World
TODAY IS : 14-SEP-09
TOMORROW IS : 15-SEP-09
PL/SQL procedure successfully completed.
BASIC_PERCENT
45
CALC
15
2) Let’s display the exact date and time of this moment and then the same in 18
hours. The scale for time components should be set to miliseconds.
SET SERVEROUTPUT ON
DECLARE
v_tomorrow v_datetime%TYPE;
BEGIN
END;
3) Lets’ find out when will be your approximate graduation month, assuming you
need exactly 1 year and 3 months more. Exclude fractions of seconds from the output
and use this Date Format for today Sep 14, 2009
SET SERVEROUTPUT ON
DECLARE
v_grad TIMESTAMP(0) ;
BEGIN
END;
SET SERVEROUTPUT ON
SET VERIFY OFF -- this will turn off display of OLD and NEW values
DECLARE
v_fname VARCHAR2(20) ;
v_lname employees.last_name%TYPE ;
BEGIN
FROM employees
END;