Re ==> EXECUTE of a 'create table' string is not happening

From: Ralph Smith <rsmith(at)10kinfo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re ==> EXECUTE of a 'create table' string is not happening
Date: 2011-02-22 19:48:23
Message-ID: 4D641307.3040808@10kinfo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here's what I'm doing.
It is to work on existing tables (not triggerable), but for subsequent
updates to the table(s) that I'm tokenizing fields for, a trigger will
be used to do the tokenizing of new data
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _

CREATE OR REPLACE FUNCTION gen_tokens_n_map(character varying,
character varying, varchar, bigint, bigint)
RETURNS void AS
'
-- Sample invocation: SELECT
gen_tokens_n_map(^businesscontact^,^businessid^,^publicname^, 0,
10000) ;
-- Where ^ are actually apostrophes.

DECLARE vTableName ALIAS FOR $1 ;
KeyColName ALIAS FOR $2 ;
ValueColName ALIAS FOR $3 ;
offsetval ALIAS FOR $4 ;
limitval ALIAS FOR $5 ;
TableFieldVal INTEGER ;
TableRec RECORD ;
BusID BIGINT ;
.
.
.
ExecuteString := ''CREATE TABLE temp_gentokenstable (ID, ValueCol)
AS '' ;
ExecuteString := ExecuteString || '' SELECT '' || KeyColName ||
'', '' || ValueColName ;
ExecuteString := ExecuteString || '' FROM '' || vTableName || ''
ORDER BY '' || KeyColName ;
ExecuteString := ExecuteString || '' OFFSET '' ||
offsetval::text::varchar || '' LIMIT '' || limitval::text::varchar
|| '' ;'';

EXECUTE ExecuteString ;

FOR TableRec IN SELECT * FROM temp_gentokenstable order by id LOOP

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _
I will now try Pavel's suggestion of

use a EXECUTE statement and FOR IN EXECUTE statement

And to DJ's question, version 7.4.12. Yes, OUCH!

I'll let you know if the execute in the FOR LOOP will help out.

Thanks all!
Ralph


--
===============================================================================================


FOR TableRec IN SELECT * FROM temp_gentokenstable order by id LOOP

--

Ralph
_________________________

Browse pgsql-general by date

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