Re: Cannot declare record members NOT NULL

Поиск
Список
Период
Сортировка
От Uwe C. Schroeder
Тема Re: Cannot declare record members NOT NULL
Дата
Msg-id 200709121345.14248.uwe@oss4u.com
обсуждение исходный текст
Ответ на Re: Cannot declare record members NOT NULL  (Cultural Sublimation <cultural_sublimation@yahoo.com>)
Ответы Re: Cannot declare record members NOT NULL  (Cultural Sublimation <cultural_sublimation@yahoo.com>)
Список pgsql-general
I haven't tried it with a view yet - so this may or may not work. But try
giving it a shot by declaring a view

create view vmovies as
select movie_id,movie_text from movies

and let your function return setof vmovies

Maybe that works - I think it should.

Uwe


On Wednesday 12 September 2007, Cultural Sublimation wrote:
> > Why do you create an extra type for that?
> > Just have your method return "movies"
>
> Hi,
>
> Thanks for the answer.  The simple example obfuscates the fact that in
> reality the table has a few extra columns that are omitted from
> get_movies_t. Therefore, I cannot return "movies".
>
> However, your answer did give me an idea:  instead of declaring
> "get_movies_t" as a record, I declare it as dummy table, and return that
> (see code at the end).
> This works, though it is *very* ugly.  Any other ideas?
>
> Thanks,
> C.S.
>
>
> CREATE TABLE get_movies_t
> (
> movie_id                int4 NOT NULL,
> movie_name              text NOT NULL
> );
>
> CREATE FUNCTION get_movies ()
> RETURNS SETOF get_movies_t
> LANGUAGE sql STABLE
> AS
> $$
> SELECT movie_id, movie_name FROM movies;
> $$;
>
>
>
>
>
>
> ___________________________________________________________________________
>_________ Shape Yahoo! in your own image.  Join our Network Research Panel
> today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org/



--
    UC

--
Open Source Solutions 4U, LLC    1618 Kelly St
Phone:  +1 707 568 3056        Santa Rosa, CA 95401
Cell:   +1 650 302 2405        United States
Fax:    +1 707 568 6416

В списке pgsql-general по дате отправления:

Предыдущее
От: Cultural Sublimation
Дата:
Сообщение: Re: Cannot declare record members NOT NULL
Следующее
От: Osvaldo Rosario Kussama
Дата:
Сообщение: Re: Cannot declare record members NOT NULL