Re: EXECUTE of a 'create table' string is not happening

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Ralph Smith'" <rsmith(at)10kinfo(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: EXECUTE of a 'create table' string is not happening
Date: 2011-02-22 19:29:12
Message-ID: 00c001cbd2c6$cb31fec0$6195fc40$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A little lost but the first thing that stands out is that you are attempting
to create an actual table instead of a temporary table. Not sure if that
difference is meaningful to the function but procedurally is there a reason
to create the permanent table instead of a temporary one?

If you do need a permanent table would you be able to generate the data as
part of routine maintenance and/or via triggers instead of building out the
entire (or portion) of the table each time?

I do not think you have provided enough code to get good feedback. The
entire function would probably help - though maybe a simplified version but
one that still exhibits the behavior in question.

You also do not provide the minor release level which may be relevant.

David J.

From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Ralph Smith
Sent: Tuesday, February 22, 2011 2:05 PM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] EXECUTE of a 'create table' string is not happening

Hi,

I'm passing a tablename and two columnnames into a function so that I can
SELECT Records in a FOR LOOP using 'fixed' field names.
Using the passed params I construct the create table command and then alter
the names of two columns.

When I 'build' the function and then run my query to use the function w/ a
different offset it works the first time.
The first time ONLY. But actually it doesn't work, it just doesn't error
the first run.
Subsequent runs tell me that relation ######## doesn't exist, at the
FOR...LOOP line, after ALTERing the table.

I build the string and it's good:
CREATE TABLE temp_gentokenstable AS SELECT businessid, publicname FROM
businesscontact ORDER BY businessid OFFSET 200000 LIMIT 10000 ;

I'm forced to use v7.4.

If this is a known error, can I (with the version ; ^) ) get around it?

Ultimately I need to FOR..LOOP through through records and the table and
cols will change. Any suggestions???

THANKS!

--

Ralph
_________________________

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2011-02-22 19:35:48 Re: EXECUTE of a 'create table' string is not happening
Previous Message Ralph Smith 2011-02-22 19:04:59 EXECUTE of a 'create table' string is not happening