Forum: Building VoltDB Applications

Post: SYSDATE replacement

SYSDATE replacement
yairogen
Mar 2, 2011
Hi,
What would be the replacement for Oracle SYSDATE? This is where I want the DB to insert the current date automatically for me.
Thanks,
Yair
re: SYSDATE replacement
tcallaghan
Mar 2, 2011
Yair,
In a VoltDB stored procedure you get the current timestamp in Java as follows:
Date spDate = this.getTransactionTime();
You can then pass this into your SQL statements.
-Tim
So the feature to have this
yairogen
Mar 2, 2011
Yair,
In a VoltDB stored procedure you get the current timestamp in Java as follows:
Date spDate = this.getTransactionTime();
You can then pass this into your SQL statements.
-Tim


So the feature to have this set inside the SQL itself like in other DB server does not exist at all? How come?
Other than that - I thought Date is not supported only Timestamp?
Yair
re: SYSDATE replacement
tcallaghan
Mar 3, 2011
So the feature to have this set inside the SQL itself like in other DB server does not exist at all? How come?
Other than that - I thought Date is not supported only Timestamp?
Yair


So the feature to have this set inside the SQL itself like in other DB server does not exist at all? How come?
Correct, we do not have an "in SQL" version of SYSDATE. (Plus, when I was coding PL/SQL I'd usually select SYSDATE into a PL/SQL variable once at the top of my stored procedure and use that variable throughout.)
Other than that - I thought Date is not supported only Timestamp?
You'll need to "import org.voltdb.types.TimestampType;" at the top of your stored procedure. Then you can get the current time (the time your stored procedure was accepted into the cluster) into a variable using "TimestampType tmcTS = new TimestampType(this.getTransactionTime());".
-Tim