Lab #11 Worksheet β Views, Procedural SQL
Views are virtual tables. Users have access to specified portions of data: increased privacy and data security. Views are dynamically updated when updates/inserts/deletes are made to the base tables.
Syntax:
CREATE VIEW ViewName AS SelectStatement;
CREATE VIEW vwProduct AS
SELECT productCode, description, price
FROM Product
WHERE price >= 100.00;
SELECT * FROM vwProduct;
SQL has some shortcomings; it doesnβt support some important programming constructs such as functions, conditional execution (if ... then), loops, variables...
Procedural SQL (PL/PGSQL) is an extension of SQL that provides procedural constructs that can be used to implement logic around standard SQL statements. The procedural code is executed by the DBMS when it is invoked (directly or indirectly) by the end user. Procedural SQL can be used to create stored procedures, functions, and triggers, that can use variables, loops, if statements, cursors...
A stored procedure is a named collection (block) of procedural and SQL statements held by the DBMS. A stored procedure is invoked by name and executed as a unit.
Syntax