If you’re a command line dinosaur like me, maybe you’d still like to occasionally step out of the dark ages and have your output in a nice colour.
Maybe in the query below, I’d like some highlighting when the hiredate is (say) more recent than 1982.
Well, if you are really keen, then you can add the following functions to your database, and then it is easy! (well, sortta easy 😀)
SQL> create or replace
2 function Black(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[30m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Red(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[31m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Green(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[32m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Yellow(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[33m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Blue(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[34m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Magenta(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[35m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Cyan(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[36m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function White(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[37m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL>
SQL>
SQL> create or replace
2 function Bright_Red(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[31;1m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Bright_Green(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[32;1m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Bright_Yellow(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[33;1m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Bright_Blue(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[34;1m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Bright_Magenta(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[35;1m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Bright_Cyan(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[36;1m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL> create or replace
2 function Bright_White(p_str varchar2) return varchar2 is
3 begin return chr(27)||'[37;1m'||p_str||chr(27)||'[0m';
4 end;
5 /
Function created.
SQL>
SQL>
Grab the source from my github repo here
Now look at this beautiful modern output 😀
If you’re thinking “Man, this dude needs to look at APEX”, then I’d say you’re correct 😀
Note: If it is just syntax highlighting that you are after, then check out the options in SQLcl here
Got some thoughts? Leave a comment