Top "Plpgsql" questions

PL/pgSQL is the default procedural language for PostgreSQL.

Store query result in a variable using in PL/pgSQL

How to assign the result of a query to a variable in PL/pgSQL, the procedural language of PostgreSQL? I …

database postgresql stored-procedures plpgsql postgresql-9.1
PostgreSQL IF statement

How can I do such query in Postgres? IF (select count(*) from orders) > 0 THEN DELETE from orders ELSE INSERT …

sql postgresql if-statement plpgsql
Postgres FOR LOOP

I am trying to get 25 random samples of 15,000 IDs from a table. Instead of manually pressing run every time, I'm …

postgresql stored-procedures for-loop random plpgsql
How to return result of a SELECT inside a function in PostgreSQL?

I have this function in PostgreSQL, but I don't know how to return the result of the query: CREATE OR …

sql postgresql return plpgsql return-type
Return multiple fields as a record in PostgreSQL with PL/pgSQL

I am writing a SP, using PL/pgSQL. I want to return a record, comprised of fields from several different …

sql postgresql stored-procedures types plpgsql
Truncating all tables in a Postgres database

I regularly need to delete all the data from my PostgreSQL database before a rebuild. How would I do this …

postgresql plpgsql dynamic-sql truncate database-table
No function matches the given name and argument types

My function is: CREATE OR REPLACE FUNCTION FnUpdateSalegtab09 ( iacyrid Integer,iRepId Integer,iDrId Integer,ivrid Integer,imode smallint,itrno varchar,…

function postgresql types casting plpgsql
Loop over array dimension in plpgsql

In plpgsql, I want to get the array contents one by one from a two dimension array. DECLARE m varchar[]; …

arrays postgresql multidimensional-array for-loop plpgsql
Store select query's output in one array in postgres

My code is: SELECT column_name FROM information.SCHEMA.columns WHERE table_name = 'aean' It returns column names of table …

sql arrays postgresql plpgsql
Postgresql, update if row with some unique value exists, else insert

I have a URLs table. They contain (id int primary key, url character varying unique, content character varying, last analyzed …

postgresql triggers plpgsql