Top "Plpgsql" questions

PL/pgSQL is the default procedural language for PostgreSQL.

Create a function declaring a predefined text array

I need to create a function in Postgres and one of the variables I declare is a predefined text array, …

arrays function postgresql plpgsql declare
Define table and column names as arguments in a plpgsql function?

It must be simple, but I'm making my first steps into Postgres functions and I can't find anything that works... …

function postgresql variables plpgsql dynamic-sql
INSERT with dynamic table name in trigger function

I'm not sure how to achieve something like the following: CREATE OR REPLACE FUNCTION fnJobQueueBEFORE() RETURNS trigger AS $$ DECLARE shadowname …

postgresql triggers dynamic-sql plpgsql
how to execute pgsql script in pgAdmin?

I want to execute some pgScript directly from the pgAdmin editor UI. FOR i IN 1..10 LOOP PRINT i; -- i …

postgresql plpgsql pgadmin
Test for null in function with varying parameters

I have a Postgres function: create function myfunction(integer, text, text, text, text, text, text) RETURNS table(id int, match …

postgresql null postgresql-9.1 plpgsql dynamic-sql
Passing column names dynamically for a record variable in PostgreSQL

Using PostgreSQL, column values from a table for 1st record are stored in a record variable. for ex: let the …

postgresql types plpgsql dynamic-sql hstore
DROP FUNCTION without knowing the number/type of parameters?

I keep all my functions in a text file with 'CREATE OR REPLACE FUNCTION somefunction'. So if I add or …

postgresql plpgsql dynamic-sql sql-drop
How to set value of composite variable field using dynamic SQL

Given this type: -- Just for testing purposes: CREATE TYPE testType as (name text) I can get the value of …

postgresql stored-procedures types composite plpgsql
Recursive function in postgres

How to map below query to postgres function. WITH RECURSIVE source (counter, product) AS ( SELECT 1, 1 UNION ALL SELECT counter + 1, product * (…

postgresql plpgsql postgresql-9.2 recursive-query
How to check if a row exists in a PostgreSQL stored procedure?

I writing a stored procedure in postgres where I need to check if a row exists then act accordingly. something …

postgresql stored-procedures plpgsql exists