ODI Java Decrypt Password

package ODI;

import com.sunopsis.dwg.DwgObject;
import java.sql.*;

public class decrypt_password {

@SuppressWarnings(“deprecation”)
public static void main(String[] args) {

@SuppressWarnings(“deprecation”)
String strMasterPassEnc=”dNfHRQilqhZhupd,MDGYw7H5pEMUKrd”;
String strMasterPass=DwgObject.snpsDecypher(strMasterPassEnc);
System.out.println(strMasterPass);

}

}

vi Unix or Dos file format

You can find out which format (unix or dos) you have by typing :set

Display CRLF as ^M:
:e ++ff=unix

Substitute CRLF for LF:
:setlocal ff=unix
:w
:e

CTAS Compression Sort

SELECT   ‘, ‘ || dtc.column_name
, dtc.num_distinct
, dtc.avg_col_len
FROM     dba_tab_cols dtc
WHERE    dtc.owner = ‘DWFACTS’
AND      dtc.table_name = ‘STATELINES_FACT’
ORDER BY dtc.num_distinct
, dtc.avg_col_len DESC;

Tar Directory

To tar a directory

tar -zcvf <tarname>.tar.gz <directory>/

  • -z: Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name

To untar a directory

tar -zxvf <tarname>.tar.gz

XML Parser

CREATE OR REPLACE FUNCTION username.parse_xml
( p_string     IN     VARCHAR2
, p_node       IN     VARCHAR2
)  RETURN VARCHAR2 AS
v_data                 VARCHAR2(4000);
v_node                 VARCHAR2(4000);
v_upper_str            VARCHAR2(4000);
v_startnode            VARCHAR2(4000);
v_endnode              VARCHAR2(4000);
v_startnodelength      NUMBER;
BEGIN
v_node               := UPPER( p_node );
v_upper_str          := UPPER( p_string );
v_startnode          := ‘<‘ || v_node || ‘>’;
v_endnode            := ‘</’ || v_node || ‘>’;
v_startnodelength    := LENGTH( v_startnode );
v_data := SUBSTR( p_string
, INSTR( v_upper_str, v_startnode ) + v_startnodelength
);
v_data := SUBSTR( v_data
, 1
, INSTR( UPPER( v_data ), v_endnode ) – 1
);
RETURN( TRIM(v_data) );
END;
/

CREATE TABLE username.XML_TABLE
(
XML  VARCHAR2(4000 BYTE)                          NULL
)
ORGANIZATION EXTERNAL
(  TYPE ORACLE_LOADER
DEFAULT DIRECTORY TMP
ACCESS PARAMETERS
( RECORDS DELIMITED BY ‘</item>’
BADFILE TMP’xml_file.bad’
LOGFILE TMP’xml_file.log’
FIELDS TERMINATED BY “,” LDRTRIM
)
LOCATION (TMP’xml_file.xml’)
)
REJECT LIMIT UNLIMITED
NOPARALLEL
NOMONITORING;

SELECT ROWNUM item_id
, username.parse_xml ( xml, ‘col1’ ) col1
, username.parse_xml ( xml, ‘col2’ ) col2
, username.parse_xml ( xml, ‘col3’ ) col3
, username.parse_xml ( xml, ‘col4’ ) col4
, username.parse_xml ( xml, ‘col5’ ) col5
FROM   username.XML_TABLE;

d_log.write

PROCEDURE WRITE
( p_text       IN VARCHAR2
, p_file       IN VARCHAR2 DEFAULT ‘d_log.log’
, p_action     IN VARCHAR2 DEFAULT ‘A’
, p_log_table  IN BOOLEAN  DEFAULT FALSE
, p_log_status IN VARCHAR2 DEFAULT ‘SUCCESS’
) IS
v_log utl_file.file_type;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
v_log  := utl_file.fopen( ‘LOG’
, p_file
, p_action
);
utl_file.put_line( v_log
, TO_CHAR(SYSDATE,’YYYY-MM-DD HH24:MI:SS’) || ‘ ‘ || p_text
);
utl_file.fclose( v_log );
IF p_log_table
THEN
INSERT INTO dwfacts.batch_log
( log_date
, log_text
, log_status
)
VALUES ( SYSDATE
, p_text
, p_log_status
);
COMMIT;
END IF;
END WRITE

ODI Session

SELECT LEVEL
, ss.parent_sess_no
, ss.sess_no
, CONNECT_BY_ROOT
ss.sess_name root_sess_name
, LPAD(‘> ‘,3*(LEVEL-1),’-‘) || sess_name sess_name
, ss.sess_beg
, ss.sess_end
, stl.rows_processed
, ss.sess_dur
, ss.sess_status
FROM  odi_atlas_work.snp_session ss
, (SELECT sess_no
, SUM(ABS(nb_row)) rows_processed
FROM odi_atlas_work.snp_sess_task_log
WHERE TRUNC(task_beg) >= ’01-JUL-2011′
AND TRUNC(task_end) < ’02-JUL-2011’
GROUP BY sess_no ) stl
WHERE      ss.sess_no = stl.sess_no
AND UPPER(ss.agent_name) = ‘APOLLOSERVER’
START WITH ss.parent_sess_no IS NULL
AND ss.sess_beg >= ’01-JUL-2011′
AND ss.sess_end < ’02-JUL-2011′
CONNECT BY PRIOR ss.sess_no = ss.parent_sess_no

Exchange Partition

DECLARE
 v_sql              VARCHAR2(20000);
 v_logfile          VARCHAR2(200)      := ‘exchange_sbf_partition.log’;
 v_min_process_date NUMBER(10);
 v_max_process_date NUMBER(10);
 v_src_count        NUMBER(10);
 v_trg_count        NUMBER(10);
 CURSOR c_get_parts IS
SELECT   partition_name
FROM     dba_tab_partitions
WHERE    table_owner = ‘WHOUSE2’
     AND table_name = ‘SPORTS_BET_FACT_TOTE’
     AND partition_name >= ‘FY20092010’
     –AND partition_name <= ‘P20110926’
ORDER BY 1;
BEGIN
FOR r_parts IN c_get_parts
      LOOP
      v_sql := ‘DROP TABLE whouse1.sbsft_tmp1 PURGE’;
      prod_run.d_log.WRITE
             ( p_text     => v_sql
             , p_file     => v_logfile );
      BEGIN
         EXECUTE IMMEDIATE v_sql;
      EXCEPTION
         WHEN OTHERS THEN
         NULL;
      END;
      prod_run.d_log.WRITE
             ( p_text     => ‘Create temp table from partition ‘ || r_parts.partition_name
             , p_file     => v_logfile );
      v_sql := q'[
      CREATE TABLE whouse1.sbsft_tmp1
TABLESPACE TSD_SPORTS_BET_FACT_TOTE
LOGGING
COMPRESS
PARALLEL ( DEGREE 32 INSTANCES 1 )
AS
SELECT   *
FROM     whouse2.sports_bet_fact_tote PARTITION ( ]’ || r_parts.partition_name || q'[ )]’;
        BEGIN
         EXECUTE IMMEDIATE v_sql;
      EXCEPTION
         WHEN OTHERS THEN
         prod_run.d_log.WRITE
             ( p_text     => v_sql
             , p_file     => v_logfile );
      END;
        v_sql := ‘SELECT COUNT(1) FROM   whouse2.sports_bet_fact_tote PARTITION ( ‘ || r_parts.partition_name || ‘)’;
        EXECUTE IMMEDIATE v_sql INTO v_src_count;
        v_sql := ‘SELECT COUNT(1) FROM   whouse1.sbsft_tmp1’;
        EXECUTE IMMEDIATE v_sql INTO v_trg_count;
        IF v_src_count != v_trg_count THEN
        prod_run.d_log.WRITE
             ( p_text     => ‘ERROR : Partition : ‘ || UPPER(r_parts.partition_name) ||
                                  ‘ Source Count : ‘ || v_src_count ||
                                  ‘ Target Count : ‘ || v_trg_count
             , p_file     => v_logfile );
        raise_application_error( -20001
                                , ‘ERROR : Partition : ‘ || UPPER(r_parts.partition_name) ||
                                  ‘ Source Count : ‘ || v_src_count ||
                                  ‘ Target Count : ‘ || v_trg_count
                                );
        END IF;
        prod_run.d_log.WRITE
             ( p_text     => ‘Source Target Check Ok : Source = ‘ || v_src_count || ‘ : Target = ‘ || v_trg_count
             , p_file     => v_logfile );
        prod_run.d_log.WRITE
             ( p_text     => ‘Analyse temp table for partition ‘ || r_parts.partition_name
             , p_file     => v_logfile );
        sys.dbms_stats.gather_table_stats (
                                              ownname           => ‘WHOUSE1’
                                            , tabname           => ‘SBSFT_TMP1’
                                            , estimate_percent  => sys.dbms_stats.auto_sample_size
                                            , method_opt        => ‘FOR ALL INDEXED COLUMNS SIZE AUTO ‘
                                            , DEGREE            => 4
                                            , CASCADE           => FALSE
                                            , no_invalidate     => FALSE);
    prod_run.d_log.WRITE
             ( p_text     => ‘Exchange temp table for partition ‘ || r_parts.partition_name
             , p_file     => v_logfile );
        v_sql :=’ALTER TABLE whouse1.sports_bet_fact_tote EXCHANGE PARTITION ‘ || r_parts.partition_name || ‘ WITH TABLE whouse1.sbsft_tmp1 INCLUDING INDEXES’;
        EXECUTE IMMEDIATE v_sql;
    v_sql :=’ALTER TABLE whouse2.sports_bet_fact_tote TRUNCATE PARTITION ‘ || r_parts.partition_name;
        –EXECUTE IMMEDIATE v_sql;
      END LOOP;
END;

Configure Hetrogeneous Services

Add the following info into the listener.ora file
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME=LinkPollTStage)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/gtw_1)
      (PROGRAM=dg4msql)
    )
    (SID_DESC =
      (SID_NAME=LinkPollETLControl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/gtw_1)
      (PROGRAM=dg4msql)
    )
    (SID_DESC =
      (SID_NAME=LinkPollETLControl2)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/gtw_1)
      (PROGRAM=dg4msql)
    )
    (SID_DESC =
      (SID_NAME=LinkPollDimETL)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/gtw_1)
      (PROGRAM=dg4msql)
    )
    (SID_DESC =
      (SID_NAME=LinkPollFactETL)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/gtw_1)
      (PROGRAM=dg4msql)
    )
  )
Stop and start the listener
Add the following files to the /u01/app/oracle/product/11.2.0/gtw_1/dg4msql/admin/ directory
initLinkPollDimETL.ora
initLinkPollETLControl2.ora
initLinkPollETLControl.ora
initLinkPollFacETL.ora
initLinkPollTStage.ora
initLinkPollDimETL.ora – Contents
HS_FDS_CONNECT_INFO=[172.18.92.9]:1433//dimetl
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
initLinkPoll ETLControl2.ora – Contents
HS_FDS_CONNECT_INFO=[172.18.92.9]:1433//etlcontrol2
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
initLinkPoll ETLControl.ora – Contents
HS_FDS_CONNECT_INFO=[172.18.92.9]:1433//etlcontrol
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
initLinkPollFactETL.ora – Contents
HS_FDS_CONNECT_INFO=[172.18.92.9]:1433//factetl
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
initLinkPollFactETL.ora – Contents
HS_FDS_CONNECT_INFO=[172.18.92.9]:1433//factetl
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
initLinkPollTStage.ora – Contents
HS_FDS_CONNECT_INFO=[172.18.92.9]:1433//tstage
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
Add the following entries into the tnsnames.ora file
##########ADDING TNSNAMES FOR Heterogeneous services
LinkPollFactETL=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(PORT = 1521)(HOST = 10.24.0.11))
    )
    (CONNECT_DATA = (SID = LinkPollFactETL))
    (HS=OK)
  )
LinkPollETLControl2=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(PORT = 1521)(HOST = 10.24.0.11))
    )
    (CONNECT_DATA = (SID = LinkPollETLControl2))
    (HS=OK)
  )
LinkPollTStage=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(PORT = 1521)(HOST = 10.24.0.11))
    )
    (CONNECT_DATA = (SID = LinkPollTStage))
    (HS=OK)
  )
LinkPollETLControl=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(PORT = 1521)(HOST = 10.24.0.11))
    )
    (CONNECT_DATA = (SID=LinkPollETLControl))
    (HS=OK)
  )
LinkPollDimETL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(PORT = 1521)(HOST = 10.24.0.11))
    )
    (CONNECT_DATA = (SID = LinkPollDimETL ))
    (HS=OK)
  )
DimETL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(PORT = 1521)(HOST = 10.24.0.11))
    )
    (CONNECT_DATA = (SID = DimETL ))
    (HS=OK)
  )

authid current_user

http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/subprograms.htm#i18574

To give the package the same rights as the caller of the package