Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-25 Thread Sebastien FLAESCH
Tom Lane wrote: Ron Mayer rm...@cheapcomplexdevices.com writes: Sam Mason wrote: You get an error because 123 11 isn't a valid literal of an (undecorated) INTERVAL type. Hmm. should it be? Well, we do allow it if it's *explicitly* stated to be a day to hour interval: regression=#

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-24 Thread Tom Lane
Ron Mayer rm...@cheapcomplexdevices.com writes: Sam Mason wrote: You get an error because 123 11 isn't a valid literal of an (undecorated) INTERVAL type. Hmm. should it be? Well, we do allow it if it's *explicitly* stated to be a day to hour interval: regression=# select interval '123

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-20 Thread Ron Mayer
Sam Mason wrote: You get an error because 123 11 isn't a valid literal of an (undecorated) INTERVAL type. Hmm. should it be? Skimming the spec makes me think it might be a valid day-time interval. Quoting the spec: unquoted interval string ::= [ sign ] { year-month literal | day-time

[GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Sebastien FLAESCH
Hello, I try to use the new 8.4 INTERVAL type with libpq, but get crazy with the input formatting rules... I use PQprepare() / PQexecPrepared() with parameter list, binding the INTERVAL values with the 1186 pg_type and passing a string buffer with values like: 12345 for an INTERVAL YEAR The

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Sam Mason
On Tue, May 19, 2009 at 10:08:37AM +0200, Sebastien FLAESCH wrote: I try to use the new 8.4 INTERVAL type with libpq, but get crazy with the input formatting rules... I think you're giving the database conflicting instructions and it's getting confused. fprintf(stdout,++ Preparing INSERT

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Sebastien FLAESCH
Yes, good point. I realize now that I would have expected libpq to give me a way to specify the exact decoration or precision of INTERVAL parameters... As you can do with ODBC's SQLBindParameter(), where you specify the C type, SQL type, precision/scale or length ... I believe this is important

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Sam Mason
On Tue, May 19, 2009 at 02:17:20PM +0200, Sebastien FLAESCH wrote: As you can do with ODBC's SQLBindParameter(), where you specify the C type, SQL type, precision/scale or length ... I believe this is important when it comes to data type conversion (for ex, when you want to insert a

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Merlin Moncure
On Tue, May 19, 2009 at 8:17 AM, Sebastien FLAESCH s...@4js.com wrote: Yes, good point. I realize now that I would have expected libpq to give me a way to specify the exact decoration or precision of INTERVAL parameters... As you can do with ODBC's SQLBindParameter(), where you specify the C

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Merlin Moncure
On Tue, May 19, 2009 at 10:12 AM, Sam Mason s...@samason.me.uk wrote: On Tue, May 19, 2009 at 02:17:20PM +0200, Sebastien FLAESCH wrote: As you can do with ODBC's SQLBindParameter(), where you specify the C type, SQL type, precision/scale or length ... I believe this is important when it comes

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Sebastien FLAESCH
Thank you guys for your input, I really appreciate. It's a while I haven't posted on this list and be happy to get fast and accurate answers... As I wrote in a previous mail, I maintain a database driver for our 4GL runtime system, allowing Informix 4gl applications to use PostgreSQL. In this

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Tom Lane
Sam Mason s...@samason.me.uk writes: I don't really know 8.4, but I believe you're saying here that you explicitly want the values to be of basic INTERVAL type here, i.e. not INTERVAL DAY TO HOUR for parameter 3. Right, you can get the equivalent behavior from psql thus: regression=# select

Re: [GENERAL] INTERVAL data type and libpq - what format?

2009-05-19 Thread Sebastien FLAESCH
Tom Lane wrote: Sam Mason s...@samason.me.uk writes: I don't really know 8.4, but I believe you're saying here that you explicitly want the values to be of basic INTERVAL type here, i.e. not INTERVAL DAY TO HOUR for parameter 3. Right, you can get the equivalent behavior from psql thus: