Hopefully you’ve heard about the new SQL*Plus we’re building.
And hopefully you’ve heard about the new REPEAT command we put into it yesterday.
Here’s a quick example of how to build a little ‘monitor’ in just 2 commands, a total of 5 lines of code.
The SQL
SELECT To_Char(Originating_Timestamp, 'DD-MON-YYYY HH24:MI:SSxFF') Time_Entry, substr(message_text, 0, 75) || '...' ABBR_MESSAGE_TEXT FROM X$dbgalertext ORDER BY Originating_Timestamp DESC fetch FIRST 10 ROWS ONLY;
So run that, make sure you like the formatting, and the data of course
Then to turn that into a refreshing report, run this:
SQL>repeat 100 0.5
And that’s it.
It will run that SQL (as it was the last thing in my SQLcl buffer), 100 times, every 0.5 seconds.
The screen refreshes with an update of what iteration you’re on.
I’ve also set the sqlformat to ANSICONSOLE for the nicer auto-spacing and column headers.
What, you want an animated demo?
Ok, ok.
Here I’m causing some Alert Log entries to be added by forcing a log switch on the Container database.
About that FETCH FIRST 10 ROWS bit
That syntax is new for 12c. And it’s awesome. It’s much nicer than doing a WHERE ROWNUM < 11 or whatever. You can skip rows, read rows, etc.
Sorry I didn't make this more clear when I first posted this. Or maybe I wanted to you to try it and see this cool technology for yourself Or maybe I was lazy.
In my defense, we’ve been talking about this since 2013.