X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3826E9FB1DB for ; Fri, 7 Jul 2006 14:57:13 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 30793-03 for ; Fri, 7 Jul 2006 14:57:08 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 90DA99FB1D9 for ; Fri, 7 Jul 2006 14:57:07 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from deliver.hol.gr (unknown [62.38.3.115]) by svr4.postgresql.org (Postfix) with ESMTP id 646905AF08F for ; Fri, 7 Jul 2006 17:57:04 +0000 (GMT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k67HuHpM017019 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Fri, 7 Jul 2006 20:56:17 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k67HupPS023531 for ; Fri, 7 Jul 2006 20:56:54 +0300 Message-Id: <200607071756.k67HupPS023531@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Custom Data Type Mapping JDBC Date: Fri, 7 Jul 2006 20:56:56 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0072_01C6A207.E5849520" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: Acah7rx2YgHkbZi2TGiN9YvORGkbbA== X-Virus-Scanned: ClamAV 0.87/1589/Fri Jul 7 17:37:51 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/108 X-Sequence-Number: 25682 This is a multi-part message in MIME format. ------=_NextPart_000_0072_01C6A207.E5849520 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello all, Let me explain the situation to the best of my knowledge. I am running postgres 8.1, and I read the documentation on CREATE TYPE, this could be extremely usefull for us at the moment. So I went ahead with this little test CREATE TYPE boolean_date AS( checked bool, value date ); CREATE TABLE answers( id serial primary key, answer1 boolean_date NOT NULL, answer2 boolean_date NOT NULL, comments text NOT NULL DEFAULT 'NONE' ); INSERT INTO answers VALUES(default, (true,'02-02-2004'),(false,null),'Hello World'); --query sucessfull SELECT * FROM answers id answer1 answer2 comments -- ------------ ------------ --------------- 1 (t,'02-02-2004) (f,) 'Hello World' -- All good SELECT (answer1::boolean_date).checked FROM answers id checked -- ------------ 1 t Now the question is, how would I go about inserting, selecting and updating answer1 and answer2 using JDBC? Could setObject help? I know I could do a prepared statement like so INSERT INTO answers(?,(?,?),(?,?),?); But that will ruin the purpose of creating a custom type for a set of values, wouldn't it? Thank you for taking the time to read this, if any clarification about the problem is required please mention it. Best Regards, Fotis ------=_NextPart_000_0072_01C6A207.E5849520 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Hello=20 all,
 
Let me = explain the=20 situation to the best of my knowledge. I am running postgres 8.1, and I = read the=20 documentation on CREATE TYPE, this could be extremely usefull for us at = the=20 moment. So I went ahead with this little test
 
CREATE = TYPE=20 boolean_date AS(
   =20 checked bool,
    value date
);
 
CREATE = TABLE=20 answers(
   =20 id serial primary key,
    answer1 boolean_date NOT NULL,
    answer2 boolean_date NOT NULL,
    comments text NOT NULL DEFAULT 'NONE'
);
 
 
INSERT = INTO answers=20 VALUES(default, (true,'02-02-2004'),(false,null),'Hello=20 World');
 
--query=20 sucessfull
 
 
 
SELECT = * FROM=20 answers
 
id       =20 answer1           =     =20 answer2        = comments
--       =20 ------------          &= nbsp;    =20 ------------       =20 ---------------
1       =20 (t,'02-02-2004)         &nbs= p; =20 (f,)            = 'Hello=20 World'
 
 
-- All = good
 
SELECT = (answer1::boolean_date).checked FROM answers
 
 
id   =20 checked
--     ------------
=
1        = t
 
 
Now = the question is,=20 how would I go about inserting, selecting and updating answer1 and = answer2=20 using JDBC?
 
Could = setObject=20 help?
 
I know = I could do a=20 prepared statement like so
 
INSERT = INTO=20 answers(?,(?,?),(?,?),?);
 
 
But = that will ruin=20 the purpose of creating a custom type for a set of values, wouldn't=20 it?
 
 
Thank = you for taking=20 the time to read this, if any clarification about the problem is = required please=20 mention it.
 
 
Best=20 Regards,
Fotis
 
 
 
------=_NextPart_000_0072_01C6A207.E5849520--