In ORDS 3.0 (without APEX) I've successfully created POST and PUT handlers that use X-APEX-FORWARD to redirect to the newly created or updated resource's URL. I've tried the same with a GET handler, source type of 'plsql/block' but have not been able to get it to work. Specifically I'm trying to implement a query at a base URL that will derive a URL, then set the X-APEX-FORWARD response header value to that derived URL and trigger a redirect.
E.g. I want to issue a GET request with the following URL - https://<server>:<port>/ords/x/y/qry/?inv_number=123456
The URL returned should point to the account number this invoice applies to (as an example).
For demonstration purposes I have defined templates, handlers and parameters as follows:
begin
ords.define_template(p_module_name => 'y'
,p_pattern => 'qry/'
,p_comments => '');
ords.define_handler(p_module_name => 'y'
,p_pattern => 'qry/'
,p_method => 'GET'
,p_source_type => 'plsql/block'
,p_source =>
'begin
if :inv_number is not null then
for rec in (select utl_url.escape(''../accs/i.account_number||''/'') account_url
from invoices i
where i.invoice_number = :inv_number)
loop
:location := rec.open_invoices_url;
:status := 302;
end loop;
else
htp.p(''...'');
:status := 200;
end if;
end;
'
,p_items_per_page => 25);
ords.define_parameter(p_module_name => 'y'
,p_pattern => 'qry/'
,p_method => 'GET'
,p_name => 'X-APEX-FORWARD'
,p_bind_variable_name => 'location'
,p_source_type => 'HEADER'
,p_param_type => 'STRING'
,p_access_method => 'OUT'
);
ords.define_parameter(p_module_name => 'y'
,p_pattern => 'qry/'
,p_method => 'GET'
,p_name => 'X-APEX-STATUS-CODE'
,p_bind_variable_name => 'status'
,p_source_type => 'HEADER'
,p_param_type => 'INT'
,p_access_method => 'OUT'
);
commit;
end;
I'm not sure what is materially different here from what I am doing in my POST and PUT requests, but this invocation will not return anything. If I put an htp.p() expression within the loop to display the selected value, this shows when called by a client, so the problem is not with the data.
Any help on this greatly appreciated.
Regards,
Ryan.