Re: Help with a very newbie question...

From: "Cristian Prieto" <cristian(at)clickdiario(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Help with a very newbie question...
Date: 2005-02-23 13:56:04
Message-ID: 01b701c519af$6e45da50$6e00a8c0@gt.ClickDiario.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Well, I will ask a little more clear:
1. A function could be declare to return a RECORD value? (the manual doesn't
put it so clear, mention only simple return values and declaration values,
not return values).
2. It will be better declare that function as a parametrized view or as a
pgsql function?
3. If the record value is not a right return value, what kind of return
value could I use for it?

Thanks a lot for your help...

----- Original Message -----
From: "Jan Poslusny" <pajout(at)gingerall(dot)cz>
To: "Cristian Prieto" <cristian(at)clickdiario(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Sent: Wednesday, February 23, 2005 6:44 AM
Subject: Re: [GENERAL] Help with a very newbie question...

>I think that sql-functions may serve as parametrized views for you...
>
> http://www.postgresql.org/docs/8.0/static/xfunc-sql.html
>
> Cristian Prieto wrote:
>
>> I want to create a view or a sp which returns NULL if nothing is found
>> and a recordset if the user is found
>> I wrote something like:
>> CREATE sp_getuser(name, pass) RETURNS record AS
>> $body$
>> DECLARE
>> retval RECORD;
>> BEGIN
>> SELECT INTO retval * FROM Users WHERE userid=name AND passwd=pass;
>> IF NOT FOUND THEN
>> RETURN NULL;
>> ELSE
>> RETURN retval;
>> END;
>> $body$
>> LANGUAGE plpgsql;
>> What is wrong with that function? I guess I could create it as a View
>> but I don't know how to pass parameters in a view, somebody could help me
>> with this?
>> Thanks a lot!
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Molinet Sylviane 2005-02-23 14:34:41 maximum size
Previous Message Kai Hessing 2005-02-23 13:43:25 Advanced SELECT