Hello,
I'd like to return a set of integer in an pl/pgsql function. How can I
do that ?
I've tried things like that, put I've an error when executing :
CREATE FUNCTION SP_UPLES() RETURNS setof INTEGER AS '
DECLARE ID INTEGER;
BEGIN
select a into id from foo;
return ID ;
END;
Andreas Tille wrote:
>
> Hello,
>
> could someone enlighten a fairly beginner how to define columns
> of a table with the following features:
>
>CreateDate DEFAULT value should store current date and time
create table mytable( CreateDate timestamp default timestamp('now'),
);
>
Graham Vickrage wrote:
>
> As far as i know, you can only return single values from functions at the
> moment.
>
> Regards
>
> Graham
Hum, this is possible a least in SQL functions.
But maybe impossible in PL/PGSQL
Andreas Tille wrote:
> I tried:
>
> web=# CREATE FUNCTION changed_at_timestamp () RETURNS OPAQUE AS '
> web'# BEGIN
> web'# ChangeDate := timestamp(''now'');
> web'# RETURN NEW;
> web'# END;
> web'# ' LANGUAGE 'plpgsql';
> CREATE
> web=# select changed_at_timestamp () ;
Andreas Tille wrote:
> What does this mean? The ERROR is caused by the Create Table statement
> (when I removed it from my complex function it worked well).
> So why doesn't this work and what copy function fails here??
Maybe you can create your table using a select into statement :
something l
Andreas Tille wrote:
>
> On Wed, 23 Aug 2000, hlefebvre wrote:
>
> > Yes. The keywords NEW / OLD are available only in triggers
> > see
> > http://www.postgresql.org/users-lounge/docs/7.0/user/c40874113.htm#AEN4286
> Well, I believe that, but
>
>
Andreas Tille wrote:
>
> On Fri, 25 Aug 2000, hlefebvre wrote:
>
> > No I suppose that the problem is the identifier "changedat" is unknown.
> >
> > You must probably prefix it : NEW.changedat
> >
> > CREATE FUNCTION changed_
Tom Lane wrote:
>
> Andreas Tille <[EMAIL PROTECTED]> writes:
> >> NEW.ChangedAt := timestamp(''now'');
>
> > This avoids the error message, but doesn't have any effect to the value
> > of ChangedAt. It just remains the same as CreatedAt :-(.
>
> I think you are getting burnt by premature co
Andreas Tille wrote:
>
> On Fri, 25 Aug 2000, Tom Lane wrote:
>
> > I think you are getting burnt by premature constant folding --- see
> > nearby discussion of how to define a column default that gives the
> > time of insertion. You need to write this as
> > NEW.ChangedAt := now();
> >
Keith Wong wrote:
>
> Hi Andreas,
>
> I've worked with MS SQL stored procedures before and they are quite
> powerful. Its a shame postgres doesn't have the same
> level of features as offered by MS SQL,
MS SQL is based on source code of Sybase v5. MS bought this source code
to sybase.
Sybase
10 matches
Mail list logo