Presentación de las nuevas funcionalidades incorporadas en Oracle 12.2 para trabajar con Machine Learning y análisis de datos a través de Oracle’s Machine Learning and Advanced Analytics 12.2 and Oracle Data Miner 4.2 New Features | Oracle Data Mining (ODM) Blog
Archivo del Autor: PabloE
Tratamiento de NIF españoles (parte 2)
Una expresión regular para tratar los NIF españoles eliminando todos los caracteres que no sean números o letras. Además, comprueba el tamaño del NIF para eliminar el código de país (identificador fiscal comunitario) si fuera necesario:
select result1 ORIGINAL_TAXID,
upper(
regexp_replace(
regexp_replace(result1, '[^[:alnum:]]', ''), -- Remove non-digit and non-alphabetic characters
'^(ES)([[:alnum:]]{9})$', -- Identify spanish NIFs with country code
'\2')) CLEAN_AND_NATIONAL_TAXID -- Remove spanish country code
from (
WITH test AS
(SELECT 'ESA45678901,B23456789,GB3456789,12345678L,B234567890123,ES-A45678901,B.23456789,GB3::456789,B234_567_890123' col1 FROM dual)
SELECT regexp_substr(col1, '[^,]+', 1, rownum) result1
FROM test
CONNECT BY LEVEL <= regexp_count(col1, ',') + 1);
El resultado es:
ORIGINAL_TAXID CLEAN_AND_NATIONAL_TAXID -------------- ------------------------ ESA45678901 A45678901 B23456789 B23456789 GB3456789 GB3456789 12345678L 12345678L B234567890123 B234567890123 ES-A45678901 A45678901 B.23456789 B23456789 GB3::456789 GB3456789 B234_567_890123 B234567890123
En el artículo Tratamiento de NIF españoles se muestra una expresión regular para añadir el código de país.
Sharing a tablespace between 2 databases
Una alternativa para compartir datos maestros o históricos entre distintas bases de datos Oracle sin replicar los datos.
Learning is not a spectator sport
I was reading an interesting discussion today about multiple databases each containing large amounts of read-only data. If that read-only data is common, then it would make sense to have a single copy of that data and have both databases share it.
Well, as long as you can isolate that data into its own tablespace, then you can do that easily with Oracle by transporting the metadata between two databases and leaving the files in place.
Here’s an example
Source database
SQL> select banner from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production PL/SQL Release 12.1.0.2.0 - Production CORE 12.1.0.2.0 Production TNS for 64-bit Windows: Version 12.1.0.2.0 - Production NLSRTL Version 12.1.0.2.0 - Production SQL> create tablespace i_am_on_121 datafile 'C:oracleoradatattsmy_tspace' size 50m; Tablespace created. SQL> create table t tablespace i_am_on_121 as select * from dba_objects; Table created. SQL> alter tablespace i_am_on_121 read only; Tablespace altered…Ver la entrada original 359 palabras más
Pragma UDF – Speeding Up your PL/SQL Functions Called From SQL
Optimización de cambios de contexto entre SQL y PL/SQL gracias a PRAGMA UDF en Oracle 12c.
Martin Widlake's Yet Another Oracle Blog
A new feature for PL/SQL was introduced in V12, pragma UDF. UDF stands for User Defined Functions. It can speed up any SQL you have that uses PL/SQL functions you created yourself.
{please see this second post on some limitations of pragma UDF in respect of IN & RETURN data types and parameter defaults}.
We can create our own functions in PL/SQL and they can be called from both PL/SQL and SQL. This has been possible since V7.3 and is used extensively by some sites to extend the capabilities of the database and encapsulate business logic.
A problem with this, though, is that every time you swap from SQL to PL/SQL (or the other way around) you have to do a context switch each time, which can be quite cpu and memory intensive. If you are using your own PL/SQL function in the SELECT list of a SQL statement and…
Ver la entrada original 814 palabras más
Benefits of Oracle Sharding
Oracle nos proporciona con la versión 12.2 una nueva forma de escalar servicios horizontalmente a través de la distribución de la base de datos en nodos independientes.
Distributed Database Technologies
In this post, we will take a look at the advantages of Oracle Sharding.
- Linear scalability with complete fault isolation. OLTP applications designed for Oracle sharding can elastically scale (data, transactions and users) to any level, on any platform, simply by deploying new shards on additional stand-alone servers. The unavailability or slowdown of a shard due to either an unplanned outage or planned maintenance affects only the users of that shard, it does not affect the availability or performance of the application for users of other shards. Upon the unavailability of a shard, failover is initiated automatically to another copy of the data. Each shard may run a different release of the Oracle Database as long as the application is backward compatible with the oldest running version – making it simple to maintain availability of an application while performing database maintenance.

- Global data distribution for data proximity – to…
Ver la entrada original 113 palabras más
Oracle REST Data Service intro
Jeff Smith nos proporciona en esta entrada una breve introducción a ORDS (antiguo APEX Listener) y un repertorio con la documentación relacionada más importante: Oracle REST Data Services (ORDS) | ThatJeffSmith
Many SQL Performance Problems Stem from «Unnecessary, Mandatory Work»
Python para desarrolladores PL/SQL
Arup Nanda, Oracle ACE Director, ha publicado una serie de tutoriales para mostrar las diferencias y similitudes entre el desarrollo con Python y PL/SQL.
Estos tutoriales están disponibles en Introduction to Python for PL/SQL Developers – … | Oracle Community
Extraer valores de una lista contenida en una columna
En ciertas ocasiones nos vemos en la necesidad de almacenar una serie de valores distintos en una misma columna. Especialmente cuando estamos tratando con datos de configuración que pueden variar en el número y valores posibles con el tiempo. Explotar esta información desde SQL suele presentar muchos inconvenientes puesto que se trata de información sin normalizar y que requiere tratar con cadenas de texto de alta variabilidad.
Gracias a la implantación de expresiones regulares dentro de SQL podemos mejorar las alternativas a la hora de consultar este tipo de datos.
Tomemos, a modo de prueba, las siguientes cadenas de texto:
TYPE=String#LENGTH=18#DEFAULT=empty LENGTH=1#TYPE=Number#DECIMALS=0#DEFAULT=0 LENGTH=10#DEFAULT=1.00#TYPE=Number#DECIMALS=2
Mediante el uso de las funciones «regexp_instr» y «regexp_substr» dentro de una consulta SELECT podemos extraer los distintos componentes de cada una de las cadenas y, por ejemplo, mostrarlos como columnas:
with test_tab as (
select 1 cfg, 'TYPE=String#LENGTH=18#DEFAULT=empty' config from dual
union all
select 2 cfg, 'LENGTH=1#TYPE=Number#DECIMALS=0#DEFAULT=0' config from dual
union all
select 3 cfg, 'LENGTH=10#DEFAULT=1.00#TYPE=Number#DECIMALS=2' config from dual)
select cfg,
decode((regexp_instr(config, '(^|#)TYPE=(.+)($|#)')), 0, '', (regexp_substr(config, '[^#]+', (regexp_instr(config, '(^|#)TYPE=(.+)($|#)')), 1))) cfg_TYPE,
decode((regexp_instr(config, '(^|#)LENGTH=(.+)($|#)')), 0, '', (regexp_substr(config, '[^#]+', (regexp_instr(config, '(^|#)LENGTH=(.+)($|#)')), 1))) cfg_LENGTH,
decode((regexp_instr(config, '(^|#)DECIMALS=(.+)($|#)')), 0, '', (regexp_substr(config, '[^#]+', (regexp_instr(config, '(^|#)DECIMALS=(.+)($|#)')), 1))) cfg_DECIMALS,
decode((regexp_instr(config, '(^|#)DEFAULT=(.+)($|#)')), 0, '', (regexp_substr(config, '[^#]+', (regexp_instr(config, '(^|#)DEFAULT=(.+)($|#)')), 1))) cfg_DEFAULT,
config
from test_tab;
Resultado:
CFG CFG_TYPE CFG_LENGTH CFG_DECIMALS CFG_DEFAULT CONFIG --- ----------- ---------- ------------- ----------- ---------------------------------------- 1 TYPE=String LENGTH=18 DEFAULT=empty TYPE=String#LENGTH=18#DEFAULT=empty 2 TYPE=Number LENGTH=1 DECIMALS=0 DEFAULT=0 LENGTH=1#TYPE=Number#DECIMALS=0#DEFAULT=0 3 TYPE=Number LENGTH=10 DECIMALS=2 DEFAULT=1.00 LENGTH=10#DEFAULT=1.00#TYPE=Number#DECIMALS=2
Estas mismas funciones nos pueden servir para filtrar los datos en la cláusula WHERE o para modificar los datos de la cadena a través del operador SET en una operación UPDATE.
Por último, mediante la cláusula CONNECT BY, podemos listar todos los datos de una de las listas y mostrarlos como filas distintas en el resultado de la consulta:
with test_tab as (select 1 cfg, 'TYPE=String#LENGTH=18#DEFAULT=empty' config from dual) select cfg, config, regexp_substr(config, '[^#]+', 1, level) key_value from test_tab connect by regexp_substr(config, '[^#]+', 1, level) is not null;
Resultado:
CFG CONFIG KEY_VALUE --- ----------------------------------- ------------- 1 TYPE=String#LENGTH=18#DEFAULT=empty TYPE=String 1 TYPE=String#LENGTH=18#DEFAULT=empty LENGTH=18 1 TYPE=String#LENGTH=18#DEFAULT=empty DEFAULT=empty
Select All / Unselect All Checkbox in Interactive Report Header
Cómo añadir un control en los IR de APEX para marcar / desmarcar todas las casilla de tipo «checkbox» del listado.
