Re: plpgsql - Mailing list pgsql-general

From Martin Marques
Subject Re: plpgsql
Date
Msg-id 200310200939.00884.martin@bugs.unl.edu.ar
Whole thread Raw
In response to Re: plpgsql  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Responses Re: plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
El Dom 19 Oct 2003 18:25, Alvaro Herrera escribió:
> On Sat, Oct 18, 2003 at 06:48:10PM -0300, Martin Marques wrote:
> > We are trying to make some things work with plpgsql. The problem is that
> > I built several functions that call one another, and I thought that the
> > way of calling it was just making the assign:
> >
> > var:=func1(arg1,arg2);
>
> Have you tried plpgsql's SELECT INTO ?

OK, let me be more specific. I tried this aready with this error:

2003-10-20 09:28:05 [27039]  ERROR:  parser: parse error at or near ")" at
character 15
2003-10-20 09:28:05 [27039]  WARNING:  plpgsql: ERROR during compile of
objetosdatosactualizadicc near line 2

Now, here are the specifications about my function.
I'm building a function that does things with the fields of each row inserted.
This function is called from a Trigger. Also, this function calls another
function with does the actual job (well, it really cals some other functions,
all writen in plpgsql).

Here's the code:

CREATE OR REPLACE FUNCTION objetosdatosActualizaDicc() RETURNS TRIGGER AS '
DECLARE
    newPk    INT;
    oldPk    INT;
    newVcampo    VARCHAR;
    oldVcampo    VARCHAR;
    salida    RECORD;
BEGIN
    IF TG_OP = ''UPDATE'' OR TG_OP = ''INSERT'' THEN
        newPk := NEW.codigo;
        newVcampo := NEW.titulo;
    END IF;
    IF TG_OP = ''UPDATE'' OR TG_OP = ''DELETE'' THEN
        oldPk := OLD.codigo;
        oldVcampo := OLD.titulo;
    END IF;
    SELECT INTO salida
        actualizarDiccionario(newPk,newVcampo,oldPk,oldVcampo,
        ''biblioteca'',''titulo'',TG_RELNAME,TG_OP);
    RETURN NEW;
END;
' LANGUAGE 'plpgsql';

(actualizarDiccionario is declared like this:
actualizarDiccionario(INT,INT,INT,INT,VARCHAR,VARCHAR,VARCHAR,VARCHAR)
)

This is what's giving me the error:

2003-10-20 09:28:05 [27039]  ERROR:  parser: parse error at or near ")" at
character 15
2003-10-20 09:28:05 [27039]  WARNING:  plpgsql: ERROR during compile of
objetosdatosactualizadicc near line 2

If I change the last SELECT INTO for a PERFORM I don't get the error, but I
also don't get the things from actualizarDiccionario() done (as if it wasn't
executed).

--
 09:28:01 up 17 days, 19:00,  3 users,  load average: 0.33, 0.38, 0.36
-----------------------------------------------------------------
Martín Marqués                  |        mmarques@unl.edu.ar
Programador, Administrador, DBA |       Centro de Telematica
                       Universidad Nacional
                            del Litoral
-----------------------------------------------------------------


pgsql-general by date:

Previous
From: Nick Burrett
Date:
Subject: Re: Recomended FS
Next
From: "Ben-Nes Michael"
Date:
Subject: Re: Recomended FS