Databases Reference
In-Depth Information
attr value => 'handle request');
END;
/
The path-alias-procedure attribute is the interesting bit. This allows us to define the name of a
procedure which will be called whenever we reference the /training/rs URL—in this case we want it to
call a procedure called handle request which will be in the TRAINING schema, since that was the schema
we authorized in the DAD.
The final step is to define the handle request procedure:
CREATE OR REPLACE PROCEDURE handle request(p path IN VARCHAR2) IS
l path arr apex application global.vc arr2;
l path VARCHAR2(32767);
l id VARCHAR2(32767) := NULL;
BEGIN
l path arr := apex util.string to table(p path || '/', '/');
l path := l path arr(1);
l id := l path arr(2);
CASE LOWER(l path)
WHEN 'foo' THEN
htp.p('You did FOO!');
WHEN 'google' THEN
owa util.redirect url('http://www.google.com');
WHEN 'sales' THEN
owa util.redirect url('/apex/f?p=SALES:HOME:0');
ELSE
HTP.Print('Page not found.');
END CASE;
END handle request;
This is quite a simple example; your real procedure would most likely be more complex. The key
things to note are that at the beginning of the procedure we break the incoming path into the
component parts, using the apex util.string to table command, so that we can compare them. Then
using a simple case statement we can perform specific actions based on what the incoming URL was.
For example:
If the URL is http://yourserver/training/foo then the browser displays the
message “You did FOO!”, as shown in Figure 1-23.
If the URL is http://yourserver/training/rs/google then the browser redirects to
http://www.google.com .
If the URL is http://yourserver/training/rs/sales then the browser redirects to
the APEX application with an alias name of SALES and the page with alias HOME.
Search WWH ::




Custom Search