Lists: | pgsql-general |
---|
From: | "Christian Kasprowicz" <chris(at)feel-free(dot)de> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Storing Procedures / Transactions |
Date: | 2006-10-09 10:19:04 |
Message-ID: | 004c01c6eb8c$5a87b5f0$0201a8c0@excalibur |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Mabye I made myself not clear enough- sorry for that...
What I want is having a statement like:
PROCEDURE MyProcedure(Value1 int, Value2 text, Value3 varchar(30))
BEGIN
---check if something is valid
---compute something
---store values I got via THIS query and put them in table A, B and C
---see wether everything is ok
COMMIT;
...which I execute from a client like: exec MyProcedure(Value1, Value2,
Value3)
Hope someone can talk me through this. ;)
Thanks in advance,
Chris
From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Christian Kasprowicz" <chris(at)feel-free(dot)de> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Storing Procedures / Transactions |
Date: | 2006-10-12 02:26:48 |
Message-ID: | b42b73150610111926p53cf3cbct2633cfbce45bb90e@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On 10/9/06, Christian Kasprowicz <chris(at)feel-free(dot)de> wrote:
> PROCEDURE MyProcedure(Value1 int, Value2 text, Value3 varchar(30))
> BEGIN
> ---check if something is valid
> ---compute something
> ---store values I got via THIS query and put them in table A, B and C
> ---see wether everything is ok
> COMMIT;
>
> ...which I execute from a client like: exec MyProcedure(Value1, Value2,
> Value3)
>
> Hope someone can talk me through this… ;)
documentation is your friend : You should read through section V.
'Extending SQL' PostgreSQL has very rich extensibility features.
IMO, you should focus on pl/pgsql.
create or replace function foo(a int, b text) returns void as
$$
declare
valid boolean;
something numeric;
values record;
ok boolean default true;
begin
select into valid f1 = a where f2 = b;
something := 3 + a;
for values in select * from bar order by z loop
if values.v >= something then
ok := false;
end if;
update foobar set x = x + 1set where key = b;
end loop;
return;
end;
$$ language plpgsql;
merlin