Wednesday, 30 January 2013

Dynamic Action hidden False actions

I thought I'd share what's quite literally a hidden problem I experienced in 4.1.1 involving dynamic actions.

The project used hundreds of dynamic actions, and often I would copy them between pages.

Something to watch out for, however, is the cleaning up APEX does with dynamic actions in it's own builder. I've notice in the past the meta-data I saw in dictionary views contained stale information, hidden after no longer being needed when adjusting some other attribute - like condition types.

By looking at the stock debug, I noticed that a good portion of my page render time was for dynamic action plug-ins. One of these was for the notification plug-in supplied by Oracle (gritter). Over time the number of notifications on the Global Page Zero had grown - but in my case could be consolidated using &ITEM. substitution syntax to define the title & message.

But there were still more instance of the gritter notification in the rendered page sauce than was expected, so I looked a little harder...

In regard to dynamic actions, beware the non-condition - in past I must have copied this from another action; removed the event "when" condition; the false action region was hidden from the developer, but and a false action remained - causing unnecessary rendering of a plug-in, hence performance issue. What a paragraph, hope that made sense!

All I saw when editing the item were the True actions.
True actions for DA with no JavaScript "when" event condition
By changing the when condition to "equal to", I was able to see the previously hidden False action.
screenshot actually from 4.2
Sure enough - there it is
A hidden False action, displayed when condition restored
So I had a few false actions to remove that would never fire.

You can find such cases yourself with the following SQL - I used this query to check for other issues.
select * 
from   apex_application_page_da d
-- no when condition present
where when_condition is null 
--and dynamic_action_name = ''
and application_id = 104
and page_id = 0
and exists  -- a false condition
  (select null 
   from apex_application_page_da_acts a
   where a.dynamic_action_id = d.dynamic_action_id
   and dynamic_action_event_result = 'False')
/

I saved about .05 seconds each plug-in render, so notifications in page zero added up over time. I saved about third of a second in my clean up of these alone. Plus I was finding other minor performance gains - they all add up!

Scott

Tuesday, 29 January 2013

Learning Oracle APEX? Try these books

If you're a reasonably confident Oracle developer and want to learn Oracle Application Express via books - I would recommend the following:

Start:

Pro APEX 4 - I read the original and I trust the updated would be even better. Start strong and solid.

Detail:

Expert APEX - compendium of great topics written by multiple authors, for a good cause.

Refine:

APEX Best Practices - Brilliant book to help make sure you properly apply what you've learnt above.

Future:

APEX Mobile - to be released this year, if you want to keep working in Oracle web development this decade, you'll need to read this. It's been brilliant so far.

Update August 2016
Time have changed, APEX 5 provides big improvements in development productivity and style, and the Universal Theme changes things, too. Look here for the best list of APEX books
apex.oracle.com/books 

For added bonus, here is one on APEX Security - on my to read list but the chapters look spot on.

Some of these I've reviewed already, plus others that are available.

If you want to keep up-to-date with what people are doing around the world, or pick up tips and tricks - subscribe your preferred blog reader to apexblogs.info - an aggregation of Oracle APEX blogs

For those perhaps not so confident, or would like to see things being done instead of reading them - I'll be publishing something early this year - stay tuned!

Scott

Thursday, 24 January 2013

What if Google went bust?

Ever consider that? What would you lose?

During life we put a spectrum of trust in different areas, depending on our own risk assessment. We originally entrusted our tribe members to help protect the community. Now, we might give a dollar to a little boy to fetch us something, and we might not get it back. Who cares? it's a buck.
We trust out mortgage to the banks because they have a proven history of money management.

So what about your data? I trust Google with a lot of my content. In fact, not really content, but information. Dates, numbers, links, hints, prompts, memories...
It's hard to back up because it's a network of information. A lattice that Google so elegantly lets you search.

We occasionally joke about our reliance on these modern devices when an old fashioned diary will do - but what happens when you lose that? I was listening to an interesting podcast recently from our public broadcaster ABC, a program called "All in the mind". A recent discussion on memory suggested we've been using these aids in various forms to help us remember from computers to paper to papyrus to cavern walls - so what's the matter with using this tool aiming for a device harmoniously engineered for bio & robotics. Well, maybe I added some thoughts in the description - but a program well worth a listen.
http://www.abc.net.au/radionational/programs/allinthemind/new-document/4420956


On a slight tangent (ba-dum), searching is an interesting topic itself - what if all information humanity knows about the universe was in a cube the size of a dice? Search facilitation would have to be impeccable. Search companies are never going to die (altavista? well, companies that aren't a verb in the Oxford English Dictionary)

If Google went bust, I'd be in the doo doo.

So what about your personal finance software? What if that went bust? or your hard disk died? laptop stolen? fire?
How much information would you lose? How easy is to backup? Copy the export to a disk, thumbdrive, cloud service, cd - somewhere off-site.

And know how to get it back.

Risk vs benefit vs simplicity.

I have what I feel is a very strong password - that's all you need, right? Remember the TV show "Weakest Link", think about that with your security. Cars used to be hot-wired, now they can't so criminals steal keys out of houses.

Heck, what happens when our cars start integrating via bluetooth with more intelligence to other aspects of your life? Smartphone applications getting more advanced and integrated than Google's My Tracks or Angry Birds.

People are being asked to put passwords everywhere now right? People using simpler passwords and not caring about that added security because it's too hard an unnecessary - who would be interested in me, right?

Shit happens and sometimes it gets up your nostrils. People might start to take notice - sites are providing shared authentication through a number of accounts - google, facebook, twitter - so the closer we get to one-size-fits-all authentication, we can perhaps think about just having one good, strong, but easy to remember password.

So, passwords is too strong for a super duper force of networked computers to hack? well try basic social engineering.

I think everyone should read the story of Mat Honan, a man who's heavily invested digital life was destroyed with a simple phone call.
http://www.wired.com/gadgetlab/2012/08/apple-amazon-mat-honan-hacking/all/

He lost all his information, and tells the horrible story of someone gaining access to a single point of his online identity, then trail blazed from there - just by someone pretending to be him on a phone, getting a password reset. All because they liked his 3 letter twitter handle.

I've had this rambling drafted for a while, and now I encounter the perfect concept to take away from this - Google has now announced a war on the password.
http://www.wired.com/wiredenterprise/2013/01/google-password/

I've always had interests in various security aspects of computer science, and I think this will be an interesting part of the journey. I wonder which science fiction writers ended up being right in helping us imagine the future we encounter?

When will we close a year of technology and comment on the general disappearance of the common password, gone like the day of the 3.5" disk that fits perfectly in your starched shirt chest pocket?

Wednesday, 23 January 2013

Which pages are locked in APEX?

Would you some SQL to tell you which pages are locked?

As far as I could tell, there is no data dictionary view that this information.

So I found this using the all_tab_columns view
SELECT 
  id
 ,flow_id
 ,object_id
 ,locked_by
 ,locked_on
 ,lock_comment
 ,security_group_id
FROM apex_040200.wwv_flow_lock_page
WHERE 1=1
--AND   flow_id   = :APP_ID 
--AND   object_id = :APP_PAGE_ID
/
I used it to add a region (bound to a build option) that displayed a notification in the sidebar to other developers that the page was locked and under construction/change/development.

Scott.

ps - can you find the joke on this post?

Thursday, 17 January 2013

Thursday Thought: Helicopters, batteries & squid

First of all, this photograph was difficult to take.

Second of all, this is one of the most fun inventions ever.

And I have a greater respect for helicopter pilots. I found an even better backdrop, but this little thing is highly sensitive to wind.

The question I'd like to ask is - when are scientists going to make even moderate gains in battery efficiency? This thing last less than 20 minutes per USB charge.

Update 2013-1-24
I have some data points - only 3, but better than a guess.
MI:SS

08:44 - in garage, wind affected,  charged previous day, left to drain?
16:13 - inside home, occasional breaze, longer flight times, recent charge, flying lights on - did I write down total, not lap time?
07:30 - inside home, occasional breaze, longer flight times, recent charge, flying lights off

04:47 - inside home, light breeze, mostly flying, charged previous day, left to drain? 
07:26 - inside home, light breeze, mostly flying, just charged

I've gathered no data as yet on charge times.
I want a bigger copter ;-)


Imagine what scaling down battery size, the way microcomputers and hard disks have paved a path to miniature. After healthcare, of course, think about what you might like to do?

Think exploratory devices - for caves you could use perhaps like the ones I just saw in Prometheus, but as quadcopters? Clever people are already using these to map rooms and find things, good steps towards disaster relief efforts.

But my number one would be the oceans.

Who shall I quote talking about how much we know about astronomy and cosmology, compared to the dark, inhabitable depths of the world's ocean. 95% of ocean ready to be explored - the other, final frontier.

All this seeded by the announcement of footage of a giant squid airing recently on NHK - I can't wait to see that footage on Discovery.

Impressive as this is, finding a kraken would be the one cryptid I'd like come true!

Who knows what other discoveries could be made by an autonomous, sensor laden, self propelling robot with the capacity to last for days?


Wednesday, 16 January 2013

Using SQL to view APEX session state

There are times (mobile development, multi-browser development, most Fridays) when checking out what's in session state isn't as easy as clicking a button in the developer toolbar.

One option is to utilise provided data dictionary views and a supplied API.
select item_name, component_comment
      ,apex_util.get_session_state(item_name) session_value
from  apex_application_page_items
where application_id = :APP_ID
and   page_id        = :APP_PAGE_ID
Update - this query locates values for Page Items, you can also use apex_application_items to view Application Item values. I used both in my debug page (thanks, Marko)

You could include this as a link to a popup from the navigation bar, or a region on a global page (page zero) that is conditionally displayed using a build option.

You can also interrogate session state using SQL in your favourite IDE, but there's a catch.

If you have access to objects in the APEX owner, you can run a query like this to view session state detail:
select s.remote_addr
      ,d.flow_id app_id
      ,i.display_sequence seq
      ,d.item_name, d.item_value_vc2 item_value
      ,d.item_filter
      ,d.session_state_status
      ,d.is_encrypted
      ,s.cookie the_user
      ,s.security_group_id
      ,d.flow_instance
      --,d.* 
from apex_040200.wwv_flow_data d
    ,apex_040200.wwv_flow_sessions$ s
    ,apex_application_page_db_items i
where d.flow_instance = s.id
and   i.item_id(+)    = d.item_id
--and   s.security_group_id = 100001 -- workspace group ID 
--and   item_name is not null
and   flow_instance   = 4359890239697682 -- session ID
and   flow_id < 4000 -- ignore dev builder et al
order by flow_id, i.display_sequence, d.item_name
In my local laptop I have this query handy in SQL Developer, replacing the session ID in the highlighted line to whatever is shown in my browser's address bar. If you aren't talking about your local laptop, and have a good relationship with your DBA, perhaps this could be turned into a view
CREATE VIEW apex_040200.apex_session_state AS...

Then grant SELECT on the new view to your schema owners, and create a synonym. Note, if any item is set to encrypted, you still won't be able to read the item value. This view was also particular to 4.2, it was previously d.item_value -- _vc2

At the end of the day, there is more than one way to check out session state.

Scott

ps - on a related note, here is another way to check out the alert log
Exposing the Oracle Alert Log to SQL - Neil Chandler

Monday, 14 January 2013

Review: Agile Oracle Application Express

Agile development is a term I've been familiar with for a while, and when you pair it up with a technology such as APEX - it makes for an interesting book.

I was a technical reviewer for Agile Oracle Application Express, written by Patrick Cimolini and Karen Cannell. This means the team at apress sent me chapters of the book as they were written, so I could provide any comments regarding code, or the understanding thereof.

If you're interested in how APEX projects might come together using Agile techniques - this is the book for you. If you don't really know what "agile" is all about, but use the Oracle APEX product - this is a book for you.

This was some time ago, memory has faded, and my comments may be out of date as some of these were garnered & paraphrased from my TR comments.

Chapter 1, Agile Software Development

I found this a great summary of what agile is all about

Chapter 2, Agile and APEX

Sometimes I found the links a little tenuous, but as the book went on I could see more detail on how the bigger picture joins together. It also seemed very pro-APEX, why not, but I like seeing authors provide a genuine perspective sometimes. Not be quite so "selly"

Chapter 3, Oracle APEX vs enhanced APEX

The first half got a little boring as it essentially lists APEX features at at 4.1, but tell you what - if you aren't aware of why APEX has in it's toolkit, you will be now.
Then it got onto how APEX can be enhanced, and how this relates to Agile. The further the book went, the stronger this was affirmed.

Chapter 4, Supporting Technologies.

This is where the book reminds you it's not all about APEX, but then goes into awesome detail on those features and how they fit into the Agile model. A heap of information in this chapter.

Chapter 5, Project Management

This took me back to university days, learning about project models and "software engineering". It got a little too textbook for my liking.

Chapter 6, Team Development

This module was added to APEX 4 and according to David Peake it was initially built internally for the APEX development team.
This chapter is a must when talking about agile, and goes into good detail with regard to gathering Feedback and distributing it across environments.

Chapter 7, Rules and Guidelines

This is an important chapter regarding agile development considerations with APEX and is full of quality. Agile still needs structure.

Chapter 8, Documentation

I'm a big fan of good documentation, and suggesting ideas on how to best utilise it. I enjoyed reading this chapter, but in hindsight I think Instrumentation needs to be included here.

Chapter 9, Quality Assurance

Something I'm sure every project can improve on. I think if every project took advantage of the 6 ideas portrayed here, software around the world would be further on the way to awesome.

Summary

It's refreshing to read an APEX book that isn't super technical and full of code, yet still be a good guide on how to run projects that use rapid development tools such as APEX. I recommend the read.

Other reviews can be found here.

Scott