At 10:54 +0300 on 25/05/1999, Anna Langer wrote:
> Now we wonder if we can put the date in to the database in the same way that
> we did with the integers? We have tried to make the date to a string, but it
> doesn't take it. The errormessage say that the database is of type datetime
> and the string is of type int4.
> Is there anyone who can help us with this?
You really must learn C. The trick with the %d is the standard way in C of
converting integers into strings. Dates are a bit more complicated. What is
the type you use for dates? time_t? If so, you convert it to string using
ctime(), a function in the standard C library. And then you use sprintf and
place it within single quotes.
It's true for every data type. You have to convert it to string, and then
have that string inserted into the command string using sprintf, with %s
within quotes. In the case of integer, the two steps can be shortened into
one, and you don't need quotes around the value. Same goes for float. Any
other data type needs the two steps and quotes.
Once you master this, remember that if your datatype is string, you have to
make sure every quote within the string is doubled (or preceded with a
backslash, but that's non-standard) before you pass it.
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
In response to
pgsql-interfaces by date
|Next:||From: Herouth Maoz||Date: 1999-05-25 10:24:24|
|Subject: Re: [GENERAL] JDBC and insert - stack overflow|
|Previous:||From: Michael Meskes||Date: 1999-05-25 07:55:17|
|Subject: Re: [INTERFACES] ECPG feature|