I've used something like the following to map the up/down arros keys in xemacs:
(add-hook 'shell-mode-hook (function (lambda () (define-key comint-mode-map 'up 'comint-previous-input) (define-key comint-mode-map 'down 'comint-next-input))))
I haven't tested this with sql-postgresql and sql-oracle, but I'm assuming that they're both built on top of comint. You will probably just need to add this to your .emacs file and change the hook name.