Search code examples
oracle-apexbind-variables

setting a datetime into global application item


Oracle APEX 24.1

  • I have 3 application items. enter image description here

  • I have this procedure

      procedure set_globals is    
      begin 
    
      apex_debug.message(p_message => 'Setting system globals'); 
      apex_util.set_session_state('G_DATE', sysdate); 
      ....
      ....
      apex_debug.message(p_message => 'System globals set');    
    
      exception when others then 
      apex_debug.error(p_message => 'Error setting global variables: ' || sqlerrm); 
    
      end set_globals;
    
  • I call this procedure on my Application Security Attributes page's Database Initialization PL/SQL Code section.

  • I have a page to see what these variables hold

enter image description here

my question: I couldn't get sysdate assigned to G_DATE as dd/mm/yyyy hh24:mi:ss

Can someone tell me what am I missing here?


Solution

  • Looks like a rounding issue. In apex, items (both application and page) do not have a datatype under the hood. They're all strings. So... try TO_CHAR(SYSDATE, 'DD/MM/YYYY HH24:MI:SS') instead.