Another way is to use the JDBC escape syntax,
similar to the C/ODBC ESCAPE syntax. What this
does is allow to specify certain database functions/operations,
that are somewhat database-dependent, in a database-independent
way. There are ways to specify a date " { d date-value } ",
time " { t time-value }", scalar function " { fn func-call }",
etc. The chunk of code from the left { to the right } has to
be inserted into your SQL statement at the point where you
need it. e.g. select * from table where date_col < { d '01/01/1999' }.
Not sure if the syntax is exact, check JDBC docs for details.

Vasudev


> -----Original Message-----
> From: Craig McClanahan [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, October 27, 1999 1:40 AM
> To:   [EMAIL PROTECTED]
> Subject:      Re: DATE PROBLEM
>
> Mark E Novak wrote:
>
> > To insert formatted dates into an Oracle date field, in this instance,
> you
> > would use to_date(dtfield, 'DD,MM,YYY'). I've used this successfully.
> >
> > You would use Oracle's to_char() to format a selected date field from
> Oracle
> > as Oracle gives it to you in its default format, 01/MAY, 1999.
> >
>
> Dates are one of the places where not all databases use the same syntax in
> their
> SQL, which can make switching from one to another more difficult than it
> needs
> to be.  One way to reduce the pain, and avoid problems like this one, is
> to use
> a PreparedStatement instead:
>
>     Connection conn = ...;    // Acquire a JDBC connection
>     PreparedStatement stmt =
>       conn.prepareStatement("update customers set updated_date = ? where
> customer_id = ?");
>     java.sql.Date updateDate = new
> java.sql.Date(System.currentTimeMillis());
>     stmt.setDate(1, updateDate);
>     stmt.setLong(2, 123456);
>     stmt.executeUpdate();
>     stmt.close();
>
> You don't have to worry about the syntax of this particular database's
> date
> handling any more.  In the particular case of Oracle, you can also call
> PL/SQL
> stored procedures (via a CallableStatement) and gain the same freedom.
>
> Craig McClanahan
>
> __________________________________________________________________________
> _
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to