Saturday, 18 July 2009

Harvesting Apex_Util in Oracle Forms (Or zombies are just misunderstood)

Consider this. The internet owes its early roots to military research. So every time you send an email, update Twitter or google for photos of Borat in his mankini (don't deny it; you know you do) you're effectively profiting from the deaths of helpless children, women and men. You're kinda like a zombie tap-dancing along a beach of blood, bones and brain matter. How do you sleep at night?!

In truth, most times something big is born the fallout is as useful as the main event. Which kinda got me thinking. Apex is the biggest, most innovative, freely available PL/SQL project ever built (that I know of) so I wondered if there were any useful functions or procedures I could borrow from it to use in, say, my Oracle Forms applications.

Here are some I found in the APEX_UTIL package: (If you're new to Application Express one of the most productive things you can do is spend an afternoon studying its packages and views.)

  • PROCEDURE: Pause(p_seconds in number): I haven't got a clue where this is used in Apex itself but it's so endearingly useful. For all those times where you want to slow your Oracle Forms application down, now you've got a simple solution: apex_util.pause(p_seconds); (where p_seconds is the length of time in seconds that you wish to pause for, up to a maximum of 120).
  • FUNCTION: Get_since(p_date date) return varchar2: If like me you've always felt that the ability to express a date as a function of time passed is the one flavour missing from the TO_CHAR chocolate box then this bad boy is just what you need. Cleverly it expresses time not as cold, mechanical fractions but as rounded up terms that make human sense (e.g, 1 year ago or 3 weeks ago).
  • PROCEDURE: export_application(p_workspace_id in number, p_application_id in number): This procedure (and the sidekicks it brings along like exuberant, kid brothers, export_application_page(p_workspace in number, p_application_id in number, p_page_id in number) and export_application_component(p_workspace_id in number, p_application_id in number, p_component_id in number, p_component_type in varchar2)) exports an application or a page to an HTP buffer. Nothing that revolutionary there, but as the number of applications I have mounts and begins to spread across workspaces, I am beginning to investigate ways of managing them easily. One of the ideas I'm toying with is build an (Oracle Forms?) application that gives me a better, more easily manipulated, view of my applications than the Apex environment does.
  • FUNCTION: filesize_mask(p_number in number) return varchar2: This takes in a file size in bytes and expresses it as a size in KB, MB or GB. Doesn't change the world - but then, neither does Ben & Jerry's Chocolate Fudge Brownie ice cream, and everybody loves Ben & Jerry's Chocolate Fudge Brownie ice cream, right? Yum.
  • FUNCTION: strong_password_validation: Time for a confession: I have not yet given this function a go. But if it does what it seems to be saying on the tin then it sounds very useful indeed. If you have tried it, please let me know.

I'm from Africa so it's only right that I throw in one of those exotic proverbs that Africans in Hollywood movies seem so fond of: when the lion feeds she leave enough meat for the vultures. Which either means that if you sit around doing nothing for long enough somebody's gonna give you their leftover hamburgers. Or it means that even if you've not yet made the move from Oracle Forms to Oracle Application Express that doesn't mean that you can't come dance at the Apex party.


Louis-Guillaume said...


It's always funny to read you!
Don't stop... ;)


David Njoku said...

Thanks, Louis-Guillaume. And there I was trying to be all serious! :-)