Blog is moving

My blog is moving to http://victormendonca.com/blog/. If you are looking for a specific or older post you are in the right place Otherwise check out my new page for more up to date content.

Thursday, May 30, 2013

Basic error handling for sqlplus

=> Command errors
The option WHENEVER SQLERROR will provide an error should the output of a sqlplus command be an error. If you mistype a command (like using "scelect" instead of "select"), it will not be caught here, rather it will provide an 'SP2-####' error.

WHENEVER SQLERROR EXIT [{error code}|SQL.ERROR]
# example

WHENEVER SQLERROR EXIT 1


=> OS errors

WHENEVER OSERROR EXIT [{error code}|SQL.ERROR]


=> Most errors
Using a PL/SQL block will also help catching most errors

runSelect () {
command sqlplus -S [user]/[passwd]@[sid] > /dev/null 2>&1 <

SET FEEDBACK OFF
SET LINESIZE 200
SET SERVEROUTPUT ON FORMAT WRAP
WHENEVER SQLERROR EXIT 1;
spool /tmp/[file].out

DECLARE
  cursor c1 is
  select [*|{column}] str
    from [table];

BEGIN
  for c1_rec in c1
    loop
      dbms_output.put_line(c1_rec.str);
    end loop;
END;
/
spool off

EOF
}


Wednesday, May 8, 2013

How to map a secure WebDAV share on Windows XP

I was trying to sync my Box files at work, however as I'm sitting behind a proxy I was not able to do that (the default Box client does not support proxy settings). So I decided to try and mount it with WebDAV, like I did on Ubuntu.

The WebDAV client is installed by default in Windows XP, however it seems that ssl support was only introduced in Windows Vista. Not to worry, a simple workaround can get things working for us.

1- Download and install "stunnel". This will allow us to create a listener that will communicate with Box via an encrypted connection

2- Open "Start => All Programs => stunnel => stunnel GUI Start". This will start stunnel and add an icon to your  notification area

3- Right click on the stunnel icon on your notification are and select "Edit stunnel.conf"


4- Comment the unnecessary services (disable)

;[pop3s]
;accept  = 995
;connect = 110

;[imaps]
;accept  = 993
;connect = 143

;[ssmtp]
;accept  = 465
;connect = 25


5- Add the following lines and change the "connect" for the URL of the WebDAV server that you would like to connect. Then save the file

[psuedo-https]
client=yes
verify=0
accept = 80
connect = www.box.com:443
TIMEOUTclose = 0


6- Right click the stunnel icon in the notification area again and select "Show Log Window". This will allow us to see the requests when we try to mount the drive and possibly troubleshoot any issues

7- Click on "Configuration => Reload stunnel.conf"



8- Open command prompt and mount the drive the following command

NET USE [drive letter]: "http://localhost/[path]" /USER:[WebDAV username] [password]

NET USE B: "http://localhost/dav" /USER:[Box username] [password]

Note: use the option "/PERSISTENT:YES" if you would like this to stick after reboots

You should now be able to access your WebDav files using the drive letter.