Tuesday, December 13, 2016

You do not currently have sufficient privileges to save a report or dashboard page that contains HTML markup

Saving analysis report has error "You do not currently have sufficient privileges to save a report or dashboard page that contains HTML markup. Custom column format may contain HTML tags, only the following formats may currently be used: 'Plain text', 'Plain text (don't break spaces)". The message box is as below:

The reason is your user don't have enough privilege. Following these steps to fix error:
Log into OBIEE using your BIAdministrator id.
Use "Administration" > "Security" > "Manage Privileges"
Change the permission on 2 lines:
Actions > Save Actions containing embedded HTML (I use BIAuthor)
Answers > Save Content with HTML Markup (BIAuthor) 

Tuesday, September 20, 2016

Restore, Recover and Open Oracle Database with Missing REDO

After you finish Resote & Recover DB. But you can not open DB for some reason. The primary is that you don't have enought REDO.
you can use this sql to check the fuzziness and PIT (Point In Time) of the datafiles after an incomplete recovery:

select fuzzy, status, checkpoint_change#, to_char(checkpoint_time, 'DD-MON-YYYY HH24:MI:SS') as checkpoint_time, count(*)
from v$datafile_header
group by fuzzy, status, checkpoint_change#, checkpoint_time
order by fuzzy, status, checkpoint_change#, checkpoint_time;

Recovering without Consistency
SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;
SQL> alter system set undo_management='MANUAL' scope=spfile;
SQL> shutdown abort;
SQL> startup mount;
SQL> alter database open resetlogs;
SQL> create undo tablespace UNDOTBS2 datafile size 50M;
SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile;

Select for rollback segments
SQL> set linesize 150
SQL> select  segment_name,status from  dba_rollback_segs where    status = 'NEEDS RECOVERY';
SQL> select owner, segment_name, tablespace_name, status from dba_rollback_segs where tablespace_name like '%2';

Create pfile and edit some parameter.  The values for rollback_segments paramet come from above sql result:
SQL> create pfile from spfile
edit your pfile as below:
*.undo_management='MANUAL'
*.undo_tablespace='SYSTEM'
*._offline_rollback_segments=(_SYSSMU137_4114137959$,_SYSSMU156_2905474506$,_SYSSMU159_3144578331$,_SYSSMU166_3380345480$)
*._corrupted_rollback_segments=(_SYSSMU137_4114137959$,_SYSSMU156_2905474506$,_SYSSMU159_3144578331$,_SYSSMU166_3380345480$)

SQL> shutdown abort;
SQL> startup pfile='/u01/your_pfile.ora';
SQL> drop tablespace undotbs2 including contents and datafiles;
SQL> alter system set "_allow_resetlogs_corruption"=false scope=spfile;
SQL> alter system set undo_management='AUTO' scope=spfile;
SQL> starup force;

Thursday, September 8, 2016

HR full script

Rem
Rem
Rem
Rem NAME
Rem Full.sql - Human Resources, HR schema
Rem
Rem DESCRIPTION
Rem This script creates six tables, associated constraints
Rem and indexes in the human resources (HR) schema.
Rem
Rem NOTES
Rem
Rem Oracle Corporation 2001.
Rem CREATED by Nancy Greenberg, Nagavalli Pataballa - 06/01/00
Rem INTEGRATED by Nelson Piedra nopiedra.wordpress.com
Rem
Rem MODIFIED (MM/DD/YY)
Rem ahunold 09/14/00 - Added emp_details_view
Rem ahunold 02/20/01 - New header
Rem vpatabal 03/02/01 - Added regions table, modified regions
Rem column in countries table to NUMBER.
Rem Added foreign key from countries table
Rem to regions table on region_id.
Rem Removed currency name, currency symbol
Rem columns from the countries table.
Rem Removed dn columns from employees and
Rem departments tables.
Rem Added sequences.
Rem Removed not null constraint from
Rem salary column of the employees table.
SET FEEDBACK 1
SET NUMWIDTH 10
SET LINESIZE 80
SET TRIMSPOOL ON
SET TAB OFF
SET PAGESIZE 100
SET ECHO OFF
REM ********************************************************************
REM Create the REGIONS table to hold region information for locations
REM HR.LOCATIONS table has a foreign key to this table.
Prompt ****** Creating REGIONS table ....
CREATE TABLE regions
( region_id NUMBER
CONSTRAINT region_id_nn NOT NULL
, region_name VARCHAR2(25)
);
CREATE UNIQUE INDEX reg_id_pk
ON regions (region_id);
ALTER TABLE regions
ADD ( CONSTRAINT reg_id_pk
PRIMARY KEY (region_id)
) ;
REM ********************************************************************
REM Create the COUNTRIES table to hold country information for customers
REM and company locations.
REM OE.CUSTOMERS table and HR.LOCATIONS have a foreign key to this table.
Prompt ****** Creating COUNTRIES table ....
CREATE TABLE countries
( country_id CHAR(2)
CONSTRAINT country_id_nn NOT NULL
, country_name VARCHAR2(40)
, region_id NUMBER
, CONSTRAINT country_c_id_pk
PRIMARY KEY (country_id)
)
ORGANIZATION INDEX;
ALTER TABLE countries
ADD ( CONSTRAINT countr_reg_fk
FOREIGN KEY (region_id)
REFERENCES regions(region_id)
) ;
REM ********************************************************************
REM Create the LOCATIONS table to hold address information for company departments.
REM HR.DEPARTMENTS has a foreign key to this table.
Prompt ****** Creating LOCATIONS table ....
CREATE TABLE locations
( location_id NUMBER(4)
, street_address VARCHAR2(40)
, postal_code VARCHAR2(12)
, city VARCHAR2(30)
CONSTRAINT loc_city_nn NOT NULL
, state_province VARCHAR2(25)
, country_id CHAR(2)
) ;
CREATE UNIQUE INDEX loc_id_pk
ON locations (location_id) ;
ALTER TABLE locations
ADD ( CONSTRAINT loc_id_pk
PRIMARY KEY (location_id)
, CONSTRAINT loc_c_id_fk
FOREIGN KEY (country_id)
REFERENCES countries(country_id)
) ;
Rem Useful for any subsequent addition of rows to locations table
Rem Starts with 3300
CREATE SEQUENCE locations_seq
START WITH 3300
INCREMENT BY 100
MAXVALUE 9900
NOCACHE
NOCYCLE;
REM ********************************************************************
REM Create the DEPARTMENTS table to hold company department information.
REM HR.EMPLOYEES and HR.JOB_HISTORY have a foreign key to this table.
Prompt ****** Creating DEPARTMENTS table ....
CREATE TABLE departments
( department_id NUMBER(4)
, department_name VARCHAR2(30)
CONSTRAINT dept_name_nn NOT NULL
, manager_id NUMBER(6)
, location_id NUMBER(4)
) ;
CREATE UNIQUE INDEX dept_id_pk
ON departments (department_id) ;
ALTER TABLE departments
ADD ( CONSTRAINT dept_id_pk
PRIMARY KEY (department_id)
, CONSTRAINT dept_loc_fk
FOREIGN KEY (location_id)
REFERENCES locations (location_id)
) ;
Rem Useful for any subsequent addition of rows to departments table
Rem Starts with 280
CREATE SEQUENCE departments_seq
START WITH 280
INCREMENT BY 10
MAXVALUE 9990
NOCACHE
NOCYCLE;
REM ********************************************************************
REM Create the JOBS table to hold the different names of job roles within the company.
REM HR.EMPLOYEES has a foreign key to this table.
Prompt ****** Creating JOBS table ....
CREATE TABLE jobs
( job_id VARCHAR2(10)
, job_title VARCHAR2(35)
CONSTRAINT job_title_nn NOT NULL
, min_salary NUMBER(6)
, max_salary NUMBER(6)
) ;

Create ora1 user

DROP USER ora1 CASCADE;

CREATE USER ora1
  IDENTIFIED BY ora1
  DEFAULT TABLESPACE USERS
  TEMPORARY TABLESPACE TEMP
  PROFILE DEFAULT
  ACCOUNT UNLOCK;
  -- 2 Roles for ora1
  GRANT RESOURCE TO ora1;
  GRANT SELECT_CATALOG_ROLE TO ora1;
  ALTER USER ora1 DEFAULT ROLE ALL;
  -- 7 System Privileges for ora1
  GRANT ALTER SESSION TO ora1;
  GRANT CREATE DATABASE LINK TO ora1;
  GRANT CREATE SEQUENCE TO ora1;
  GRANT CREATE SESSION TO ora1;
  GRANT CREATE SYNONYM TO ora1;
  GRANT CREATE VIEW TO ora1;
  GRANT UNLIMITED TABLESPACE TO ora1;
  -- 1 Object Privilege for ora1
    GRANT EXECUTE ON SYS.DBMS_STATS TO ora1;
------------------------------------------------------------------------------------------------------------


Thursday, June 16, 2016

How to reconfigure OBIEE to connect to new Database Host

For some reason, your database have been moved to new host. And then you must reconfigure OBIEE application to replect the new Database Host. The following is the steps that you will do to make changes:
Change DB connection information in tnsnames.ora file:
$MW_HOME/Oracle_BI1/network/admin/tnsnames.ora
$MW_HOME/oracle_common/network/admin/tnsnames.ora
Reconfigure OBIEE using Administration Console & Enterprise Manager
Datasources:

Update new Database connection for all Data Sources as below:



BI Scheduler
configure file: $ORACLE_INSTANCE/config/OracleBISchedulerComponent/coreapplication_obisch1/ instanceconfig.xml
Start OBIEE component(opmnctl startall)

You cant also use this topic to move BI Application and Database to new hosts for many purpose, ex: Testing, Develop, …

Friday, May 27, 2016

Create New Repository – The connection has failed

That was installed last two weeks. As you see I’m a beginner in OBI.
To day, I follow the document “Creating a Repository Using the Oracle BI 11g Administration Tool” to create the new repository for the BI system. But I have error “The connection has failed”. The error is as the follow image:

The logfile say that:
[2014-06-23T01:03:25.000+07:00] [OracleBIServerComponent] [ERROR:1] [] [] [ecid: ] [tid: 1b9c]  [nQSError: 17014] Could not connect to Oracle database. [[
[nQSError: 17001] Oracle Error code: 12154, message: ORA-12154: TNS:could not resolve the connect identifier specified at OCI call OCIServerAttach.]]

But I can connect to Database server using sqlplus via cmd in Windows. I don’t know why. After google I found the solution.

To fix this error you must define environment variable TNS_ADMIN as bellow:

Automate start/stop OBIEE using Oracle WebLogic Scripting Tool (WLST) on Linux

We can use command to start/stop OBIEE(Admin Server, Managed Server and OPNM-System Components) in the Doc ID 1240964.1. But by this method we must tail the log file to determine if the Admin Server/Managed Server is started completely. After that you start the next commands. So you have your eyes glued to screen and wait util you see some pattern, ex: "Server started in RUNNING mode". It's hard to write an auto start shell script.
There is another method that you can start/stop OBIEE by writing an auto start shell script. It is Oracle Weblogic Scripting Tool(WLST). This note I will write an shell script to start/stop OBIEE.

My test environment:
OBIEE 11.1.1.7.0 is install on single Oracle Linux 6 x64 host.
Linux user: bi
Environment variables:
    $HOME=/home/bi
    $MW_HOME=/obiee11
    $WL_HOME=/obiee11/wlserver_10.3
    $BI_ORACLE_HOME=/obiee11/Oracle_BI1
    $DOMAIN_HOME=/obiee11/user_projects/domains/bifoundation_domain

Start OBIEE:
Create an WLST script file wlst_start_bi.py with the content as below
startNodeManager(verbose='true', PropertiesFile='/obiee11/wlserver_10.3/common/nodemanager/nodemanager.properties');
nmConnect('weblogic','password', host='192.168.x.x',port='9556',domainName='bifoundation_domain',domainDir='/obiee11/user_projects/domains/bifoundation_domain',nmType='ssl');
nmStart(serverName='AdminServer', domainDir='/obiee11/user_projects/domains/bifoundation_domain');
nmServerStatus('AdminServer')
connect('weblogic', 'password', 't3://localhost:7001');
start('bi_server1', 'Server');
exit();
Note: value 9556 is granted to port parameter in nmConnect is the Listening port of NodeManager. It is defined by ListenPort parameter in /obiee11/wlserver_10.3/common/nodemanager/nodemanager.properties. This ListenPort parameter must be the same as the one defined by <node-manager> → <listen-port> tag in /obiee11/user_projects/domains/bifoundation_domain/config/config.xml. Shortly they are defined at 9556 in my test.

Encapsulate all tasks into a shell script
#! /bin/bash
. /obiee11/wlserver_10.3/server/bin/setWLSEnv.sh
java weblogic.WLST /home/bi/wlst_start_bi.py
opmnctl startall
opnmctl status

Now you have a script to start OBIEE. You can exectute it when you need or auto start at the boot time.
Stop OBIEE:
Create an WLST script file, wlst_stop_bi.py
nmConnect('weblogic','password',host='192.168.x.x',port='9556',domainName='bifoundation_domain',domainDir='/obiee11/user_projects/domains/bifoundation_domain',nmType='ssl');
connect('weblogic','password', 't3://localhost:7001');
shutdown('bi_server1', 'Server', ignoreSessions='true', timeOut=600, force='true');
disconnect();
nmKill('AdminServer');
stopNodeManager();
exit();

Encapsulate all tasks into a shell script
#! /bin/bash
. /obiee11/wlserver_10.3/server/bin/setWLSEnv.sh
java weblogic.WLST /home/bi/wlst_stop_bi.py
opmnctl stopall

Let's try and leave your comment!

Reference:
    http://docs.oracle.com/cd/E23943_01/web.1111/e13740/starting_nodemgr.htm#NODEM220
    http://docs.oracle.com/cd/E23943_01/web.1111/e13715/manage_servers.htm#WLSTG169
    http://docs.oracle.com/cd/E23943_01/web.1111/e13813/reference.htm#WLSTC158
    http://ram-obi.blogspot.com/2011/10/how-to-start-stop-obiee-11g-1111x-unix.html

Wednesday, January 20, 2016

Cách lưu file excel sang file CSV vẫn giữ font tiếng Việt

 Mấy hôm nay gặp vấn đề về font tiếng Việt với  file csv. Vấn đề chi tiết như sau.
 Mình có file dữ liệu là excel *.xls . Vì nhu cầu công việc mình cần phải chuyển nó sang file có định dạng *.csv để import vào một ứng dụng của công ty. Mặc dù trong Excel có chức năng Save As, chọn type là *.csv; nhưng Excel lại không hỗ trợ Unicode. Do đó file *.csv sau khi tạo bằng chức năng Save As của Excel bị mất font tiếng Việt.
 Lên net tìm một một buổi chẳng có chỉ thấy ai làm được. Chỉ có cách của Anhgolden's Blog! . Nhưng cách này thì rườm rà, không hay.
Thế là mình quyết định viết một macro ngay trên Excel để chuyển font Unicode sang UTF8. Rồi sau đó dùng chức năng Save As của Excel để lưu ra file *.csv. Vì đặc tính của UTF8 là dùng nhiều ký tự 1byte để biểu diễn cho một ký tự Unicode nhiều bytes. Nên file *.csv tạo ra vẫn có tiếng Việt. Và có thể import vào ứng dụng của công ty. Hiện nay, hầu hết các ứng dụng đều hỗ trợ UTF8(nhưng Excel không hiễn thị được tiếng Việt UTF8 nhé).
Giờ thì chỉ mỗi việc mở file excel có macro (Link download) run macro để chuyển font Unicode sang UTF8 là có file *.csv với font Tiếng Việt. Bài viết giúp được bạn comment cảm ơn để người sau biết hữu dụng mà dùng.

  Dưới đây là demo: