X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7D2ED53563 for ; Fri, 13 May 2005 10:55:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42105-08 for ; Fri, 13 May 2005 13:55:04 +0000 (GMT) Received: from mnc.ch (www.mnc.ch [212.23.250.43]) by svr1.postgresql.org (Postfix) with ESMTP id 459D3565CB for ; Fri, 13 May 2005 10:55:01 -0300 (ADT) Received: (qmail 17861 invoked from network); 13 May 2005 15:55:03 +0200 Received: from 62-2-77-202.business.cablecom.ch (HELO meuh.mnc.ch) (62.2.77.202) by www.mnc.ch with SMTP; 13 May 2005 15:55:03 +0200 Received: by meuh.mnc.ch (Postfix, from userid 1000) id 217A723F8B8; Fri, 13 May 2005 15:54:58 +0200 (CEST) To: pgsql-jdbc@postgresql.org Subject: convert 'foobar'::text to the string foobar From: Guillaume Cottenceau Date: 13 May 2005 15:54:58 +0200 Message-ID: <87mzqzb58t.fsf@meuh.mnc.ch> Lines: 32 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.051 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/74 X-Sequence-Number: 12905 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