dbTalk Databases Forums  

Using perform in plpgsql throws compile errors

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Using perform in plpgsql throws compile errors in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mail
 
Posts: n/a

Default Using perform in plpgsql throws compile errors - 09-24-2004 , 12:58 PM






Sorry if this is a re-post, but my posts don't seem to get through ...

Hi,

I am trying to create a really simple pl/pgsql based function to simply
return true or false depending on a query result ...

As I do not need the query result row, I want to use PERFORM to dump the
resulting data ... So, here's my attempt:

CREATE OR REPLACE FUNCTION islicensed(int8, int8) RETURNS bool AS '
DECLARE
pID ALIAS FOR $1;
aID ALIAS FOR $2;
BEGIN
PERFORM SELECT * FROM transactions x INNER JOIN tx_items i ON(x.id =
i.tx_id) where i.archive_id=aID and x.status=\'valid\' and x.person_id=pID;
RETURN FOUND;
END;
' LANGUAGE 'plpgsql';


However, even so the creation statement succeeds, any attempt to call
this function throws a compilation error:

ERROR: syntax error at or near "SELECT" at character 9
CONTEXT: PL/pgSQL function "islicensed" line 5 at perform

Why this? As I understand the docs, this is how it should work!?!

Any help is highly appreciated.

Oh, PostgreSQL 7.4.1 running on RH Linux ES 3.0 (not from RH rpm, but
compiled from sources) ...

Thanks,
Chris






---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: Using perform in plpgsql throws compile errors - 09-24-2004 , 01:47 PM






mail <mail (AT) peneios (DOT) com> writes:
Quote:
PERFORM SELECT * FROM transactions x INNER JOIN tx_items i ON(x.id =
i.tx_id) where i.archive_id=aID and x.status=\'valid\' and x.person_id=pID;
You need "PERFORM * FROM transactions ...". No SELECT keyword.

Looking at the manual, I see it could be worded better. The example is
correct but the description is misleading :-(

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Reply With Quote
  #3  
Old   
Gaetano Mendola
 
Posts: n/a

Default Re: Using PERFORM in plpgsql throws compile errors - 09-27-2004 , 06:17 PM



Christian Armeanu wrote:
Quote:
Hi,

I am trying to create a really simple pl/pgsql based function to simply
return true or false depending on a query result ...

As I do not need the query result row, I want to use PERFORM to dump the
resulting data ... So, here's my attempt:

CREATE OR REPLACE FUNCTION islicensed(int8, int8) RETURNS bool AS '
DECLARE
pID ALIAS FOR $1;
aID ALIAS FOR $2;
BEGIN
PERFORM SELECT * FROM transactions x INNER JOIN tx_items i ON(x.id =
i.tx_id) where i.archive_id=aID and x.status=\'valid\' and x.person_id=pID;
RETURN FOUND;
END;
' LANGUAGE 'plpgsql';


However, even so the creation statement succeeds, any attempt to call
this function throws a compilation error:

ERROR: syntax error at or near "SELECT" at character 9
CONTEXT: PL/pgSQL function "islicensed" line 5 at perform

Why this? As I understand the docs, this is how it should work!?!

Any help is highly appreciated.

Oh, PostgreSQL 7.4.1 running on RH Linux ES 3.0 (not from RH rpm, but
compiled from sources) ...
Remove the SELECT on the PERFORM statement:

PERFORM * FROM ....


Regards
Gaetano Mendola



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.