Re: insert select fails inside of function - Mailing list pgsql-general

From Tom Lane
Subject Re: insert select fails inside of function
Date
Msg-id 17596.1340394255@sss.pgh.pa.us
Whole thread Raw
In response to insert select fails inside of function  (Benedict Holland <benedict.m.holland@gmail.com>)
Responses Re: insert select fails inside of function
List pgsql-general
Benedict Holland <benedict.m.holland@gmail.com> writes:
> I am scratching my head over this one. I have a basic function which
> populates a table inside of it (declared outside of the function but that
> shouldn't matter)  and it requires something like

> insert into table1 (col1, ...)
> select * from foo

> and I get the error "query has no destination for result data". This is
> surely not the case as it's going directly into the insert statement which
> doesn't have output. Any idea how to get around this particularly annoying
> problem?

What PG version?  Could we see the exact text of the function?  I'm
wondering about aliasing problems stemming from function variables named
similarly to the target table or its columns --- newer PG versions are
brighter about that sort of conflict than older ones.

> I have to say, making the switch from t-sql to postgresql has been
> fairly easy except for function debugging.

RAISE NOTICE is the usual substitute for what I think you were doing on
t-sql.  Also, I think EDB is still supporting their plpgsql debugger, so
you might consider experimenting with that.

            regards, tom lane

pgsql-general by date:

Previous
From: Виктор Егоров
Date:
Subject: Re: Extensions and roles for access administration
Next
From: Benedict Holland
Date:
Subject: Re: insert select fails inside of function