From: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com> |
---|---|
To: | Matt Miller <mattm(at)epx(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, josh(at)agliodbs(dot)com, pgsql-hackers(at)postgresql(dot)org, Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Subject: | Re: 8.1 and syntax checking at create time |
Date: | 2005-08-31 19:58:17 |
Message-ID: | 20050831195816.GH98175@pervasive.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Aug 31, 2005 at 07:43:45PM +0000, Matt Miller wrote:
> On Wed, 2005-08-31 at 15:29 -0400, Tom Lane wrote:
> > Matt Miller <mattm(at)epx(dot)com> writes:
> > > I don't remember the last time I intended to write code that referenced
> > > something that did not exist in the database.
> >
> > Almost every day, people try to write stuff like
> >
> > CREATE TEMP TABLE foo ... ;
> > INSERT INTO foo ... ;
> > etc etc
> > DROP TABLE foo ;
>
> Point taken.
>
> PL/SQL requires all DDL to be dynamic SQL. For example:
>
> execute immediate 'drop table foo';
BTW, the way you handled this case in DB2 was:
CREATE TEMP TABLE foo ...;
CREATE FUNCTION blah AS ...;
DROP TEMP TABLE foo;
This way the object you wanted did exist when you were creating the
function. Of course it would be better if plpgsql could just read the
DDL and deal with it... but I'd say that doing the CREATE TABLE outside
the statement is better than nothing.
Actually, I think you only had to do the CREATE TEMP TABLE outside the
function creation if the function didn't create the temp table itself.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com 512-569-9461
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-08-31 19:59:56 | Re: 8.1 and syntax checking at create time |
Previous Message | Matt Miller | 2005-08-31 19:43:45 | Re: 8.1 and syntax checking at create time |