Re: convert 'foobar'::text to the string foobar

From: Kris Jurka <books(at)ejurka(dot)com>
To: Guillaume Cottenceau <gc(at)mnc(dot)ch>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: convert 'foobar'::text to the string foobar
Date: 2005-05-17 17:35:37
Message-ID: Pine.BSO.4.56.0505171230460.20628@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Fri, 13 May 2005, Guillaume Cottenceau wrote:

> I want to retrieve the default value of a TEXT column of a table.

You might want to consider DatabaseMetaData.getColumns() and using the
COLUMN_DEF column.

> 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).
>

That's how it is stored internally and there's not really much we can do
about it. If you know it's going to be 'xxx'::sometype it would be easy
to parse, but the driver can make no such assumptions.

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2005-05-17 18:02:13 Re: Simplified Chinese translation of po file
Previous Message Weiping 2005-05-17 01:15:10 Simplified Chinese translation of po file