Kbase P161935: SQL: Sample Java SQL Stored Procedure to return the system time stamp?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  03/05/2010 |
|
Status: Unverified
GOAL:
SQL: Sample Java SQL Stored Procedure to return the system time stamp?
GOAL:
Sample Java stored procedure to return the system time stamp in a specific format?
GOAL:
Sample Java stored procedure to return the system time stamp in the format YYYYMMDDSSSSS where SSSSS is the number of elapsed seconds since midnight.
GOAL:
How to invoke the NOW, SYSDATE and the TO_CHAR functions in SQL?
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.x
Progress 9.x
OpenEdge Category: SQL
FIX:
The following JAVA stored procedure uses the SYSDATE and the NOW functions to return a character string time stamp in the format of YYYYMMDDSSSSS where SSSSS is the number of seconds elapsed since midnight:
DROP PROCEDURE getTime;
CREATE PROCEDURE getTime()
RESULT (
CurrentTime CHARACTER(40)
)
BEGIN
String sCurrentTime = "";
SQLCursor timecursor = new SQLCursor ("SELECT TO_CHAR(SYSDATE(),'YYYYMMDD') + TO_CHAR(Now(), 'SSSSS') FROM SYSPROGRESS.SYSTABLES WHERE ID = 1");
timecursor.open ();
timecursor.fetch ();
while (timecursor.found())
{
sCurrentTime = (String) timecursor.getValue(1, CHARACTER);
SQLResultSet.set (1, sCurrentTime);
SQLResultSet.insert ();
timecursor.fetch();
}
timecursor.close ();
END
COMMIT;