Forum Stats

  • 3,873,230 Users
  • 2,266,520 Discussions
  • 7,911,476 Comments

Discussions

LPAD removes trailing value in IG text field column validation with format mask

Indy Maat
Indy Maat Member Posts: 1 Green Ribbon
edited Dec 21, 2021 1:33PM in APEX Discussions

I have an Interactive Grid with a text field column (DEVULTD). This text field represents a 24-hour clock and is saved as a Number(4,0) in the database. The format mask is set to 0000 so that the following values are formatted correctly upon render of the IG:

  • 1 -> 0001
  • 30 -> 0030
  • 110 -> 0110
  • 1730 -> 1730

When processing, we validate this clock with another date to determine if it is after a certain date. To be sure we are validating the right 24-hour clock value we use LPAD(:DEVULTD, 4, '0'). However, when using LPAD in combination with the format mask, LPAD seems to remove a trailing number. The following values have been logged using apex_debug.info():

apex_debug.info(':DELVRDT = ' || :DELVRDT);
apex_debug.info(':DEVULDT = ' || :DEVULDT);
apex_debug.info(':DEVULTD = ' || :DEVULTD);
apex_debug.info('lpad(:DEVULTD, 4, ''0'') = ' || lpad(:DEVULTD, 4, '0'));
apex_debug.info('lpad(:DEVULTD, 4, 0) = ' || lpad(:DEVULTD, 4, 0));
apex_debug.info('lpad(to_char(:DEVULTD), 4, ''0'') = ' || lpad(to_char(:DEVULTD), 4, '0'));
apex_debug.info('to_date(:DELVRDT, ''DD-MM-YYYY HH24:MI'') = ' || to_char(to_date(:DELVRDT, 'DD-MM-YYYY HH24:MI'), 'DD-MM-YYYY HH24:MI'));
apex_debug.info('to_timestamp(:DELVRDT, ''DD-MM-YYYY HH24:MI'') = ' || to_timestamp(:DELVRDT, 'DD-MM-YYYY HH24:MI'));
apex_debug.info('to_date(:DEVULDT || '' '' || lpad(:DEVULTD, 4, ''0''), ''DD-MM-YYYY HH24MI'') = ' || to_char(to_date(:DEVULDT || ' ' || lpad(:DEVULTD, 4, '0'), 'DD-MM-YYYY HH24MI'), 'DD-MM-YYYY HH24:MI'));
apex_debug.info('to_timestamp(:DEVULDT || '' '' || :DEVULTD, ''DD-MM-YYYY HH24MI'') = ' || to_timestamp(:DEVULDT || ' ' || :DEVULTD, 'DD-MM-YYYY HH24MI'));
apex_debug.info('to_timestamp(:DEVULDT || '' '' || lpad(:DEVULTD, 4, ''0''), ''DD-MM-YYYY HH24MI'') = ' || to_timestamp(:DEVULDT || ' ' || lpad(:DEVULTD, 4, '0'), 'DD-MM-YYYY HH24MI'));



When not using the format mask, LPAD is working as expected however, the values are not formatted how we want:


Any chance this is a bug? Or am I missing something here?


Kind regards,

Indy Maat

Tagged: