Top "Plpgsql" questions

PL/pgSQL is the default procedural language for PostgreSQL.

PL/pgSQL functions: How to return a normal table with multiple columns using an execute statement

I've got this PL/pgSQL function which must return some users information. CREATE OR REPLACE FUNCTION my_function( user_id …

postgresql function stored-procedures plpgsql psql
How do I get the primary key(s) of a table from Postgres via plpgsql?

Given a table name, how do I extract a list of primary key columns and their datatypes from a plpgsql …

sql postgresql plpgsql
Iterating over integer[] in PL/pgSQL

I am trying to loop through an integer array (integer[]) in a plpgsql function. Something like this: declare a integer[] = …

arrays postgresql loops plpgsql postgresql-8.4
Cursor based records in PostgreSQL

I'm trying to use cursors for a query that joins multiple tables. I've seen that for oracle there is a …

postgresql loops cursor plpgsql
A simple pg/plsql loop example

We are redesigning table schema in postgres. It used to have a linker table to the two tables partner and …

postgresql data-migration plpgsql
PostgreSQL table variable

Is there anything like table variables in T-SQL? In Sql Server it looks like this: DECLARE @ProductTotals TABLE ( ProductID int, …

sql postgresql plpgsql table-variable
Postgres SELECT ... FOR UPDATE in functions

I have two questions about using SELECT … FOR UPDATE row-level locking in a Postgres function: Does it matter which columns …

postgresql plpgsql postgresql-9.1 select-for-update
PostgreSQL: ERROR: 42601: a column definition list is required for functions returning "record"

As far as I can tell, my function properly resembles the samples I've seen. Can someone clue me in as …

postgresql parameter-passing plpgsql set-returning-functions
PostgreSQL 9.1 pg_restore error regarding PLPGSQL

I am using Postgres for a django project and I am currently implementing a database backup/restore system that as …

postgresql plpgsql database-restore
Declare variable set = select

This probably sounds like a really stupid question, but how do I declare a variable for used in a PostgreSQL 9.3 …

postgresql variables set plpgsql declare