I'm looking for a way to create function which returns column type as single
character:
C = char/text/varchar, N=numeric, L=bool, .... others, U=unknown
from expression in form 'tablename.columnname', where tablename if table
from
current search_path tables. search_path has two schemas. First is custom
schema which can be different for different runs.
second is public schema always
ExpressionType('mytable.mycol') retuns C if mytable has column mycol
of type CHAR(10)
Currently I'm using hard coded column names as shown below.
User can add its own columns to db so hard-coding is not accurate.
How to implement such generic function ?
Andrus.
CREATE OR REPLACE FUNCTION public.ExpressionType(expression text )
RETURNS char(1) AS
$BODY$
BEGIN
IF LOWER(expression)='isik.sotskorrkl' THEN
RETURN 'L';
END IF;
RETURN 'U';
END;
$BODY$ language plpgsql immutable;
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general