Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Wednesday, July 18, 2012

Oracle: condition CASE in select sentence


SELECT 
TRANSACCION.num_tarjeta
,TRANSACCION.fecha_hora_tran
, TRANSACCION.monto_1 as monto
,  CASE 
WHEN TRANSACCION.ciudad != ' ' 
THEN TRANSACCION.ciudad 
ELSE 'No Disponible' 
END AS ciudad 
, CLASE_TRANSA.DESCRIPCION AS MEDIO
FROM 
TRANSACCION 
left outer join CIUDADES 
ON TRANSACCION.ciudad = CIUDADES.cod_ciud  
left outer join CLASE_TRANSA
ON TRANSACCION.clase = CLASE_TRANSA.CODIGO


Reference:
http://www.adp-gmbh.ch/ora/sql/case_when.html

Saturday, July 14, 2012

Oracle: filter date type column in where sql clause

Use to_date() method:


where (DPFOLIO.BUDGET_PROD.MONTH > to_date('12/31/2005 12:00:00 AM','MM/DD/YYYY HH12:MI:SS AM'))

Reference:

http://en.allexperts.com/q/Oracle-1451/oracle-date-filtering-cause.htm

Friday, July 29, 2011

ORACLE 10G: drop tablespaces

 Dropping a Tablespace: Example

The following statement drops the tbs_01 tablespace and drops all referential integrity constraints that refer to primary and unique keys inside tbs_01:

DROP TABLESPACE tbs_01
    INCLUDING CONTENTS
        CASCADE CONSTRAINTS;

Deleting Operating System Files: Example
The following example drops the tbs_02 tablespace and deletes all associated operating system datafiles:

DROP TABLESPACE tbs_02
   INCLUDING CONTENTS AND DATAFILES;

Source:
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_9004.htm