pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rafa Couto <rafacouto@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Transaction in plpgslq
Date: Fri, 20 May 2005 12:47:31 +0200
Message-ID: <22df564b05052003479481da1@mail.gmail.com> (raw)

I have got a plpgsql function:

CREATE FUNCTION nueva_llamada(integer, integer) RETURNS integer

as

DECLARE
  _operadora_id ALIAS FOR $1;
  _actividad_id ALIAS FOR $2;
  _contacto_id integer;

BEGIN

  -- BEGIN;

    SELECT min(id) INTO _contacto_id FROM contactos 
      WHERE contactos.operadora_id IS NULL AND contactos.actividad_id
= _actividad_id;

    UPDATE contactos SET operadora_id = _operadora_id WHERE id = _contacto_id;

  -- COMMIT;

  INSERT INTO llamadas (contacto_id, operadora_id, fecha) 
    VALUES (_contacto_id, _operadora_id, now());

  RETURN _contacto_id;
END

and it works right, but I need atomic execution from --BEGIN and
--COMMIT, and manual says it is not possible to have transactions in
PL/pgSQL procedures :-(

May be with LOCK TABLE?



-- 
Rafa Couto (caligari)
mailto:rafacouto@gmail.com
urgentes (sólo texto): rafa112@amena.com
PGP 0x30EC5C31 [E6BF 11EF FE55 38B1  CF7E 9380 58E5 9FA3]



view thread (6+ messages)  latest in thread

Message-ID: <22df564b05052003479481da1@mail.gmail.com>
Permalink:  ../22df564b05052003479481da1@mail.gmail.com/
Also on:    postgresql.org/message-id/22df564b05052003479481da1@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rafacouto@gmail.com
  Subject: Re: Transaction in plpgslq
  In-Reply-To: <22df564b05052003479481da1@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox