Month: January 2006

Updating and inserting an xml attribute

Wrote a little java function that does what I need. Oracle’s JDeveloper version of XMLDom doesn’t support Xpath so I have to search every node by hand and then find the one with the attribute set to the value I want to find, sigh. Then I update the attribute I need to update. However it does work so fine.

Ok says I, now that I know what to do let’s translate it into PL/SQL.

I’m convinced that the two functions are logically equivalent but no, they return different results, the PL/SQL one being wrong.

Will try again on Monday. Joy.

Not that I don’t have a whole ruck of more important stuff to do, of course.

This really shouldn’t be that hard and XPath should be implemented everywhere, not just for the XMLtype. But that would be too easy, wouldn’t it.

I will post the code here once I’ve got it working…

Joy.

Update: I think that you can do the XPath thing with one of the document methods that gets lists of nodes (I remember this from ages ago) but haven’t had time to look into it properly.

Oracle XMLDB – is it a bag of spanners?

This is driving me nuts

There’s a new type called XMLtype.

I can retrieve data from it no problem.

I can update an entire node no problem using XMLUpdate method, but it won’t let me update attributes. If it does I can’t find an example anywhere.

If an attriibute wasn’t supplied but you want to put it in .. how do you do it? Only half of the necessary methods have been implemented.

For those non-UK readers – a bag of spanners means that it looks useful but isn’t because you can’t find the right one, after you’ve tried all 50 of them none of them fit. It’s also used to mean a really ugly person, as in face like a … but I’d never describe a fellow human being that way.

I’m looking at the DBMS_XML package but the documentation and examples are total crap. I’m convinced there used to be a halfway decent example in the manuals but it isn’t there any more.

I’m going to do it in Java. I’ve had enough.

Fun with the Emacs Psychotherapist

I am the psychotherapist. Please, describe your problems. Each time you are finished talking, type RET twice.

yarbo adnf hfodnde bbdyyer a

Why do you say yarbo adnf hfodnde bbdyyer a?

yhnfhhd ddfdbb gfffasd ettetdfdsad

Is it because of your plans that you say yhnfhhd ddfdbb gfffasd ettetdfdsad?

bbdfdasdft tte fdfdf dasdfd egr gdffdasfasdf asdf d ffhhhfd hdhfd
fdhhdhfdjh hdha
asdfas dhhdjkhdd uuuasdf fhfheuexccveddasdf?

Maybe your life have something to do with this.

mmm

Can you elaborate on that?

ndfhdh fhdhf datdstfas dfgggfdgfhdasf if tger hf d dhfdasf

What makes you believe that?

befcydfe cyevvytadf yye cbbg asdfda hfbvgghh

Are you sure that befcydfe cyevvytadf yye cbbg asdfda hfbvgghh?

y

I would appreciate it if you would continue.

no

Defector

XEmacs is a nice GUI. Problem is, most of the handy little utilities you need are written for GNU-Emacs and they don’t work too well.

I wanted to get a function like the vi `dot.’ function, that simply repeats the last command. It’s not there in XEmacs. This has been in GNU-Emacs for ages, and there is a patch for XEmacs, but I don’t have the energy to mess about building one or contacting the guy that implemented it to see if there’s a windows build with it in.

I wanted a function like the gvim get-keyword (normally bound to ^X^P) that takes the characters you’ve just typed, scans backwards (or forwards if you use ^N) for a word like the one you’ve just typed a bit of. I found this for GNU Emacs and it would’t compile with XEmacs. Have’t tried it yet but I know it’ll work. Gvim has a way of getting a whole line but I don’t need it that much.

I wanted a function like gvim find word under cursor (bound to * for forward and # for backward)  and found a very simple example that I hacked to work in both directions; to be fair this worked on both. I’ve bound it to control- keypad * and -. I suppose if you’ve got tags it is’t that important, but I’ve yet to see proper tags for PL/SQL (not so sure about Python).

I don’t like the poor mouse menu stuff in XEmacs either. The mouse works like with X-Windows on GNU and if you hold down control you can get to the buffer menu, the edit menu and the mode menu from the 3 mouse buttons. XEmacs only gives you the mode menu on the third mouse button so you can’t do silly stuff like select. copy, move to another location, paste. The X-Window behaviour gives you that anyway in a much neater form. This functionality does’t work quite correctly in gvim so one up for GNU Emacs I think.

[[ Update Dec-06 most of this stuff is there but called something different, the copy existing word in buffer is

(global-set-key [C-return] ’dabbrev-expand)

– here bound to control-return. Find element under cursor, press incremental search and use ^K to select more and more of the word. Also works with reverse search as well. ^Y after incremental selects the whole of the rest of the line ]] 

Tabs and indentation

This is a total pain. Tabs are mode dependent and indentation depends upon the whims of whoever set up the mode you are using. In essence, to make it work correctly for the Enter key, do this in your run file (works with both):

(global-set-key “C-m” ‘newline-and-indent)

PL/SQL mode is’t quite right. When I have the time I’ll fix it and send it back to the guy who wrote it originally. I love being able to pick the procedures and functions from a list.

I’ve also got

(setq indent-line-function ‘indent-relative-maybe)

(setq-default tab-width 2)

But can’t remember why at the moment!

Rectangles

Not as good as gvim, I can mark a block and indent from it. I think that once I can remember the rectangle mnemonics I’ll be OK. Bought the O’Reilly GNU Emacs book with my Xmas book token – god I’m sad.

The XEmacs mouse rectangle stuff is difficult to use. I think the GNU will win out when I get used to it.

It’s been an interesting few days but I think my productivity will start to rise, particularly with the more powerful PL/SQL mode.

Just need to add all of my abbreviations in next …

 [[ Update Dec-06 dabbrev-expand makes running SQL*Plus a dream, press your bound key and up pops the column name or value from any other open buffer – brilliant ]]

XEmacs & Lisp – TOAD replacement

Over the Xmas break I followed a link from the Joel on software blog (see linked entry) and got to an on-line version of The Structure and Interpretation of Computer Programswhich got me looking at Lisp again. I’ve been translating the examples from Scheme to Common Lisp. At this level it’s mainly changing define for defun and moving the function name out of the list. I believe that the two languages veer more later, but you can still do useful things in them. Scheme is allegedly more restricted because it’s a teaching language. (have a look at the flame wars on the net – I’m keeping out of it)

For the first time in ages, when I was working through the questions, I was faced with a genuine mystery about why something didn’t work. Gahd it was refreshing. I had to learn how to use the GNU CLisp debugger using (step …). Then work out what the problem was.

This got me thinking about dev environments and I decided to have another go at Emacs. Downloaded XEmacs for windows and have spent some jolly time getting it to understand PL/SQL properly and do auto indentation the way I want it done. Still not quite right, but it’ll do.

Spent a pleasant time today at work with SQL*Plus in one buffer and copying stuff from one place to another and executing it.

I will post how I did things another day – I want to get some sleep now. Back at work after a nice long break and I’m feeling a bit washed out.

Joel replied to my mail and pointed out that Java isn’t really the new C; it’s the new VB. All of the irritating non-projects that used to get written in VB are now (at least some of them) being done in Java – hence all of the frameworks rather than a way to Just Get It Done. I think he’s right, and this means I’ve been learning some kind of weird proxy VB, which probably explains why I don’t like it.

TOAD replacement

Have a look at Oracle’s project SQL Developer. It looks like the SQL part of JDeveloper unbundled with some extra reports. Maybe Quest will start charging something slightly less silly for TOAD. Definitely worth a look, and it’s free.