Skip to main content

Posts

Showing posts from December, 2022

APEX Tabs with Badges

D Did you ever wanted to add badges to the tab names in Tabs component ? You might expect this will be simple. But it is not. You add a <span> to the name and your tabs will break (see the image below). Expected result is on the right. So what you need to do? assign TABS static id to your Tabs region assign any static id to all your tabs (subregions) create page item for each tab fill these items however you like create DA to add these badges after the tabs are created adjust CSS styles to your needs Here is the DA which will map your badge items to the proper tabs. So on page 1 it will map P1_ TAB_A _BADGE item to the TAB_A tab (subregion with TAB_A static id). setTimeout(function() { var tabs_id = 'TABS'; // static_id for the Tabs region var badges = '_BADGE'; // postfix for badge items // if (!$('#' + tabs_id)) { return; } var tabs = apex.regio...

Adding/dropping columns in a repeatable way

O On one of my projects I have to create patch scripts to add columns to a table or remove them. Thing is, that they might be run multiple times or might get different result on different environments. So I created this simple script where I can define which column in which table I need to add or drop and it will skip what was already done. Keep in mind that I am not solving changed data types nor the column positions. PROMPT PROCESSING TABLE CHANGES -- SET SERVEROUTPUT ON BEGIN FOR c IN ( WITH x (action, table_name, column_name, data_type) AS ( SELECT 'ADD', 'TABLE_NAME', 'COLUMN_NAME1', 'NUMBER' FROM DUAL UNION ALL SELECT 'DROP', 'TABLE_NAME', 'COLUMN_NAME2', NULL FROM DUAL ) SELECT x.*, c.column_name AS column_exists FROM x LEFT JOIN user_tab_cols c ON c.table_name = x.table_name AND c.column_name = x.column_name ) LOOP...

Sharpen the saw

I Imagine this. You know stuff. Maybe a lot of stuff. How long does this last if you don't add new skills and new experience regularly? How long before you are being replaced by someone else or worst something else? How easily will you get a new job? How can you provide high quality services to your clients? I have met a lot of APEX developers. Many of them on senior level, doing APEX for 10+ years. But many of them also stuck on APEX 5 and Oracle 11g, rarely 12c. Do you realize that 11g is like 15 years old and APEX 5 half of that? You really can't call yourself a senior if you are doing the same thing for 10 years, can you? Do you know how many of these guys know at least one new feature from latest APEX? Or a main difference between 11g and 12c? Zero. One new feature from 19c? Zero. I also see this over and over in teams: We don't have time to refactor the code. We will do that in phase two (never). We don't have time to write unit tests. ...

Set page items based on SQL query

I If you want to create a lot of items on APEX page, you should use the Form region. Based on a table/view or query it will create items for every column and add init process to prefill these items for you when you pass a primary key. Neat. The thing is, sometimes I can't use the form processes, I just need to set items based on a query. The usual approach is to SELECT INTO (select columns into the items). For 20 items you will get 40+ lines query, for 60 items you will get 120+ lines, you get the idea. You have to be careful about the column names and items names and not to mix them. And this also leads to different item names than columns. SELECT column_name1, column_name2, column_name3, column_name4 ... INTO :P100_column_name1, :P100_column_nameee2, :P100_column_name3, :P100_col_name4 ... FROM your_table WHERE ROWNUM = 1; How about this? DECLARE l_curs SYS_REFCURSOR; BEGIN OPEN l_curs FOR SELECT * -- your columns whi...