Custom Data Type Mapping JDBC

From: "Forums (at) Existanze" <forums(at)existanze(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Custom Data Type Mapping JDBC
Date: 2006-07-07 17:56:56
Message-ID: 200607071756.k67HupPS023531@auth-smtp.hol.gr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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



Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2006-07-07 18:07:10 Re: Atomar SQL Statement
Previous Message T E Schmitz 2006-07-07 17:35:11 Re: SELECT substring with regex