Skip site navigation (1) Skip section navigation (2)

Re: pass date type data to PQexecparams

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: pr0v4 <josip(dot)povreslo(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: pass date type data to PQexecparams
Date: 2006-09-25 03:44:14
Message-ID: 20060925034414.GA44347@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-novice
On Fri, Sep 22, 2006 at 10:26:12AM +0200, pr0v4 wrote:
> I need to pass date type data from one table to another using the libpq
> library wich meens that I'm using the C programming language...
> PQexecparams look's like:
> 
> res = PQexecParams(conn,
> "INSERT INTO orders
> (userid,productid,qty,nomprice,discount,totprice,delivered,orderdate) VALUES
> ($1::int4,$2::int4,$3::int4,$4::int4,$5::int4,$6::int4,$7::int4,$8::QUESTION)",
> 8,
> NULL,
> paramValues,
> paramLengths,
> paramFormats,
> 1)
> 
> You can see that last 8th argument is of type QUESTION, well this is my
> question wich datatype must be declared to pass date into ?

The obvious answer is that the type should be date but I can think
of situations that need something more.  If the parameter format
is binary and the parameter value is a type other than date then
you might need two casts: one to specify the parameter type and
another to cast that type to the destination column's type.  For
example, if the format is binary, the value is text, and the
destination column is date, then "$8::text::date" is probably what
you need.  But if the value is date then "$8::date" should work.

Is the input value in text or binary format?  If binary then what
type is it?  What have you tried and with what results?  If you're
getting an error then please post the error message.

-- 
Michael Fuhr

In response to

Responses

pgsql-novice by date

Next:From: Oliver FrommeDate: 2006-09-25 15:58:36
Subject: Multiple UNIX-domain sockets?
Previous:From: Stephan SzaboDate: 2006-09-23 15:59:15
Subject: Re: assertion and company

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group