Lecture 13
Lecture 13
Database Management
Systems
Lecture 13
Hamza Shaukat
[email protected]
If the rows in the joined table do not match, the full outer join sets NULL
values for every column of the table that does not have the matching
row.If a row from one table matches a row in another table, the result
row will contain columns populated from columns of rows from both
tables.
Syntax: SELECT * FROM A
FULL [OUTER] JOIN B on A.id = B.id;
Department
Employees
DECLARE
/* Declarative section */
BEGIN
EXCEPTION
10
11
12
13
[ <<label>> ]
for loop_counter in [ reverse ] from.. to [ by
step ] loop
statements
end loop [ label ];
Example
$$
begin Output:
for counter in 1..5 loop
raise notice 'counter: %', counter; NOTICE: Counter: 1
end loop; NOTICE: Counter: 2
NOTICE: Counter: 3
end; $$
NOTICE: Counter: 4
NOTICE: Counter: 5
15
CALL DeleteAccounts(2);
16
if condition then
statements;
end if;
17
IF a < b THEN
RAISE NOTICE 'a is less than b';
END IF;
IF a = b THEN
RAISE NOTICE 'a is equal to b';
END IF;
END $$;
18
# genre_rec record;
# BEGIN
# loop
end loop;
$# END;
$$ ;
19
Write a procedure to insert data in the Employee name and raise a note when
inserted
21
22
23
Execution:
testdb=# select totalRecords();
24
Select get_car_Price(26000,70000);
26
Write a function to return an average value of the prople who’s deaprartment is between 30 to
90
27
Table 1
Table 2
28
29
30
SELECT select_list
FROM A
INTERSECT
SELECT select_list
FROM B;
31
32
SELECT select_list
FROM A
EXCEPT
SELECT select_list
FROM B;
33
34