Simple function closes connection to server

From: "T- Bone" <jbowen333(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Simple function closes connection to server
Date: 2005-04-06 19:34:24
Message-ID: BAY103-F3750768FE2F0DCFFEE54EAE73D0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello all,

PG 8.0.1
Mandrake 10.1
Uniqueidentifier 0.2 type and function instatlled (see
http://gborg.postgresql.org/project/uniqueidentifier/projdisplay.php)

I have a very simple funtion designed to perform a lookup on a 'zone name'
based on a uniqueidentifier:
-----------------------------------8<-------------------------------------------
CREATE OR REPLACE FUNCTION "getZoneName"(text)
RETURNS text AS
$BODY$DECLARE
zonename text;
BEGIN
-- Perform a lookup on OrgID to determine Zone Name
SELECT INTO zonename "Name" FROM "tblOrganisation" WHERE "OrgID"::text =
$1;
RETURN zonename;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE STRICT SECURITY DEFINER;
-----------------------------------8<-------------------------------------------

The "OrgID" is a uniqueidentifier type, so I explicitly cast it. The
function works fine when I execute it as follows:
-----------------------------------8<-------------------------------------------
SELECT "getZoneName"('51f6c6a0-fee0-43c1-b50c-bd67191cb374')
-----------------------------------8<-------------------------------------------
The zone name is returned.

However, when I execute it as follows, my connection to the db gets closed
and, obviously, there is no result. In fact, it appears that ALL
connections are closed (this is not good).
-----------------------------------8<-------------------------------------------
SELECT "ZoneID", "getZoneName"("ZoneID"::text) AS "ZoneName"
FROM "tblOrganisation";
-----------------------------------8<-------------------------------------------
Essentially, I want to use the "ZoneID" (also a uniqueidentifier type) value
to plug into my function. I thought my function gets processed on a
row-by-row basis (like a strpos function would).

I am hoping that I am missing something quite simple. Thanks in advance.

Regards,
Jim

_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft
SmartScreen Technology.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSN Premium right now and get the
first two months FREE*.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Keith Worthington 2005-04-06 20:06:57 JOIN on a lookup table
Previous Message Deepblues 2005-04-06 16:42:55 binding values to sql statement in DBI perl