Unlike other databases, PostgreSQL returns a TEXT type by default every time you run a select with a free string. Example:
SELECT 'Text' as FIELD FROM TABLE
in this case above the field FIELD
will be returned with type TEXT
Does anyone know if it is possible to change some parameter in PostgreSQL so that it returns a CHAR
or VARCHAR
type in the above case?
Firebird and Oracle return a CHAR
type.
I know this would be solved with a CAST however for this I would have to replicate the same for all SQL's of the system besides having to make using CAST
a standard routine of developing new SQL's.
Anyway, does anyone have any idea of anything that might have changed? I'm studying the files pg_cast.h
and pg_type.h
with a as ( select 'hello'::varchar as b from table ) select a.b,pg_typeof(a.b) from a;
casting seems to work... maybe the problem is in the library. - can you post example code? – Jasen May 19 '18 at 2:33