One of those packages announced in Oracle APEX 5.1 that are deprecated, and which I used a lot, was apex_util.string_to_table.
For example, in APEX Office Print (AOP) we read the session state of page items and we have some code like this:
declare
l_string varchar2(4000) := 'P1_X:P1_Y';
l_page_items_arr apex_application_global.vc_arr2;
begin
l_page_items_arr := apex_util.string_to_table(p_string => l_string, p_separator => ':');
for i in 1..l_page_items_arr.count
loop
sys.htp.p(l_page_items_arr(i)||':'||apex_util.get_session_state(l_page_items_arr(i)));
end loop;
end;
As the function is deprecated and APEX is already on release 18.1, it's good to start replacing those calls. The new function you can use is apex_string.split.
The above code becomes then:
declare
l_string varchar2(4000) := 'P1_X:P1_Y';
l_page_items_arr apex_t_varchar2;
begin
l_page_items_arr := apex_string.split(p_str => l_string, p_sep => ':');
for i in 1..l_page_items_arr.count
loop
sys.htp.p(l_page_items_arr(i)||':'||apex_util.get_session_state(l_page_items_arr(i)));
end loop;
end;
Depending on your application, you might need to be careful. For example with AOP, we support customers with versions of Oracle APEX 5.0, 5.1 and 18.1. We can't really force customers to move to higher APEX versions, so the way we solve it is by using conditional compilation of our code. If we see you are on APEX 5.1 or above we will use apex_string.split if not, and you are still on an earlier version, we will use apex_util.string_to_table.
Here's an example of what the code with conditional compilation looks like:
$if wwv_flow_api.c_current >= 20160824
$then
l_page_items_arr := apex_string.split(p_str=>l_string, p_sep=>':');
$else
l_page_items_arr := apex_util.string_to_table(p_string=>l_string, p_separator=>':');
$end
Note the conditional compilation you also need to do on the variable if they are different, or you can choose to conditional compile on the entire function.
To conclude, I recommend with every new release of Oracle APEX to look for deprecated components and search for those and make notes to change those when needed.
Thanks for this Dimitri - I just spotted that this function is deprecated in the 5.1 API Guide.
ReplyDeleteIs there a way to easily search for ALL deprecated features that are being used by an application? Or is it a case of checking documentation for deprecated functionality and manually trawling through the application for each deprecated API call?
Hi Steve,
ReplyDeleteIn APEX if you could go to Application - Utilities and click the Upgrade Application link - it will show you things to upgrade.
This mostly works for APEX itself eg. Anychart to JET chart.
For the PL/SQL API you could write a query to check the meta-data for things that are deprecated.
I don't know a tool that does it for you. We (APEX R&D) have some plans in creating this, but that is not there yet today.
Hope that helps,
Dimitri
Hello what, about the return values, in some point maybe that functions returns a different type of values right ? ... What are your recommendations at that point
ReplyDeleteThanks your example helped me a lot
ReplyDelete
ReplyDeleteIs it possible to use the apex_string.split function without installing APEX? We cannot install APEX on a system, but would like to use the feature.