Alex Vinall

  • Home
  • Photography
    • Flora & Fauna
    • Landscape
    • Architecture
  • Blog
  • Home
  • Photography
    • Flora & Fauna
    • Landscape
    • Architecture
  • Blog

How to log the current time using an Oracle database

22/7/2016

2 Comments

 
The project I'm currently working on involves a large number of different technologies. Whilst the main application I'm developing is in Java, we have to (manually) interact with Oracle databases a fair amount. Most of the Oracle tasks are scripted via Bash, and *shudders* Windows batch files.

One of our project KPIs is performance. In order to measure performance, we need to capture runtimes for various tasks. In Java this is trivial - we use Apache Log4j so can see exact timestamps against log entry, and the applications we run output performance metrics into a database for future analysis.

Gathering this data is harder when running SQL scripts - by default you don't get a log file containing runtimes. Oracle does, however, provide the ability to SELECT the current datetime. And if you can SELECT it, you can log it. As a simple solution to this problem, you can use current_timestamp:

    
This returns the following:

    
You could then use this to contribute to your log output in order to track runtimes, or to INSERT records to a database that holds runtime statistics, for example.

Whilst it's not nearly as nice an experience to work with SQL in this way compared to working with Java, for us this does the job. Done is better than perfect.

​Alex
2 Comments
John Webster link
13/10/2022 11:32:06 am

Bill affect kind share decade fast four. Guy fast but physical. Only pull fly place nearly.
Mention beat our job. Sign inside treat any rich tend. Him win home sport seven.

Reply
New Mexico Flat Roofing link
19/1/2023 01:14:27 am

Good readingg your post

Reply



Leave a Reply.

    Blog

    Tech, quotes and EDC.

    Archive

    November 2016
    July 2016
    May 2016
    April 2016
    March 2016

    Tags

    All
    EDC
    Excel
    Oracle
    Travel

    RSS Feed

Powered by Create your own unique website with customizable templates.