Re: [PLPGSQL] PERFORM into an EXECUTE allowed ?

From: Bruno Baguette <bruno(dot)baguette(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: [PLPGSQL] PERFORM into an EXECUTE allowed ?
Date: 2008-10-27 08:41:35
Message-ID: ge3urt$17hc$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le 27/10/08 05:16, Tom Lane a écrit :
> Bruno Baguette <bruno(dot)baguette(at)gmail(dot)com> writes:
>> EXECUTE 'PERFORM COUNT(*)'
>> || ' FROM ' || quote_ident(TG_RELNAME)
>> || ' GROUP BY ' || quote_ident(column_name_to_check)
>> || ' HAVING COUNT(*) > 1';
>
> PERFORM is a plpgsql keyword, not a SQL keyword, so it's not surprising
> that this fails. What I'm wondering is what exactly you hope the above
> will accomplish? Why would you want to execute this query only to have
> the results discarded?
>
> regards, tom lane

Hello Tom !

I only want to know if there is at least one result for this query.
I don't want to get the results itself.

That's why I wanted to use PERFORM and working with IF FOUND THEN (or)
IF NOT FOUND THEN.

Since this trigger is intented to be usable for any table and any column
name, this query is dynamically builed into the trigger.

I've read on
<http://www.postgresql.org/docs/8.3/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS>
that the statement type for my need was PERFORM (since SELECT INTO is
not supported currently on EXECUTE).

That's why I was trying to do a PERFORM into an EXECUTE.
Indeed, you're right, PERFORM is PL/PLGSQL keyword, not SQL keyword.

Mmmh, I wonder how I will workaround that problem...

Regards,

--
Bruno Baguette - bruno(dot)baguette(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message wstrzalka 2008-10-27 08:59:42 psql screen size
Previous Message Ron Mayer 2008-10-27 07:34:16 Re: Are there plans to add data compression feature to postgresql?