Wednesday, 30 June 2010

ZX: All The Colours (Colors?) of the Rainbow

It is probably this machine (ZX Spectrum+, see photo) that started me on the rocky road to working in IT. Many an hour was spent loading programs from tape, the reassuring electronic screech still rings in my ears (I should get that checked), the multicoloured loading pattern is etched in my memory and the electronic attempt at the sound of a motor as I played F1 simulators.

I spent many an hour coding in BASIC, typing in reams of code from books to be disappointed by the resulting game. We all have to start somewhere but .NET kids nowadays don't know the half of it!

Many computers followed, BBC Micro, Acorn, Atari, 286, 386, 486, Cyrix 586 and then they get a bit boring and modern for my liking.

Great news for iPhone users though, for the princely sum of £0.59 you can get a ZX Nostalgia app and play some classic games so check it out.

That is my inner super geek purged for a while.

Friday, 25 June 2010

LOBs the wrong and the wright way

I've been troubleshooting an ORA-06502: PL/SQL: numeric or value error although there is an official explanation of what causes this problem it is all to often not obvious where to look to resolve it, no line numbers or anything.

Although clobs can in theory store gigs and gigs of data if you dont handle them correctly Oracle will throw up an error long before you even get to 1 gig of data. Secondly if you do not do things correctly then Oracle will re-index a clob every time you append data to it, this uses up unnessary processing power on the database server.

So if you are writing clobs make sure you

  1. CREATE TEMP CLOB
  2. OPEN CLOB
  3. WRITE/APPEND CLOB
  4. CLOSE CLOB
  5. FREE CLOB
The code might look a bit like this:
DECLARE

V_CLOB CLOB;
V_IN VARCHAR2(10) := 'TEXT IN';
V_IN_LEN NUMBER;

BEGIN

--Creates clob or blob in temp tablespace
dbms_lob.createtemporary(V_CLOB, TRUE);

--opens the clob in read/write mode
dbms_lob.open(V_CLOB, dbms_lob.lob_readwrite);

--if you have lots of data to append you can use a loop here

--get lenth off data to add to clob
V_IN_LEN := LENGTH(V_IN);

--use writeappend to add text to the clob
dbms_lob.writeappend(V_CLOB, V_IN_LEN, V_IN);

--if you were using a loop you would probably end it here

--close clob
dbms_lob.close(V_CLOB);

--although it's closed you can still access the clob here

dbms_output.put_line(V_CLOB);

--when you dont need the clob data anymore ditch it!
DBMS_LOB.FREETEMPORARY(V_CLOB);

END;


Thursday, 17 June 2010

ESCAPE!

Just a quick and simple tip today.

If you are using TO_CHAR in PL/SQL or Oracle SQL you can escape any non-formatting characters by surrounding them in double quotes. For some reason they don't mention this on PSOUG or techonthenet.

Try it out with this SQL statement:
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD"T"HH:MM:SS"Z"') FROM DUAL

Tuesday, 15 June 2010

XPath Visualizer

Having been doing a bit of work with XML and XPATH recently I've been using the XPath Visualizer tool which has been a bit of a life saver.

It allows you to test your XPath statements against any given XML and highlights the XML that would be selected, very simple but very handy.

Check it out here: http://xpathvisualizer.codeplex.com/

Tuesday, 8 June 2010

SOAP on a rope

I'm doing some work with SOAP requests at the moment and I wanted a program to test the web services without having to use my own code. There were not that many offerings out there but soapUI seemed to fit the bill.

It comes in an open source FREE flavour and a pro version but the open source version is pretty good.