Skip to content

Instantly share code, notes, and snippets.

View hhudson's full-sized avatar

Hayden Hudson hhudson

  • Insum Solutions
View GitHub Profile
@hhudson
hhudson / apex_debug_javascript.json
Last active November 9, 2023 21:09
Javascript apex debug snippets
{
"ad 0.0 create session": {
"prefix": "ad create session",
"body": [
"apex_session.create_session(p_app_id=>$1,p_page_id=>$2,p_username=>'HHH');"
],
"description": "Create session to run outside of apex"
},
"ad 0.1 enable debug": {
"prefix": "ad enable debug",
@hhudson
hhudson / logger_snippets.json
Last active November 2, 2023 19:57
logger snippets
{
"logger_0 gc_scope_prefix": {
"prefix": "logger_0",
"body": [
"gc_scope_prefix constant varchar2(31) := lower($$plsql_unit) || '.';"
],
"description": "Define the logger scope prefix at the top of the package body"
},
"logger_1.0 l_scope": {
"prefix": "logger_1.0",
@hhudson
hhudson / apex_debug_snippets.json
Last active November 9, 2023 20:39
apex debug snippets
{
"ad 0.0 create session": {
"prefix": "ad create session",
"body": [
"apex_session.create_session(p_app_id=>$1,p_page_id=>$2,p_username=>'HHH');"
],
"description": "Create session to run outside of apex"
},
"ad 0.1 enable debug": {
"prefix": "ad enable debug",
@hhudson
hhudson / nav_search.sql
Last active July 28, 2023 16:02
nav menu search for search configuration (AIT ep 117)
select aale.list_entry_id,
aale.entry_text,
aale.entry_target,
apex_plugin_util.replace_substitutions (
p_value => aale.entry_target) entry_url,
aale.entry_attribute_01,
aale.authorization_scheme,
aale.entry_image
from apex_application_list_entries aale
inner join apex_applications aa on aa.application_id = aale.application_id
@hhudson
hhudson / appShortCutsLoad.js
Created December 9, 2022 17:26
Example code from Episode 94
window.onload = function() {
apex.actions.add({
name: "page-help",
label: "Get Page Help",
action: function getPageHelp(){
$('[data-id=pageHelp]').click();
}
});
@hhudson
hhudson / ait_logon_trigger.sql
Last active November 4, 2022 15:48
A Database Logon Trigger to set session values (enable PL/SQL Warnings, for eg)
/*
* This script needs to be run from a privileged account with the following grants (SYS will work):
* • GRANT CREATE TRIGGER TO {your privileged schema};
* • GRANT ADMINISTER DATABASE TRIGGER TO {your privileged schema};
*/
create or replace trigger ait_logon_trigger
after logon on database
when (user not in ('SYS','SYSTEM') and user not like 'APEX%')
begin
@hhudson
hhudson / V_EXECUTION_STATS.sql
Created June 17, 2022 15:55
query used in AIT episode 78 to retrieve the dbms_hprof results
create or replace force view v_execution_stats as
with execution_stats as (
select fi.runid,
fi.symbolid,
pci.parentsymid,
rtrim(fi.module || '.' || nullif(fi.function,fi.module), '.') as unit,
nvl(pci.subtree_elapsed_time, fi.subtree_elapsed_time)/1000000 as subtree_elapsed_time_seconds,
nvl(pci.function_elapsed_time, fi.function_elapsed_time)/1000000 as function_elapsed_time_seconds,
fi.line#,
nvl(pci.calls, fi.calls) as calls,
@hhudson
hhudson / apex_ir_example.sql
Created June 3, 2022 15:18
APEX_IR PLSQL used in APEX Instant Tip
DECLARE
l_report APEX_IR.T_REPORT;
l_region_id apex_application_page_regions.region_id%type;
l_binds varchar2(4000);
BEGIN
select region_id
into l_region_id
from apex_application_page_regions
where application_id = :APP_ID
and page_id = :APP_PAGE_ID
@hhudson
hhudson / apex-detect-changed-items.js
Created April 9, 2021 13:32
Javascript to enhance the 'Warn on Unsaved Changes' UX with item-level call-outs
//window.onbeforeunload = confirmExit;
/* The below will not run unless the above is uncommented.
* The recommendation is to run the above command in a
* dynamic action on page load of Page 0 with the Server
* Side Condition of 'Rows returned' for the following query:
* select 1
* from apex_application_pages
* where application_id = :APP_ID
* and page_id = :APP_PAGE_ID
* and warn_on_unsaved_changes = 'Yes'