Re: pass date type data to PQexecparams
От | Michael Fuhr |
---|---|
Тема | Re: pass date type data to PQexecparams |
Дата | |
Msg-id | 20060925034414.GA44347@winnie.fuhr.org обсуждение исходный текст |
Ответ на | pass date type data to PQexecparams (pr0v4 <josip.povreslo@gmail.com>) |
Список | 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
В списке pgsql-novice по дате отправления: