convert 'foobar'::text to the string foobar

From: Guillaume Cottenceau <gc(at)mnc(dot)ch>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: convert 'foobar'::text to the string foobar
Date: 2005-05-13 13:54:58
Message-ID: 87mzqzb58t.fsf@meuh.mnc.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,

I want to retrieve the default value of a TEXT column of a table.
So far, I had a hard time writing this query and after looking at
postgresql doc I have looked in phppgadmin source code, and am
finally using:

SELECT adef.adsrc AS value
FROM pg_catalog.pg_attribute a
LEFT JOIN pg_catalog.pg_attrdef adef
ON a.attrelid = adef.adrelid
AND a.attnum = adef.adnum
WHERE a.attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = ?)
AND a.attname = ?

when used with a table with a default value set by:

ALTER TABLE table_name ALTER COLUMN column_name SET DEFAULT 'foobar';

displaying that way with \d:

column_name | text | not null default 'foobar'::text

retrieved as a String in Java, I end up with "'foobar'::text"
where I'd need just the string "foobar" (without any quote).

Is there something I'm doing wrong?

Thank you.

--
Guillaume Cottenceau

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message sumit shah 2005-05-13 15:20:50 Arrays Was (Re: ERROR in 8.0 driver, but not 7.4: SELECT DISTINCT, ORDER BY expressions must appear in select list)
Previous Message Oliver Jowett 2005-05-13 11:24:51 Re: log_min_duration_statement doesn't work