APEX Automated Row Fetch Failing Due to Primary Key of Type CHAR(20)

Ran into an interesting problem with a APEX form on a report always failing to fetch with No Data Found even when the data was plainly there in the table and the right ID item was getting set when branching to the detail page.

Turned out that the issue was because the primary key column was defined as CHAR(20) (even though it held what looked line a numeric value).

Changing the column to NUMBER immediately corrected the problem.

No mystery here, examine the data types.

CHAR is a fixed length data type, use of VARCHAR2 or INTEGER or NUMBER avoids this issue.

The use of a CHAR primary key was apparently defeating the implicit type conversion which APEX relies on.

Here's a quick recap of the Oracle Data Types Oracle Data Types

Cheers.