Top "Plpgsql" questions

PL/pgSQL is the default procedural language for PostgreSQL.

PostgreSQL - RETURNING INTO array

I want to store an update's RETURNING values into a data structure so that I can use it in a …

function postgresql plpgsql sql-returning
How to copy structure of one table to another with foreign key constraints in psql?

Foreign key constraints are not copied when using create table table_name ( like source_table INCLUDING ALL)' in Postgres. …

postgresql foreign-keys plpgsql create-table
Format specifier for integer variables in format() for EXECUTE?

CREATE OR REPLACE FUNCTION getParentLtree(parent_id bigint, tbl_name varchar) RETURNS ltree AS $BODY$ DECLARE parent_ltree ltree; BEGIN …

postgresql plpgsql dynamic-sql string-concatenation
Analysing/Profiling queries on PostgreSQL

I've just inherited an old PostgreSQL installation and need to do some diagnostics to find out why this database is …

sql postgresql plpgsql postgresql-8.4
Postgres 9.2 PL/pgSQL simple update in loop

I have a following table: +----+----------+----------+ | id | trail_id | position | +----+----------+----------+ | 11 | 16 | NULL | | 12 | 121 | NULL | | 15 | 121 | NULL | | 19 | 42 | NULL | | 20 | 42 | NULL | | 21 | 42 | …

sql postgresql plpgsql postgresql-9.2
Execute multiple functions together without losing performance

I have this process that has to make a series of queries, using pl/pgsql: --process: SELECT function1(); SELECT function2(); …

postgresql plpgsql database-performance query-performance postgresql-performance
How to use variable settings in trigger functions?

I would like to record the id of a user in the session/transaction, using SET, so I could be …

postgresql global-variables plpgsql postgresql-triggers
"ERROR: invalid transaction termination" when trying to execute a procedure with nested transaction control

According to the documentation (https://www.postgresql.org/docs/current/app-psql.html), even with AUTOCOMMIT set to off, PSQL issues …

postgresql transactions plpgsql commit postgresql-11
Inserting DEFAULT value into a column when a parameter is NULL

I would like to write a stored procedure like this: CREATE OR REPLACE FUNCTION my_function(param_1 text, param_2 text …

postgresql stored-procedures plpgsql postgresql-9.4
Postgres Function to insert multiple records in two tables

create table public.orders ( orderID serial PRIMARY KEY, orderdate timestamp NOT NULL ); create table public.orderdetails ( orderdetailID serial PRIMARY KEY, …

sql database postgresql plpgsql postgresql-9.4