No evil shahs live on

That is a palindrome. Surprisingly relevant to current events.

Check this site out for more.

[via Reddit]


Comments (2)

Oracle Application Contexts

A quick writeup on Oracle Application Contexts

Link to 9i Documentation
Link to 10g Documentation

From the documentation:

Application contexts allow you to write applications which draw upon certain aspects of a user’s session information. It provides a way to define, set, and access attributes that an application can use.
An Application context is a namespace. Each Application Context namespace can have multiple attributes (name/value pairs). These are associated with a user session and can be set/accessed multiple times.

Creating Context
To create a context namespace called sls_app_context:

CREATE CONTEXT sls_app_context USING sls_app_context_pkg

To create a context namespace, you must have CREATE ANY CONTEXT system privilege.

sls_app_context_pkg is a PL/SQL package that can change the Application context.

You can only set the context attributes inside the trusted procedure/package you named in the CREATE CONTEXT statement. This prevents a malicious user from changing context attributes without proper attribute validation. The sls_app_context_pkg is the trusted package.

Set Context
Package sls_app_context_pkg would be defined as follows:
CREATE OR REPLACE PACKAGE sls_app_context_pkg AS
-- Set App Id for App User management
PROCEDURE set_app_id (p_app_id Varchar2);
-- Set period of interest
PROCEDURE set_period (p_period Integer);
-- Set App Id for App User management
PROCEDURE set_app_id (p_app_id Varchar2) IS
DBMS_SESSION.SET_CONTEXT('sls_app_context', 'app_id', p_app_id);
-- Set period of interest
PROCEDURE set_period (p_period Integer) IS
DBMS_SESSION.SET_CONTEXT('sls_app_context', 'period', p_period);

Now, the context can be set by any program unit (procedure/trigger etc) by calling the appropriate procedure from sls_app_context_pkg.

PROCEDURE login_proc IS
v_app_id Varchar2(256);
-- Set app_id context attribute
SELECT char_value
INTO v_app_id
FROM tsysstg stg
WHERE stg.code = 'APP_ID';
-- set period context attribute
sls_app_context_pkg.set_period(To_Number(To_Char(Sysdate,'MM'))); -- Assuming period is month number

Get Context
To access the context attribute value use the SYS_CONTEXT function:

v_period Integer;
v_period := SYS_CONTEXT('SLS_APP_CONTEXT','period');

This function can be used in various places. Some examples:
1. In queries (including views)
2. In PL/SQL code
3. As default values for table columns

CREATE TABLE txxxtab (
id number(10),
col1 varchar2(30),
col2 varchar2(10),
period number(10) DEFAULT SYS_CONTEXT('SLS_APP_CONTEXT','period'))
CREATE VIEW txxxtab_vw AS
FROM txxxtab
v_period Integer;
v_period := SYS_CONTEXT('SLS_APP_CONTEXT','period');
insert into txxxtab_vw values (1,'AAA','A');
insert into txxxtab_vw values (1,'BBB','B');
insert into txxxtab_vw values (1,'BBB','B');
FROM txxxtab

Built-in Contexts
There is a built-in context USERENV that provides information about the current session. Some examples:

Returns the operating system identifier for the client of the current session. “Virtual” in TCP/IP

Returns the language and territory currently used by the session, along with the database character set in the form: language_territory.characterset

Returns abbreviation for the language name

Returns auditing session identifier

Returns instance identification number of the current instance

Returns the operating system username of the client process that initiated the database session

These are accessed like user defined Application contexts i.e. using the SYS_CONTEXT function.

v_os_user varchar2(256);
v_os_user := SYS_CONTEXT('USERENV','OS_USER');

Comments (1)


Everything you wanted to know about Segmentation, but were afraid to ask.

Camels and Rubber Duckies – Joel on Software

That was all I was going to publish. But then, what’s a blog post without a rant. So here’s more. A quote from Joel’s article:

In the world of software, you can just make a version of your product called “Professional” and another version called “Home” with some inconsequential differences, and hope that the corporate purchasers (again, the people who are not spending their own money) will be too embarassed at the thought of using “Windows XP Home Edition” at work and they’ll buy the Pro edition. Home Edition at work? Somehow that feels like coming to work in your pyjamas! Ick!

I run Oracle 10g XE on my laptop running Windows XP Home Edition. I don’t run any mission critical applications, but so far XE does what I ask it to do. However, from the minimum system requirements in the XE Installation guide :

One of the following 32-bit Windows operating systems:

  • Windows 2000 Service Pack 4 or later
  • Windows Server 2003
  • Windows XP Professional Service Pack 1 or later

If I hadn’t tried to run XE on the Home Edition, I would end up spendng an extra $119 on my next PC. Given that XE itself is “free to develop, deploy and distribute” it just doesn’t make sense to put money in the competitions pocket. I wish Oracle would just publish a list of XE features that cannot be used when running Windows XP Home.


From the same XE installation guide mentioned above:

It is not possible to disable simple file sharing on Microsoft Windows XP Home. Oracle strongly recommends that you upgrade to one of the required operating systems identified in “System Requirements”. However, if you cannot upgrade, then Oracle recommends that you enable the firewall and ensure that port 1521 (or the Oracle listener port you configured during installation) is blocked. Note that blocking port 1521 blocks remote access to the database over TCP/IP.

To enable the firewall (or check that the firewall is enabled) on Microsoft Windows XP, see Microsoft Knowledge Base article number 283673, “How to turn on or turn off the firewall in Windows XP.”

So it seems the sytem requirements are not “minimum” system requirements and you can install XE on the XP Home Edition. The Professional Edition is recommended for security issues.

Leave a Comment

What really is an RSS feed?

If you have been trying to make sense of all the Web 2.0 hype, you probably have wondered what RSS is. To me an RSS feed is:

  • a mechanism to inform people of changes to your website content
  • an XML document (that conforms to the RSS specification),
  • accessible over HTTP
  • that automatically updates when you update your website content

Let's use a sample from the RSS Specification page at Harvard. The location of the RSS feed file is:

Once you point your RSS Reader to the above location, it reads the feed and displays it in human readable format. Here is what my favorite Reader, Netvibes displays:

Feed Reader

Lets take the XML file apart. The channel represents a feed.

<title>Liftoff News</title>
    <description>Liftoff to Space Exploration.</description>
    <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>

The title ("Liftoff News") usually shows up as the feed title in your reader. The link is a URL to your main site/blog etc.

The most important pieces in the feed are items. These show up as a list in your reader. If this was a feed of your blog, then each item would represent a blog post.

      <title>The Engine That Does More</title>
      <description>Before man travels to Mars, NASA hopes to design new engines
        that will let us fly through the Solar System more quickly.  The proposed
        VASIMR engine would do that.</description>
      <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>

Each item has a title, link, description and guid. The title ("The Engine That Does More") appears in the feed. The description is what appears when you hover your mouse over the item title in most readers. The link is where you are redirected to when you click the item (which is the whole purpose of publishing the feed if you ask me). I am assuming the guid is so that the reader can tell two posts apart even if they have the same title.


Leave a Comment

Monitor batch jobs with Oracle XE

Since installation, the Oracle 10g XE on my desktop has mostly been used for quickly testing how database stuff works. Last week I finally got around to digging a bit deeper into the HTMLDB/Application Express part.

Lets say you have batch jobs on your system. Every morning management requires a report of the previous day’s run. Fortunately, your batch jobs log their status in a table. Now you could always run a query against this table, spool the data and email it to management. Or you could create a report using Application Express. Consider:

  • No software to deploy on management desktops (need a browser though)
  • You aren’t the messenger that delivers bad news about batch job failures
  • A browser based report looks a lot more impressive than spooled CSV (especially when your boss is trying to impress his boss)
  • Not wastefully repetetive or mind numbingly boring

So here is how you go about impressing management:

  1. Login to your desktop Oracle XE instance as a user with DBA privileges
  2. Create a new user – say rss
  3. Create a database link to your application database(say remdb) that has the batch log table(app_batch_log)
  4. Create a public synonym (app_batch_log_remdb) for this remote table (app_batch_log@remdb)
  5. Grant select on app_batch_log_remdb to user rss
  6. Logout and login to Oracle XE as user rss
  7. Choose Application Builder >> Create Application >> Create Application from the (rather picturesque) XE menu
  8. Enter your application name and click Next
  9. Select Report as Page Type, SQL Query as Page Source and enter your query (SELECT * FROM app_batch_log_remdb). Click Add Page.
  10. Click Next thrice
  11. Change Authentication Scheme to No Authentication and click Next twice
  12. Click Create
  13. Click Run Application

Here is a screen capture of the application creation process (Steps 7 thru 13).

To deploy:

  1. Enable HTTP access to your XE instance as described here
  2. Copy the URL from the last step and replace the with your desktop IP address/hostname
  3. Send off to those interested.

Leave a Comment


Eddie Awad's blog posts have a nice row of social bookmarking icons at the bottom. These are courtesy of the Sociable plugin for WordPress. Each of these bookmarks the post at the associated social bookmarking site.

I have always thought it would be nice to have this on my blog. Since I can't use plugins willy nilly at, I had to find another way. Enter the Socializer by Pierre Far. Provides a way to bookmark your blog on a whole bunch (~40 at last count) of bookmarking sites. To make it easy to use:

1. I rolled my own chicklet : 69116222284211458404467ff.png
2. Created my custom URL<my url>%2F&title=<my title>
3. Used the image and URL to create a Bookmark to my own blog

Not the same thing, but a pretty good hack even if I say so myself.

Comments (64)



Here, here and here.

Comments (4)

« Newer Posts · Older Posts »