From: | "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Casting |
Date: | 2003-04-08 09:04:30 |
Message-ID: | Pine.LNX.4.21.0304081002330.24319-100000@ponder.fairway2k.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
I'm obviously missing something here but I don't know what. This is on 7.3.2.
When I use my cast I get:
mydb=> select cast('truE'::text as boolean);
WARNING: Error occurred while executing PL/pgSQL function text_to_bool
WARNING: line 4 at select into variables
ERROR: CopyQuerySnapshot: no snapshot has been set
Any clues as to why that is?
The code is simplistic to say the least:
-- text_to_bool ()
--
-- Cast from text type to boolean.
--
CREATE OR REPLACE FUNCTION text_to_bool ( text )
RETURNS boolean
AS '
DECLARE
rv boolean;
BEGIN
SELECT INTO rv
CASE
WHEN lower($1) = ''true''
OR lower($1) = ''t''
OR lower($1) = ''1''
THEN
true
WHEN lower($1) = ''false''
OR lower($1) = ''f''
OR lower($1) = ''0''
THEN
false
ELSE
NULL
END;
RETURN rv;
END;
'
LANGUAGE 'plpgsql'
STRICT
IMMUTABLE;
CREATE CAST (text AS boolean) WITH FUNCTION text_to_bool ( text );
Thanks,
--
Nigel J. Andrews
From | Date | Subject | |
---|---|---|---|
Next Message | Laurent Perez | 2003-04-08 09:11:03 | CVS doesn't compile initdb and other binaries |
Previous Message | Jean-Christian Imbeault | 2003-04-08 08:49:55 | Re: Instalation problem |
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2003-04-08 10:24:55 | Re: Backpatch FK changes to 7.3 and 7.2? |
Previous Message | Ron Peacetree | 2003-04-08 03:11:26 | Re: No merge sort? |