On Thu, Nov 18, 2004 at 02:54:31PM +0100, Kjetil Haaland wrote:
> I have made my own type alignres that holds a string and an integer. I have
> created the type in postgres and tried to insert into it and it works. I also
> have a function that returns a row (or composite type). I have used
> tupdesc = RelationNameGetTupleDesc("alignres");
> to set it to return my own type. When i try to use the function in postgres
> it says
> ERROR: relation "alignres" does not exist
The type you created isn't a composite -- it's a base (scalar) type.
Do you want to return a row with a field that has your type, or do
you just want to return a single value of your type?
> If i try to let the function use a type that is only created in postgres (not
> c code) then it works.
I assume you mean it works for a composite type like this:
CREATE TYPE foo AS (val INTEGER, fstring TEXT);
As the CREATE TYPE documentation says, this is essentially the same
as the row type of a table. But your type is a scalar, not a composite,
so RelationNameGetTupleDesc() doesn't work.
> Is it possible to use my own type to be returned?
Yes, and you've already written a function that does: alignres_in().
Its CREATE FUNCTION statement says "RETURNS alignres", doesn't it?
If you want the new function to return a single value of your type,
then do what alignres_in() does.
In response to
pgsql-novice by date
|Next:||From: Bruno Wolff III||Date: 2004-11-18 17:31:54|
|Subject: Re: upgrade from postgres 7.3.2|
|Previous:||From: Kjetil Haaland||Date: 2004-11-18 13:54:31|
|Subject: function returning a row|