From: | Juan Pablo GO <mozstyle2002(at)gmx(dot)net> |
---|---|
To: | Pepe Ballaga <pepe(at)transnet(dot)cu> |
Cc: | Jaime Casanova <systemguards(at)gmail(dot)com>, Ayuda Postgres <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: duda sobre function en postgress |
Date: | 2005-06-17 17:49:33 |
Message-ID: | 42B30D2D.40009@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Bueno...
perform nombre,clave from admin where nombre=$1 and clave=$2 *; // fijate en el terminador de linea (;).*
Para el resto del c'odigo plpgsql:
http://www.postgresql.org/docs/8.0/static/plpgsql.html
Pepe Ballaga wrote:
> amigos ya hice la funcion tal y como me dijeron (por cierto que no se
> donde ponerle el return que me dicen que falta), pero el asunto es que
> me da estos errores cuando lo ejecuto (errores que salen en el log del
> status del servidor) y no me hace nada en la tabla. ¿podrian
> ayudarme?. disculpen tantas preguntas. muchas gracias
>
> syntax error at or near "if" at character 66
>
> Select nombre, clave from admin where nombre=$1 and clave=$2 if not $3
> then insert into admin values($4,$5,null,null) else update admin set
> clave=$6 where nombre=$7 end if
>
> PL/pgSQL function "adminahora" line 2 at perform
>
> esta es la funcion en si
>
>
> CREATE OR REPLACE FUNCTION adminahora(text, text)
> RETURNS int4 AS
> $BODY$
> BEGIN
> perform nombre,clave from admin where nombre=$1 and clave=$2
> if not found then
> insert into admin values($1,$2,null,null)
> else
> update admin set clave=$2 where nombre=$1
> end if;
> end;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE;
> ALTER FUNCTION adminahora(text, text) OWNER TO postgres;
>
>
> PEPE
>
> Pepe Ballaga
> Analista de Sistemas
> SITRANS. La Habana Cuba
> Tel: 8624685
> pepe(dot)ballaga(at)gmail(dot)com
> ----- Original Message ----- From: "Jaime Casanova"
> <systemguards(at)gmail(dot)com>
> To: "Pepe Ballaga" <pepe(at)transnet(dot)cu>
> Cc: "Ayuda Postgres" <pgsql-es-ayuda(at)postgresql(dot)org>
> Sent: Thursday, June 16, 2005 6:18 PM
> Subject: Re: [pgsql-es-ayuda] duda sobre function en postgress
>
>
>> On 6/16/05, Pepe Ballaga <pepe(at)transnet(dot)cu> wrote:
>>
>>> amigos esta es la funcion que cree, pero no me inserta nada en la
>>> tabla. por
>>> cierto que la mando a ejecutar en el Query tool de la siguiente manera.
>>> ¿esta bien asi?¿que me falta?. creo la funcion. pero no me daningun
>>> resultado.
>>>
>>
>> Logico, no le estas poniendo "RETURN valor_entero;" al final, eso te
>> falta.
>>
>> --
>> Atentamente,
>> Jaime Casanova
>> (DBA: DataBase Aniquilator ;)
>>
>>
>>
>
>
>
> ---------------------------(fin del mensaje)---------------------------
> TIP 4: No hagas 'kill -9' a postmaster
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2005-06-17 18:21:55 | Re: Descripcion de un tabla |
Previous Message | Oswaldo Hernández | 2005-06-17 17:38:13 | Re: duda sobre function en postgress |