Originally posted by Rob Levo:
I am confused what the proper way to insert into a Date field. Sybase is the database.
Sould I format the date as a string that Sybase will except as a Date, or is there a better approach.
If someone could provide a simple example of doing an insert into tablename ...... where one of the fields is of type Data, that would be very, very helpful.
Thanks in advance.
Rob
Hi rob,
I have no Idea if Sybase uses a particular format for date inserts. But you can always use prepared statements I suppose.
PreparedStatement pstmt =
conn.prepareStatement ("insert into EMP (EMPNO, ENAME) values (?, ?)");
pstmt.setInt (1, 1500); The first ? is for EMPNO
pstmt.setString (2, "LESLIE");// The second ? is for ENAME
If Date is one of the fields. we can use
pstmt.setDate(1,date);
date is a java.sql.Date object.
It works with oracle. I think its no different for Sybase
Hope this would help.
regards
Prash.