Hi all,
I want to use a plpgsql function that returns the value of a column, depending on the arguments ( the code below does
notwork, hence the question):
CREATE OR REPLACE FUNCTION getcustomername(text, int4) RETURNS text AS
'
BEGIN
IF $2 = 1 THEN
SELECT lastname FROM person WHERE objectid = $1;
RETURN lastname;
ELSIF $2 = 2 THEN
SELECT name into name1 from company WHERE objectid = $1;
RETURN name1;
END IF;
END
' LANGUAGE 'plpgsql' VOLATILE;
What is the correct way of doing this?
TIA
Groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl