I need some help with defining a Function in postgreSQL:
here are my table definitions:
CREATE TABLE venue (
id INTEGER DEFAULT NEXTVAL('venue_id_seq')
, building_code building_code
, floorNo int
, roomNo int
, width int
, length int
);
I need to create a function related to that table that gives me the Floor area.Here is what I have so far:
CREATE FUNCTION floorArea(id int) RETURNS int AS '
SELECT venue.width * venue.length AS result ;
' LANGUAGE SQL;
I don't know how to possibly make variables etc.
I want something along the lines of:
var width= Select width from venue where id=$1;
var length= Select length from venue where id=$1;
return width * length;