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.