CoinHive

Monday, January 8, 2018

Apex copy page does not change items consistently

Being able to copy a whole page with all its items, region, processes and logic with just a few clicks is just awesome right? Today I was confronted with an inconsistency (could be either a bug or a feature) in Apex 4.2.

When you copy a page, Apex copies and renames all the items. An item :P1_NAME on page 1 will be copied to page 2 and named :P2_NAME  and so on. A cool feature is that processes are copied too and whenever a page item is referenced in a page process, the copied process will reference the corresponding copied page item.

Our development team often uses this copy functionality, either to back up a page or to test some implementations. What we found today is that in the case of conditions, Apex does not change the items, as you would expect it too. In our case specifically, we have a report on a page with one conditional column. The column was rendered only if a page item had a specific value.
For example:
On page 1, region Employees, column Salary should only be rendered when item :P1_SALARY_VISIBLE has a value 'Y'. After copying this page to page 2, you would expect that the condition on column Salary would reference :P2_SALARY_VISIBLE, but it does not. It still references the item on Page 1.

I should test if it still happens in Apex 5, but I'm already tired of finding this bug.

Tuesday, January 2, 2018

ORA-01427: single-row subquery returns more than one row... but not consistently?

Today we had an issue with saved reports. A clients application has a page with an interactive report based on a view. The source of this report is fairly simple:
select * from some_view; 
What could go wrong right? For one thing, some of the saved reports were throwing an ORA-01427 error and some were not. Even worse, the view did not have any errors and running the query in SQLDeveloper did not result in errors.

Eventually we found the problem. SQLDeveloper shows the first 50 records. It's very possible that an error takes place in a result set which is not shown. In our case the view was something like:

select p.last_name
     , p.first_name
     , p.date_of_birth
     , p.city
     , (select c.country
          from cities c
         where c.city_name = p.city
        ) country
  from persons p; 

So I guess the lesson learned is, that when you have select statements in the select part of your query, you should make sure to return all rows when debugging.

Oooorrrr... like my mentor Frank would say: "Don't put a select in the select part of your query!".