Skip site navigation (1) Skip section navigation (2)

Using Execute with Dynamic Raise Commands

From: Robert Bernabe <rbernabe(at)sandmansystems(dot)com>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Using Execute with Dynamic Raise Commands
Date: 2007-11-21 08:14:40
Message-ID: 4743E8F0.6020400@sandmansystems.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi All,
   I've been trying to create a debugging function that would receive a 
tablename and a list of columns and then the function would display all 
the contents of the table using the RAISE command.

CREATE OR REPLACE FUNCTION usp_PG_DUMPTEMPTABLE(varchar(100), text[])
   RETURNS void AS
 $BODY$
 DECLARE
    _temptable ALIAS FOR $1;
    _temparray alias for $2;
    
    _i            integer;
    _max             integer;
    _tempstring        varchar(2000);

 BEGIN
   
    _tempstring := 'RAISE INFO''';
    for _i in 1 ..array_upper(_temparray, 1)
    loop
        _tempstring := _tempstring || _temparray[_i] || '   ' ;
    end loop;
    _tempstring := _tempstring || ''';';

    raise info'%', _tempstring;
    execute _tempstring;
    raise info '---';

    
     RETURN;
 END;
 $BODY$
   LANGUAGE 'plpgsql';


for some reason, the EXECUTE command issues an error at the start fo the 
RAISE command...help?

Error from PG Admin III

ERROR:  syntax error at or near "RAISE"
LINE 1: RAISE DEBUG 'SKUID   CatID   ';
        ^
QUERY:  RAISE DEBUG 'SKUID   CatID   ';
CONTEXT:  PL/pgSQL function "usp_pg_dumptemptable" line 42 at EXECUTE 
statement


Regards

In response to

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2007-11-21 16:43:44
Subject: Re: Using Execute with Dynamic Raise Commands
Previous:From: Rodrigo De LeónDate: 2007-11-20 16:19:09
Subject: Re: need trigger help

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group