Monday, April 21, 2014

How to Autostart a headless Virtual Machine Guest in Oracle Virtualbox on a Windows host


Create a text file with .bat extension containing the following line. Let's call it autostart_oracle_vm.bat

C:\Program Files\Oracle\VirtualBox\vboxheadless.exe --startvm MYVM

Now create a text file with the extension .vbs with following content, let's call this autostart_oracle_vm.vbs

Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd /c D:\autostart_oracle_vm.bat"
oShell.Run strArgs, 0, false

Now add a short-cut to autostart_oracle_vm.vbs in the following location

C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Friday, February 7, 2014

Error Stack and SQL trace

You can run the following to get an errorstack of any ORA error in a database:

alter session set tracefile_identifier =  'errorstack';
alter session set events '<error_id> trace name errorstack level 3';
--run the problematic sql here
alter session set events '<error_id> trace name errorstack off';

e.g. to diagnose error:-
ORA-00942: table or view does not exist
run:
SQL> alter session set events '942 trace name errorstack level 3';

To generate an sql trace, run the following:

alter session set tracefile_identifier =  'sqltrace';
alter session set events '10046 trace name context forever,level 12';
--run the problematic sql here
alter session set events '10046 trace name context off';

Friday, January 31, 2014

Automatically format SQL or PL/SQL code online/offline

Did you know you can automatically format your sql or pl/sql code?
Complete with indentations and colors and everything.

My Favourite tools to accomplish this online are:
sqlformat.appspot.com
and
www.dpriver.com/pp/sqlformat.htm

If you have sql developer, you can paste your code into a worksheet and press Ctrl+F7 to format the code.