pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Forums @ Existanze <forums@existanze.com>
To: pgsql-sql@postgresql.org
Subject: Custom Data Type Mapping JDBC
Date: Fri, 7 Jul 2006 20:56:56 +0300
Message-ID: <200607071756.k67HupPS023531@auth-smtp.hol.gr> (raw)

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
 
 
 

Message-ID: <200607071756.k67HupPS023531@auth-smtp.hol.gr>
Permalink:  ../200607071756.k67HupPS023531@auth-smtp.hol.gr/
Also on:    postgresql.org/message-id/200607071756.k67HupPS023531@auth-smtp.hol.gr

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: forums@existanze.com
  Subject: Re: Custom Data Type Mapping JDBC
  In-Reply-To: <200607071756.k67HupPS023531@auth-smtp.hol.gr>

* 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