类型:
CREATE TYPE equipment AS ENUM ('projector','PAsystem','safe','PC','phone');
CREATE TYPE building_code AS ENUM ('IT','EMS','HSB','ENG');
表:
CREATE TABLE venue (
id INTEGER DEFAULT NEXTVAL('venue_id_seq')
, building_code building_code
, floorNo int
, roomNo int
, width int
, length int
);
CREATE TABLE lecture_room (
id INTEGER DEFAULT NEXTVAL('lecture_id_seq')
, seatCount int
, equipment equipment[]
) INHERITS(venue);
功能:
CREATE or REPLACE FUNCTION hasProjector(_id int ) RETURNS boolean AS
$$
code to check if there exists a projector in the equipment array of lecture_room
$$ LANGUAGE SQL;
我不是 100% 确定要放入函数的 SQL 代码以及如何获得布尔值。