Home > Archive > PostgreSQL Discussion > August 2005 > Altering functions cast









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Altering functions cast
Matt A.

2005-08-26, 8:23 pm

We use NULLIF() for adding [1|0|null] according to the
evalution of nullif('x','') into boolean columns.
Where x is [1|0|null], which if it's an empty string
(x='') then we add NULL cause NULLIF says if '' == ''
then return NULL into boolean.

An example wrapper function for this with an integer
cast:


CREATE FUNCTION nullif_always_int(te
xt) RETURNS
integer AS '
SELECT nullif($1,'''')::int
;
' LANGUAGE SQL;


I was hoping I could do something simliar with
booleans if possible?



____________________
____________________
____________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs


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

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com