====== PostgreSQL Store ====== Se puede crear un store de dos formas, usando SQL o usando PL/PgSQL * [[https://share.google/aimode/uINzEoneLAG3PFq8K]] * [[https://dev.to/hyperkai/do-statement-in-postgresql-533p]] * [[https://docs.oracle.com/en/database/other-databases/timesten/22.1/plsql-developer/pl-sql-packages.html#GUID-CD17C443-9122-4419-9A80-9F35A955E9B4]] * [[https://www.geeksforgeeks.org/postgresql/postgresql-if-statement/]] Los stores en postgres es reciente antes lo tenĂ­a que programar en function * [[https://www.postgresql.org/docs/current/sql-createfunction.html]] * [[https://www.pgtutorial.com/plpgsql/plpgsql-if/]] Ejemplo de bloque de codigo con DO DO $$ DECLARE -- Declare variables with initial values counter INTEGER := 1; first_name VARCHAR(50) DEFAULT 'John'; payment NUMERIC(11, 2) = 20.5; -- Declare a constant user_id CONSTANT INTEGER := 10; -- Declare a variable based on a table column's type film_title film.title%TYPE; BEGIN -- Assign a value from a query result SELECT title INTO film_title FROM film WHERE film_id = user_id; -- Output the variable values (for demonstration purposes, like in pgAdmin's Messages window) RAISE NOTICE '% % % has been paid % USD, Film title: %', counter, first_name, payment, film_title; -- The following line would cause an error because user_id is a CONSTANT -- user_id := 12; END $$;