Top "Plpgsql" questions

PL/pgSQL is the default procedural language for PostgreSQL.

PL/pgSQL: Can we store a query result into a variable

I'm trying to create a function in plpgsql like: CREATE OR REPLACE FUNCTION select_left_photo_ids(in_photo_id …

postgresql stored-procedures plpgsql select-into
Is SELECT or INSERT in a function prone to race conditions?

I wrote a function to create posts for a simple blogging engine: CREATE FUNCTION CreatePost(VARCHAR, TEXT, VARCHAR[]) RETURNS INTEGER …

sql postgresql concurrency plpgsql upsert
PostgreSQL PL/pgSQL random value from array of values

How can I declare an array like variable with two or three values and get them randomly during execution? a := [1, 2, 5] …

arrays postgresql random plpgsql postgresql-9.2
How to pass text parameter to stored function for `IN` operator

I need obtain table names from schema, except some tables CREATE OR REPLACE FUNCTION func(unnecessary_tables TEXT) returns void …

postgresql plpgsql postgresql-9.5
Disable DELETE on table in PostgreSQL?

For a security sensitive design, I'd like to disable DELETEs on certain tables. The DELETE should merely set a deleted …

postgresql triggers plpgsql sql-delete audit
How to use variables in "EXECUTE format()" in plpgsql

I want to update a column in table stats with the specific column being a parameter, then return the updated …

sql postgresql plpgsql dynamic-sql stored-functions
The forgotten assignment operator "=" and the commonplace ":="

The documentation for PL/pgSQL says, that declaration and assignment to variables is done with :=. But a simple, shorter and …

postgresql plpgsql assignment-operator colon-equals
How do I create a nested function in PL/pgSQL?

I would like to create a function in PL/pgSQL with a couple of nested (or inner) functions within it. …

postgresql scope plpgsql postgresql-9.5
Differences between ROWTYPE, TYPE, and RECORD in postgresql?

What is the use of the following declarations, and where will we use these types of declarations? myrow tablename%ROWTYPE; …

postgresql plpgsql rdbms sqldatatypes
Dynamic SELECT INTO in PL/pgSQL function

How can I write a dynamic SELECT INTO query inside a PL/pgSQL function in Postgres? Say I have a …

postgresql variable-assignment plpgsql dynamic-sql stored-functions