Monday, August 3, 2015

การแก้ไขปัญหา Oracle + Toad :: You have no Oracle Clients Installed

Problem
ปัญหามีดังนี้  อยู่ดีๆ มาวันนึง TOAD 9.0.0.160 ที่เคยใช้ปกติ เกิดใช้ขึ้นมาไม่ได้ เสียอย่างนั้น โดย error message ที่เจอก็คือ

You have no Oracle Clients Installed

ถึงกับงงกันไปเลย ทั้งๆ ที่มันก็ไม่ได้มีอะไรผิดปกติ  ตัว client มันก็ต้องมีอยู่แล้ว เพราะว่าใช้กันทุกวัน

OS ที่ใช้คือ Windows XP SP2

Solution
เมื่อเจอปัญหา ก็ลองไปค้นหาใน google ก็ไม่ได้เรื่องอะไรเลย ไม่เจออะไรนอกจากปัญหาที่เจอกัน ที่ไม่มีการแก้ไขอะไร

แต่พอดูไปเรื่อยๆ ก็ไปเจอกับบทความเกี่ยวกับการใช้ติดต่อไปยัง Oracle server โดยไม่ต้องติดตั้ง Oracle client มันก็เข้าทางเราเลย เพราะว่า เครื่องเราเป็น client เหมือนกัน และต้องการติดต่อไปยัง Server เท่านั้น และเรายังติดตั้ง Oracle client ไว้อีก

ดังนั้นมาดูวิธีการหน่อยว่าทำอย่างไร
1. ไป Download Oracle Instant Client จากที่นี่
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

แล้วก็เลือกตาม OS ที่ใช้งานกันเลย

โดยผมเลือกใช้
  • Instant Client for Microsoft Windows (32-bit) 
  • และเลือก version เลย จากที่ลองใช้งานนั้นในเครื่องผม ที่ทำงานได้คือ Version 10.1.0.5 Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications

2. หลังจากที่ downalod มาแล้วก็ extract ออกมาซะ 
ตัวอย่างที่ผมได้คือ

c:\instant_client\instantclient10_1

โดยใน folder จะประกอบไปด้วย file ต่างๆ เช่น oci.dll, ojdbc.jar เป็นต้น

3. ทำการ config environment variables ของระบบดังนี้
สำหรับ folder ที่เก็บ file tnsnames.ora ซึ่งถ้ามีอยู่แล้วก็กำหนดไปเลย เช่น
Quote
TNS_ADMIN=c:\oracle\product\NETWORK\ADMIN
PATH=c:\instant_client\instantclient10_1;%PATH%

หมายเหตุ
  • สร้าง TNS_ADMIN ใน User Variable
  • แก้ไข PATH ใน System Variable

ถ้าไม่มี file tnsnames.ora ก็สามารถสร้างขึ้นมาเองได้ครับ

4. ทำการทดสอบโดยเปิด TOAD ขึ้นมาดู จะพบว่าปัญหาจะหมดไปแล้ว

Wednesday, July 22, 2015

Config Create Service Windows and New Instance Report Oracle 11g


Script Create Service Weblogic 
SETLOCAL
set DOMAIN_NAME=FormsReports
set USERDOMAIN_HOME=D:\Oracle\Middleware\user_projects\domains\FormsReports
set SERVER_NAME=AdminServer
set PRODUCTION_MODE=true
cd %USERDOMAIN_HOME%
call %USERDOMAIN_HOME%\bin\setDomainEnv.cmd
call "D:\Oracle\Middleware\wlserver_10.3\server\bin\installSvc.cmd"
ENDLOCAL

Script Create Service Form
SETLOCAL
set DOMAIN_NAME=FormsReports
set USERDOMAIN_HOME=D:\Oracle\Middleware\user_projects\domains\FormsReports
set SERVER_NAME=WLS_FORMS
set PRODUCTION_MODE=true
set ADMIN_URL=http://PST-PMISAPPSRV1.mbk-center.mbk:7001
cd %USERDOMAIN_HOME%
call %USERDOMAIN_HOME%\bin\setDomainEnv.cmd
call "D:\Oracle\Middleware\wlserver_10.3\server\bin\installSvc.cmd"
ENDLOCAL

Script Create Service Report
SETLOCAL
set DOMAIN_NAME=FormsReports
set USERDOMAIN_HOME=D:\Oracle\Middleware\user_projects\domains\FormsReports
set SERVER_NAME=WLS_REPORTS
set PRODUCTION_MODE=true
set ADMIN_URL=http://PST-PMISAPPSRV1.mbk-center.mbk:7001
cd %USERDOMAIN_HOME%
call %USERDOMAIN_HOME%\bin\setDomainEnv.cmd
call "D:\Oracle\Middleware\wlserver_10.3\server\bin\installSvc.cmd"
ENDLOCAL



Uninstall Service 
@echo off
SETLOCAL

set WL_HOME=D:\Oracle\Middleware\wlserver_10.3

rem *** Uninstall the service
"%WL_HOME%\server\bin\beasvc" -remove -svcname:"beasvc adf_domain_AdminServer"

ENDLOCAL


Create Instance Report Server
ORACLE_INSTANCE/bin/opmnctl createcomponent \
-adminUsername weblogic \
-adminHost ${ADMIN_HOST} \
-adminPort ${ADMIN_PORT} \
-oracleHome ${ORACLE_HOME} \
-oracleInstance ${ORACLE_INSTANCE} \
-instanceName $INSTANCE_NAME \
-componentName \
-componentType ReportsServerComponent

Example Script Create New Report Instance
opmnctl createcomponent -adminUsername weblogic -adminHost PST-PMISAPPSRV1 -adminPort 7001 -oracleHome D:\Oracle\Middleware\as_1 -oracleInstance D:\Oracle\Middleware\asinst_1 -instanceName asinst_1 -componentName ReportsServer_Promis -componentType ReportsServerComponent

Script Start Instance
opmnctl startproc ias-component=ReportsServer_Promis

Fix Error Open Oracle Form 11g in web Brower to Hang



in path
D:\Oracle\Middleware\user_projects\domains\FormsReports\config\fmwconfig\servers\WLS_FORMS\applications\formsapp_11.1.1\config\formsweb.cfg

change session
from WebUtilArchive=frmwebutil.jar,jacob.jar
to      WebUtilArchive=jacob.jar, frmwebutil.jar


Reinstall node manager Oracle 11g (case not auto start)



node manager log -> %Oracle_home%\wlserver_10.3\common\nodemanager

Uninstall -> D:\Oracle\Middleware\wlserver_10.3\server\bin\uninstallNodeMgrSvc.cmd

Install -> D:\Oracle\Middleware\wlserver_10.3\server\bin\installNodeMgrSvc.cmd

Path config file AS server 11g

Oracle Forms 11g Configuration Files
$DOMAIN_DIR -> D:\Oracle\Middleware\user_projects\domains\FormsReports
%ORACLE_HOME% -> D:\Oracle\Middleware
$ORACLE_INSTANCE -> D:\Oracle\Middleware\frinst


Servlet environment file
default.env => $DOMAIN_DIR\config\fmwconfig\servers\WLS_FORMS\applications\formsapp_11.1.1\config


Forms Services application configuration information
formsweb.cfg => $DOMAIN_DIR\config\fmwconfig\servers\WLS_FORMS\applications\formsapp_11.1.1\config


Java - Jar files copy handleimage.jar, myAppIcons.jar, jacob.jar
Java => %ORACLE_HOME%\as_1\forms\java
Java => D:\Oracle\Middleware\as_1\forms\java

copy jacob.dll -> %ORACLE_HOME%\as_1\forms\webutil
        -> D:\Oracle\Middleware\as_1\forms\webutil


Tnsname
tnsnames.ora => $ORACLE_INSTANCE\config\tnsnames.ora
tnsnames.ora => D:\Oracle\Middleware\frinst\config\tnsnames.ora


Config Port change 8888 to 80
httpd.conf => $ORACLE_INSTANCE\config\OHS\ohs1\httpd.conf
httpd.conf => D:\Oracle\Middleware\frinst\config\OHS\ohs1\httpd.conf

Config Port forms
forms.conf => $ORACLE_INSTANCE\config\OHS\ohs1\moduleconf\forms.conf

Report Config
rwserver.conf => $ORACLE_INSTANCE\config\ReportsServerComponent\$ReportServer\rwserver.conf
reports_ohs.conf => $ORACLE_INSTANCE\config\OHS\ohs1\moduleconf\reports_ohs.conf


Config visual path mappings (download)
httpd.conf => $ORACLE_INSTANCE\config\OHS\ohs1\httpd.conf
httpd.conf => D:\Oracle\Middleware\frinst\config\OHS\ohs1\httpd.conf


WEBUTIL Files: (upload)
webutil.cfg => $ORACLE_INSTANCE\config\FormsComponent\forms\server


Font
D:\Oracle\Middleware\frinst\config\FRComponent\frcommon\tools\COMMON\uifont.ali




Others.
Forms servlet aliases
web.xml => $DOMAIN_DIR\servers\WLS_FORMS\stage\formsapp\11.1.1\formsapp\WEB-INF\web.xml


configure Forms Trace
ftrace.cfg => $ORACLE_INSTANCE\config\FormsComponent\forms\server


webutilbase.htm; webutiljpi.htm => $ORACLE_INSTANCE\config\FormsComponent\forms\server

วิธีการเซ็ต Java บนเครื่อง client




1.       ทำการ Installment  Java ซึ่งจะต้อง เลือกว่าจะลง java กับ windows ที่ลงกับเครื่อง ว่าเป็น 32 หรือ 64 บิต

2.       หลังจากลงเสร็จแล้ว ทำการเลือกไปที่ Start -> Setting -> Control Panel -> เลือก Java ดังรูป



3.       ไปที่ Tab Advanced แล้วทำการเซ็ต ดังรูป ใน ส่วน Security -> General


4.       เซ็ตในส่วน Security -> Mixed code เลือก Disable verification หลังจะเซ็ตเสร็จทำการ กดปุ่ม Apply และ OK ต่อไป


5.       เข้าหน้าโปรแกรม Internet Explorer และ เลือกไปที่ Tools -> Internet Options



ทำการเข้าไปที่ Security และทำการเซ็ตแบบในรูป และทำการกดปุ่ม apply และ OK หลังจากนั้นก็สามารถทำการเข้าโปรแกรมได้ตามปกติ ในการเข้าครั้งแรกจะใช้เวลาในการเข้าใช้งานนานนิดครับ ประมาณ 2 นาที โดยประมาณ




                ขั้นตอนในการเซ็ต แชท Path ให้ระบบ PROMIS  สามารถ ก๊อป ไฟล์ลงเครื่อง Client ได้




 ไปที่ C:\Program Files เลือกที่ Folder ที่ชื่อว่า JAVA คลิ๊กขวา เลือก Sharing and Security และทำการเลือก แชร์เลือก user เป็น Even one และทำการ ติ๊ก เลือก Full Control แล้วทำการ กดปุ่ม Apply และ OK






               



Create Oracle ODBC


example using Access instead of MS SQL Server.

NOTE: No guarantees whatsoever. This example just shows how to connect to an Access database from within Forms. I strongly suggest that you do this from the database and not from forms directly. But for the sake of the example, here goes:

Environment:
•WIndows XP

•Oracle 10g XE

•MS Access 2003

•Forms 10g


STEP I:
Create a simple access database. In this example, it is "C:\orafaq\Orafaq.mdb". This database contains a single table, called "emp" with the columns "ename" and "empno".

STEP II:
In the ODBC Data source administrator, you need to add a System DSN pointing to this database. So you select "MS Access Driver" and add the name "OrafAccess" in the data source name. Make sure you've added the correct .mdb file (orafaq.mdb)

STEP III:
Now we set up the HS init file: it's name is fixed (init.ora). It contains only two lines of code:

$ORACLE_HOME/hs/admin/initOrafAccess.ora:

#
# HS init parameters
#
HS_FDS_CONNECT_INFO = OraFaccess
HS_FDS_TRACE_LEVEL = 0


STEP IV:
Next, I changed the listener.ora of my XE database:
$ORACLE_HOME/network/admin/listener.ora:
added in SID_LIST:

    (SID_DESC =
         (SID_NAME = OrafAccess)
         (ORACLE_HOME = )
         (program = hsodbc)
        )

STEP V:
$ORACLE_HOME/network/admin/tnsnames.ora:
The setup of the HSODBC is done, and we need to make it accessible for our Oracle users. Like any other database there has to be an entry in the TNSNAMES.ORA file:

ORAFACCESS =
   (description =
    (address = (protocol=tcp)(host=localhost)(port=1521))
     (connect_data = (sid=orafaccess))
     (hs=ok)
   )

STEP VI:
bounce the listener. You can do this befor step V, but I just did it in this order.

STEP VII:
SQL*Plus:


SQL> create database link orafaccess using 'ORAFACCESS';

Database link created.

SQL> desc emp@orafaccess
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------

 empno                                              NUMBER(10)
 ename                                              VARCHAR2(50)

SQL> create synonym access_emp for emp@orafaccess;

Synonym created.

SQL> desc access_emp;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------

 empno                                              NUMBER(10)
 ename                                              VARCHAR2(50)

SQL>

STEP VIII:
In Forms we make a basic form:
- data block wizard
- table Access_emp
- key mode UPDATEABLE (rowid won't work)
- empno = primary key
- layout wizard
- tabular design

I added double quotes (") around the column names in the property palette. I also added the following triggers:
ON-COMMIT:

BEGIN
   COMMIT_FORM;
END;
ON-LOCK:

BEGIN
   NULL;
END;
ON-DELETE:

BEGIN
   DELETE_RECORD;
END;I'm not 100% convinced that the ON-DELETE trigger is necessary but it didn't hurt. The ON-LOCK trigger and ON-COMMIT triggers were necessary due to differences in Access locking mechanism. I can't tell whether it will work like that in MS SQL Server...

Test the form. Enjoy! 

How to Create shell script to Start Database and Checking Table Space

 #dr_check_db_ERPGF.sh #!/bin/bash #run ./dr_check_db_ERPGF.sh | tee dr_ERPGF.out echo -e "\n" echo -e "+++++ Start Check Dat...