A Tale of Two Models

select dm.name
from   data_models dm
join   data_model_values qc
on     dm.id = qc.model_id
join   data_model_values de
on     dm.id = de.model_id
join   data_model_values coa
on     dm.id = coa.model_id
where  qc.attr = 'Query complexity'
and    qc.val = 'Hideously mind-boggling'
and    de.attr = 'Datatype  (more...)

The things that make life worth living

insert into joyous_memories
  select making_vast_improvements
  from   that_horrible_query
  union  all
  select designing_data_models
  from   scalable_applications
  union  all
  select heart_warming_smile
  from   your_newborn_child;

While there can be a lot of effort put in before getting these outcomes, the reward is worth it! :)

Where did all the decimals go?

create table fractional_digits_disappear (
  without_warning_when_put_in_an integer
);

insert into fractional_digits_disappear (
  without_warning_when_put_in_an
) values (
  3.141592
);

select *
from    fractional_digits_disappear;

WITHOUT_WARNING_WHEN_PUT_IN_AN
------------------------------
                             3

The fractional seconds of timestamps are also silently  (more...)

The Crying Game

select count(*)
from   babies
where  crying = any (
  select understanding
  from   parents
);

COUNT(*)
--------
       0

If anyone ever manages to create a baby-to-parent translation device, 
I'm sure they'll become the richest person in the world!

The NON-EXISTENT Edition

drop procedure is_not_really_gone_but;

select object_name || ' ' || object_type 
                 as "Continues on"
from   user_objects_ae
where  object_name = 
           'IS_NOT_REALLY_GONE_BUT';

Continues on
-----------------------------------
IS_NOT_REALLY_GONE_BUT NON-EXISTENT

create table is_not_really_gone_but ( 
  until_replaced            number,
  by_a_non_editioned_object varchar2(1) 
                            default 'Y',
  which_we_then_drop        varchar2(1)
);

drop table is_not_really_gone_but;

select  (more...)

Traffic Management

delete
from   roads
where  cars in ('my', 'way')
and    desire_to_get_home_quickly = 'huge';

1,492 rows deleted
Now I just need to find a way to execute this before leaving work to ensure an smooth flowing journey home!

Sequence out of fetch? More problems with committing in loops

create sequence ora 
start  with -1002 minvalue -1002;

begin
  for commits in (
    select loops 
    from   queries
    where  we = 'specify'
    for    update
  ) loop
    dbms_output.put_line(
      'Causes an ' || sqlerrm(ora.nextval));
    commit;
  end loop;
end;
/

Error report:
ORA-01002: fetch out of sequence
Issuing a  (more...)

You don’t need to wait to be given this permission

grant read on 
directory concepts_guide 
to everyone;
It's always slightly disappointing seeing how many forum questions could be answered by a quick and easy look at the relevant section of the concepts guide and/or general manuals

But now you’ve got it, head here to read it!

A Private Place to Manage Working Data

create global temporary table  
      contains_data_that_is (
  only_visible_to_one_session 
    varchar2(1)  default 'Y',
  and_by 
    varchar2(50) default 'removed on commit',
  unless_you_state 
    integer
) on commit preserve rows;

I've always found the "global" naming of temporary tables slightly confusing, 
as this implies the data is visible across  (more...)

One Database, One Package, Multiple Codepaths

create edition allows_one_plsql_object 
as child of itself_with_differing_code;

comment on edition allows_one_plsql_object is 
'so you can release changes with no dowmtime!';

Releasing changes to server side PL/SQL in 24x7, always up databases can be a big challenge. Ensuring the release 
worked correctly can be impossible without renaming the objects  (more...)