SQL function - Mailing list pgsql-novice

From Prasad dev
Subject SQL function
Date
Msg-id BAY103-F23AEE65C4087556E8A8B10C0CF0@phx.gbl
Whole thread Raw
Responses Re: SQL function  (Michael Glaesemann <grzm@myrealbox.com>)
List pgsql-novice
Hi all !

I want an SQL function a rough structure below-

CREATE  FUNCTION ins_both(int,int,int,int) RETURNS boolean AS '
BEGIN
INSERT INTO inv2 values($2,$3,$4);
INSERT INTO inv1 values($1,$2,$3);
COMMIT
' LANGUAGE SQL;


but we cannot include Begin and commit in an SQL function
so i came out with the following which is not right

Create function insboth(int,int,int,int) RETURNS void AS $$
START TRANSACTION;
INSERT INTO inv2 values($2,$3,$4);
INSERT INTO inv1 values($1,$2,$3);
END TRANSACTION;
$$LANGUAGE SQL;

In short what i look for, i commit only after inserting these 2 tuples and
later it fires my trigger etc. If there is any other possible way please let
me know.

Thanks

Cheers
Prasad.



pgsql-novice by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: Troubles with PL/Perl in PgSQL
Next
From: Michael Glaesemann
Date:
Subject: Re: SQL function