From: Guillaume Cottenceau <gc@mnc.ch>
To: pgsql-jdbc@postgresql.org
Subject: convert 'foobar'::text to the string foobar
Date: 13 May 2005 15:54:58 +0200
Message-ID: <87mzqzb58t.fsf@meuh.mnc.ch> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: gc@mnc.ch
Subject: Re: convert 'foobar'::text to the string foobar
In-Reply-To: <87mzqzb58t.fsf@meuh.mnc.ch>
References: <87mzqzb58t.fsf@meuh.mnc.ch>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox