Top "Plpgsql" questions

PL/pgSQL is the default procedural language for PostgreSQL.

Postgres trigger after insert accessing NEW

I have a pretty simple trigger: CREATE OR REPLACE FUNCTION f_log_datei() RETURNS TRIGGER AS $$ BEGIN INSERT INTO logs (…

sql postgresql triggers plpgsql
Deadlock detected in PL/pgSQL function

I am facing a deadlock problem from a PL/pgSQL function in my PostgreSQL database. Please find the SQL statement …

postgresql concurrency deadlock plpgsql
Raising error in postgreSQL

CREATE OR REPLACE FUNCTION msgfailerror() RETURNS trigger AS ' BEGIN IF NEW.noces< new.first_column THEN RAISE EXCEPTION …

postgresql plpgsql quoting
PostgreSQL - Writing dynamic sql in stored procedure that returns a result set

How can I write a stored procedure that contains a dynamically built SQL statement that returns a result set? Here …

postgresql resultset plpgsql execute dynamic-sql
How to create sequence if not exists

I tried to use code from Check if sequence exists in Postgres (plpgsql). To create sequence if it does not …

sql postgresql database-design plpgsql postgresql-9.2
How to use a record type variable in plpgsql?

How can I use query result stored into a record type variable for another query within the same stored function? …

postgresql function variables plpgsql table-variable
Function to loop through and select data from multiple tables

I'm new to Postgres and have a database with multiple tables of the same structure. I need to select data …

postgresql for-loop plpgsql dynamic-sql set-returning-functions
Variable containing the number of rows affected by previous DELETE? (in a function)

I have a function that is used as an INSERT trigger. This function deletes rows that would conflict with [the …

postgresql triggers plpgsql
How to write function for optional parameters in postgresql?

My requirement is write optional parameters to a function.Parameters are optional sometimes i will add or i will not …

sql postgresql plpgsql
PostgreSQL: How to DROP FUNCTION IF EXISTS without specifying parameters?

I can successfully create a function as follows: CREATE FUNCTION Foo(MY_Value INT) RETURNS INT AS 'SELECT 2 + MY_Value' …

postgresql plpgsql