how do I test conditions inside a stored procedure/function

From: adb <adb(at)Beast(dot)COM>
To: pgsql-general(at)postgresql(dot)org
Subject: how do I test conditions inside a stored procedure/function
Date: 2001-01-26 00:51:37
Message-ID: Pine.GSO.4.10.10101251644340.2561-100000@hairdini.beast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, I've just started using postgres 7.0 and I'm trying to see how
much I can do inside a stored procedure (or function I should say)

Is there any way to get data from a table into a variable in your
function? like
$maxuser = select max(userId) from users;

Also is there a way to test for existence of a row like

if exists (select 1 from users where userId = $userId) then
do something
else
raise exception "crap"
end if;

Basically I'm used to using stored procedures in sybase and I
want to see if similar methods can be used in postgres

Thanks,

Alex.

Browse pgsql-general by date

  From Date Subject
Next Message Josh Rovero 2001-01-26 01:12:35 Re: Wild Cards
Previous Message Karel Zak 2001-01-26 00:49:36 Re: backend closing connections while executing...