Browsing "Older Posts"

Using APEX_ERROR to manage custom error messages

Von Tobias Arnhold → 1.18.2017
Sometimes you just feel like you would be a newbie in coding business applications. Luckily it doesn't happen so often anymore. But this time it hit me hard. :)

During an application upgrade on Universal Theme I discovered an ugly workaround to create custom error messages I used in that time.

The old code looked like that:
declare 
  retval number;
  p_cust_id number;
  p_status varchar2(30);
  p_upduser varchar2(10);

begin 
  p_cust_id := :p1_cust_id;
  p_status  := 0;
  p_upduser := :app_user;

  retval := cust_apex_pkg.cust_apex_fnc ( p_cust_id, p_status, p_upduser );

  if retval = 1 then
    apex_application.g_print_success_message := '<span style="color: green;">Order was successfully published.</span>';
  elsif retval = 2 then
    apex_application.g_print_success_message := '<span style="color: red;">Error: Custom error 1 occurred.</span>';  
  elsif retval = 3 then
    apex_application.g_print_success_message := '<span style="color: red;">Error: Custom error 2 occurred.</span>';  
  else
    apex_application.g_print_success_message := '<span style="color: red;">Error: Unknown error occurred.</span>';  
  end if;
  commit; 
end;
As you can see I used the apex_application.g_print_success_message to overwrite the text color. Quite ugly but it worked as expected.
Anyway on Universal Theme it looked not so nice anymore because a "success message" has always a green background color. Putting some red text color above is not the user experience I would prefer.


I searched for about 3 minutes and found a really good article from Jorge Rimblas writing about the APEX_ERROR package. The blog post is from 2013 so this procedure must be available for a while now. What made me feeling like a jerk. The good side is that I now can start again to climb up on the iron throne. :)

The updated code looked like that:

declare 
  retval number;
  p_cust_id number;
  p_status varchar2(30);
  p_upduser varchar2(10);

begin 
  p_cust_id := :p1_cust_id;
  p_status  := 0;
  p_upduser := :app_user;

  retval := cust_apex_pkg.cust_apex_fnc ( p_cust_id, p_status, p_upduser );

  if retval = 1 then
    apex_application.g_print_success_message := 'Order was successfully published.';
  elsif retval = 2 then
    apex_error.add_error(
      p_message => 'Error: Custom error 1 occurred.'
    , p_display_location => apex_error.c_inline_in_notification
    );
  elsif retval = 3 then
    apex_error.add_error(
      p_message => 'Error: Custom error 2 occurred.'
    , p_display_location => apex_error.c_inline_in_notification
    );
  else
    apex_error.add_error(
      p_message => 'Error: Unknown error occurred.'
    , p_display_location => apex_error.c_inline_in_notification
    );
  end if;

  commit; 
end;

Thanks Jorges by blogging and sharing your knowledge.

APEX IR column only exportable for administrators

Von Tobias Arnhold → 1.13.2017
A few days ago I tweeted about a solution from Martin Giffy D'Souza to hide a specific column from export.


In my case I needed some username columns to be displayed during run-time but only exportable for administrators. The export itself was made with the default APEX CSV export.


Martin solutions was a really good starting point. I just had to add some security checks for the administrator role. And all together was put into a new authorization scheme which I added inside the conditional columns of my Interactive Report.

-- Authorization Scheme Name: ROLE_EXPORT_USERNAME
-- Validate authorization scheme: Once per page view

-- Code:
if pkg_security.has_user_role(:APP_USER,'ADMIN') = true or :REQUEST != 'CSV' then
  return true;
else
  return false;
end if;



A new year promises new possibilities!

Von Tobias Arnhold → 1.10.2017
The last year was quite successful even so it was a pain in the ass in many ways.
I have been on 3 conferences, made a few blog posts, got member at DOAG #NextGen, I initialized the "APEX Dashboard Competition" and I created a quite complicated example application which creates new solvable business cases for many of you: SVG in APEX.
This wouldn't be possible if I would have been alone. I worked with many different people in the community to get those activities done and I'm thankful for that.

Because I had the luck to talk to so many people I created a new idea regarding my main focus for this year "Getting students and trainees in touch with Oracle technology". This will not be just a simple presentation or some piece of code you create and publish. It is much more complicated and you can't do it alone.

By Kit from Pittsburgh, USA (Grads Absorb the News) [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

You may even have noticed it: Oracle will invest over 3 billion dollars for better education in the next 3 years. Only in Europe it will be around 1,4 billion. Something they may should have done 5 years ago. Anyway I'm curios if Oracle is just doing some great marketing slogan or if they start seeing the next generation of students as their most important invest after cloud.

In Germany we facing the problem finding new specialists since years. Except for a few companies we (the Oracle community) haven't done so much against it either.
Last year the German community woke up from their winter sleep by founding a new group inside DOAG called "DOAG #NextGen". This group focuses on students using Oracle products (Database, SQL, PL/SQL, APEX and more).

But why do we have the problem to find new students getting interested in Oracle software?
IMHO: Nowadays it is not enough to have a powerful engine and the fact that you can earn good money with it. It needs more to convince students to work with Oracle.

I tried it myself to get more students into Oracle APEX by making the APEX dashboard competition last year. Even so the competition was a success I have failed in my own focused main target: Getting new people interested into APEX.
I had do understand that it is much harder to get in touch with students then I thought. It is definitely not enough to post something in the most known IT event channels (Twitter, Eventbrite, XING, ...). It is actually the hardest and most time taking part to get in touch with them.

Luckily I don't give up so easily. At DOAG #NextGen we are planning a great event for students this year. More info's will follow.

I wish everyone a good start in 2017 and I will write about my next activities regarding students because I know that a lot of you understanding the need for Oracle specialists today, tomorrow and in 10 years.