how do I test conditions inside a stored procedure/function - Mailing list pgsql-general

From adb
Subject how do I test conditions inside a stored procedure/function
Date
Msg-id Pine.GSO.4.10.10101251644340.2561-100000@hairdini.beast.com
Whole thread Raw
List 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.


pgsql-general by date:

Previous
From: Karel Zak
Date:
Subject: Re: backend closing connections while executing...
Next
From: Kyle
Date:
Subject: DBD::Pg using int2 / smallint