January 2019
Beginner
556 pages
14h 19m
English
PL/pgSQL can be used to return a single row from a function; an example of this type is the factorial function.
The RETURN type can be a base, composite, domain, pseudo, or domain data type. The following function returns a JSON representation of a certain account:
-- in sql CREATE OR REPLACE FUNCTION car_portal_app.get_account_in_json (account_id INT) RETURNS JSON AS $$ SELECT row_to_json(account) FROM car_portal_app.account WHERE account_id = $1;$$ LANGUAGE SQL;--- in plpgsql CREATE OR REPLACE FUNCTION car_portal_app.get_account_in_json1 (acc_id INT) RETURNS JSON AS $$BEGIN RETURN (SELECT ...
Read now
Unlock full access