SQLPLUS HTML COLOR

Recently i was asked to generate a report that shows all the databases that were backed up via RMAN and they wanted a color code when a backup failed or wasn’t completed successfully.

That posed a challenge and took some research, but finally generated a report.   Below is a sample report and how to color code on afailed backup, but can be used on any sql report:


SET MARKUP HTML ON SPOOL ON
SET TERMOUT OFF
SET PAGESIZE 1000
SET LINESIZE 300
SET TRIMOUT ON
SET TERMOUT ON
set pages 999
set feedback off
break on db_name page
alter session set nls_date_format='DD-MON-YY HH24:MI:SS';
spool backup_report
SET MARKUP HTML ENTMAP OFF
PROMPT <H2><center><b> RMAN Backup  details  </b></center></H2>
SET MARKUP HTML ENTMAP ON
SET VERIFY    off
SET lines 132 pages 9999 feedback off
COLUMN start_time      format date              heading ‘Start Date’
COLUMN end_time      format date              heading ‘End Date’
COLUMN input_bytes format 999,999,999,999 heading ‘Input Bytes’
COLUMN output_bytes        format 999,999,999,999 heading ‘Output Bytes’
COLUMN cstatus format a40  heading ‘Status’
COLUMN object_type              format a10  heading ‘Backup Type’
COLUMN time_taken_display      format a40  heading ‘Time Taken’
COLUMN cstatus ENTMAP OFF
select db_name, object_type,start_time,end_time,input_bytes, output_bytes,
(case
when status like ‘%WARN%’ then ‘<font color=”green”>COMPLETED</font>’   <==== Note color default for non-failed jobs
when status like ‘COMPLETED’ then ‘<font color=”green”>COMPLETED</font>’
ELSE ‘ <font color=”red”>’||status||'</font>’                                                             <=== Note – falls through code and any noncompleted status uses this color
END) cstatus
from <RMAN CATALOG>.rc_rman_status
where object_type = ‘DB FULL’
and operation not in (‘RESTORE VALIDATE’)
order by db_name,start_time Asc;
SET MARKUP HTML ENTMAP OFF
spool off

Hope this helps with your reports and can be used for any type of report that requires color coding.

–Mike

GLOC16 is here !!

This year there are more Oracle ACES presenting than ever before at the Great Lakes Oracle Users Conference. Check out the Schedule at a Glance and see which sessions you want to attend. Oracle Aces include Susan Behn, Karen Brownfield, Michael Gangler, Gustavo Gonzalez, Tim Gorman, Janis Griffin, Kyle Hailey, Francis Mignault, Daniel Morgan, Rich Niemiec, Kerry Osborne, Elke Phelps, Tanel Poder, Kellyn Pot’Vin-Gorman, Carlos Sierra, Scott Spendolini, Deanna Sunde, Mark Bobak, Ric Van Dyke, and Tim Vlamis.

I will be speaking on May 19th from 4 – 5:00pm on “Using RPM’s to distribute OEM Agents”
https://www.neooug.org/gloc/agenda.aspx

TO Register:

https://www.neooug.org/gloc/registration.aspx

 

Granting Oracle Schema Permissions (Objects not created yet) – Part 2

After presenting at Collaborate 16 about granting schema permissions, a colleague – Frank Pound send me the following that can also be used to perform the trigger only on “Tables”:

https://community.oracle.com/thread/402826?start=0&tstart=0

create or replace trigger trigger_grant_dml

after create on schema
declare
v_job number;
v_todo varchar2(200);
begin
     if ora_sysevent = 'CREATE' and ora_dict_obj_type = 'TABLE' then
     v_todo:='execute immediate ''grant select, insert, update, delete on '||ora_dict_obj_name||' to my_new_role'';';
     dbms_job.submit(job=>v_job, what=>v_todo);
  end if;
exception
  when others then
  null;
end;
/

2016_1198_gangler_ppt

Please contact me with any questions - mjgangler@gmail.com

Collaborate 16 !

I will be presenting 3 presentations at this years Collaborate 16 in Las Vegas.

Monday – April 11 – 12 – 12:30 – Palm B – Using Puppet and RPM’s to deploy EM12C Agents

Wednesday – April 13 – – 12:00 – 12:30 – Jasmine B – Granting Oracle Schema Permissions When Objects not Created Yet !

Thursday – April 14 – 8:30 am – 9:30 am – Palm  D – Optimize and Simplify Oracle 12C RAC using dNFS, ZFS and OISP

2016_1197_gangler_pdf

 

2016_1198_gangler_ppt

 

2016_1201_gangler_ppt

MOUS15 is here !!!

If you are in the Indiana, Michigan, Illinois, Ohio or Canada region and want to see and experience great Oracle user and technical presentations, networking and hands-on workshops, please register to the Michigan Oracle User Summit (#MOUS15), on Wednesday, November 18th at Schoolcraft college in Livonia, Michigan (www.mous.us).    Its a full day of presentations (45) that include Big Data presentations, Hyperion presentations, JDEdwards, Oracle Applications, Middleware (SOA), Database (Oracle12c, RAC, others) and 2 hands-on workshops – #cloneattack and #racattack.   We also have 13 Oracle Ace and Ace directors, Rich Niemiec of Rolta will be our keynote speaker.   Please visit our website (www.mous.us) or guidebook for more details on the conference content.

So not only do you get some great user and technical presentations, but you get 2 great hands-on workshops – Clone Attack and Racattack (www.racattack.org).

Clone attack (www.delphix.com ) – did you ever want to create development databases from production with a small footprint and dynamic way ?   Well come to MOUS15 and create many development databases on your own PC.

RACATTACK – (www.racattack.org) – Racattack allows you to create a 12c RAC database on your own PC, yes, you too can have your own RAC database on your pc.

Wait there is more !! – WE ARE ON GUIDEBOOK – http://www.guidebook.com (Look for MOUS) its free !!

Lastly, this conference is a great way to network with other Oracle users, a full day of presentations, hands-on workshops, great food , education and its priced reasonably ($50 pre-register, $75 at door).

Hope to see you at the conference and please contact me with any questions,

--Mike Gangler
mjgangler@yahoo.com

ORA-10997 and ORA-09968 on ASM startup (With NFS)

During a recent hardware upgrade, i received the following error on a ASM (NO-RAC) startup.   It was very confusing, because i was custom to seeing ASM on Storage LUNS and in this case it was using ASM (NO-RAC) and NFS storage.   Unfortunately, as always with late night changes, you don’t notice things until you get fresh eyes on the issue.   A simple “df -kh” would’ve told me that it was NFS, but made too many presumptions.

When i first told about the NFS settings, i thought i needed to restart nfs, but that didn’t work.   Than after getting another fresh pair of eyes from the Linux team, we realized that the directory “/var/lib/nfs” was set to 750???   After some investigation, we saw that puppet was changing it to 750 every 5 minutes, so even when we changed it to 755, it was 750.  so the next question, why ?

Well it appears that FTI requirements are the culprit.  Apparently the auditors don’t understand nfs and O/S’s, probably don’t care either.   Apparently, FTI companies are required to set this to 750…. Now i understand security, but this directory needs to be readable by Oracle to start up the nfs drives and ASM.

Until we get a permanent solution, the linux team offered the following solution:

the setting of 755 is only needed for startup, so the temporary solution is (as root):


root> chmod 755 /var/lib/nfs
root> chatter +i /var/lib/nfs <== protects
root> crsctl start has
== after successful startup ====
root> chatter -i /var/lib/nfs <== takes off the protection

The following is the error description:

grid> srvctl start asm

PRCR-1079 : Failed to start resource ora.asm
CRS-5017: The resource action "ora.asm start" encountered the following error:
ORA-10997: another startup/shutdown operation of this instance in progress
ORA-09968: unable to lock file
Linux-x86_64 Error: 37: No locks available
Additional information: 64
. For details refer to "(:CLSN00107:)" in "/u01/app/grid/product/11.2.0.4/grid_home/log/<machine_name>/agent/ohasd/oraagent_grid/oraagent_grid.log".
CRS-2674: Start of 'ora.asm' on '<machine name>' failed

Multitenant – Oracle 12c Standard Edition

Im Re-blogging this information, as i heard this at Collaborate 15, that non-multitenant databases will be deprecated in Oracle 13, not sure if its true, but here is some good information, if it is true…..

==============================================

Can you have Oracle Multitenant in Oracle Standard Edition 12.1.0.2 SE2?

No, you can’t as Oracle Multitenant is a licensable option for Enterprise Edition (EE) databases only.   

But wait a second …

You can do Oracle Single Tenant with SE2 of course meaning you can have one active pluggable database within one container database at a time. That is possible and does not require any additional licenses.

See the DBCA (Database Configuration Assistant) screen when you’ll try to create a container database:

More information? 

You’ll find more information about the differences in handling and such between Oracle non-CDB, Oracle Single Tenant and Oracle Multitenant databases in this presentation:

User Group Benefits – (Extending Kellyn’s Post)

A few weeks back Kellyn Potvin-Gorman, wrote an excellent blog about Local and Regional user groups (http://dbakevlar.com/2015/07/community-and-regional-oracle-user-groups/), i encourage everyone to read this blog.   As many of you know i have been associated with the Oracle User community since the day of the dinosaurs and floppy disks with Oracle 4 and Oracle 5.1c.   Again, I have told this story many times, but it bears repeating.   During the early years of my Oracle experience, i was to develop a application that kept track of machine / press assets and usage.   Primarily to save on purchasing new molds and dies.   I was using Oracle Forms 2.0 at the time and needed to map my heading information with the detail information on the same page (I was trying to follow popular Database design).   i spent at least 2 – 3 weeks and many hours trying everything to make them match up, but back then we didn’t have the internet or google.   We only had old fashion (RTFM) Oracle manuals, that never had decent examples (BTW, still don’t, IMHO).  The other item was that I was NOT to call Oracle, because at the time we were still considering Oracle and didnt want to tip our hand to Oracle.

I was at the point of breaking many of the database design rules to make it work, when someone (Thank you) mentioned that there was a Oracle user group meeting at the local Oracle office that night.   So I headed over there and it just so happened that Oracle Forms was the agenda item and a local user and Oracle Instructor indicated that there was a trick to make it work.   I tried it the next day at work and that saved the day and many additional hours of trial and error.

Since that time i have been involved in all areas of user group activities.  This includes the current chair of the Southeast Michigan Oracle User Group (SEMOP) , many regional group boards (MOUG, MOUS) and the International Board (IOUG).  I have also shared my experiences with presentations and papers at numerous conferences since 1988.   This includes giving presentations in Brazil, UKOUG, RMOUG, IOUG, OOW and many local user groups around the country and publishing articles in Select magazine.

Ok, I know, you are saying what does this mean to me ?   Since my Involvement my DBA skills have greatly improved, my communication skills have improved and i have met and made friendships with many great people around the world.  Oracle (Like Rugby) is a small world / Community and no matter where you go in the world, someone will know or use Oracle products.

I once met a cab driver in Miami, while attending the IMS oracle user group meeting who use to be a Oracle programmer and when i tested him with many higher level questions, he aced the answers with comments only Oracle Programmers would know.

I know we now have the internet and lots of information is out already,  I ask you to get involved at some level.   So even if its just publishing a paper, Presenting a paper, Room Monitor, volunteering to sit a a registration desk, or just volunteering to order pizza at the next meeting.   its a small community and get involved, it will make you a better DBA and as with me, I have learned more from participating in the User community from both the technical and technical areas.   It has made me a better DBA, employee, employer and person overall.   There are many local, regional and Special interest groups in your area (Trust me) and I encourage you to try it, here are some links:

www.ioug.org

www.rmoug.org

www.odtug.org

www.semop.org

www.mous.us

Please feel to reach out to me if you have any questions or having issues finding a local/regional group.

–Mike