RE: CURRENT_TIMESTAMP question

"Andrews, Trent - 43" <[email protected]>
Newsgroups gmane.comp.db.mckoi
Message-ID <[email protected]>
In Oracle this is allowed.

	SYSTIMESTAMP to Oracle as CURRENT_TIMESTAMP is to Mckoi.

Example

	PreparedStatememt statement =
connection.prepareStatement("INSERT INTO TABLE1 VALUES (?,SYSTIMESTAMP
)");
	statement.setString(1, "value");
	statement.execute();

Trent

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of James
Sent: Wednesday, December 01, 2004 7:52 AM
To: [email protected]
Subject: RE: CURRENT_TIMESTAMP question

In your example you are using a PreparedStatement and
are passing the string literal "CURRENT_TIMESTAMP" via
setString() on statement object.

"CURRENT_TIMESTAMP" is of java type String whereas the
column in table is of type DATE.  You needed to pass a
Timestamp java type, ie
statement.setTimestamp(6,dateCreated)

CURRENT_TIMESTAMP is a scalar function call, ie
returns a single value.  It can only be invoked in the
context of a sql statement, not as a string passed as
parameter to a JDBC statement.

The following should work:
insert into "APP"."parameter" 
("parameter_id","parameter_key","parameter","comment","updater_person_id
","date_created","date_updated")

values (?,?,?,?,?, CURRENT_TIMESTAMP,?)

However, I like your option 1, in conjunction with
defining a default for that column in table.  Like so:

, date_created  TIMESTAMP DEFAULT current_timestamp
NOT NULL
, next_column

Best Regards, Jim



---------------------------------------------------------------
Mckoi SQL Database mailing list  http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]





---------------------------------------------------------------
Mckoi SQL Database mailing list  http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.