High Availbility

OS & Virtualization

Friday, July 04, 2008

How to create PLSQL webservice

How to create PLSQL webservice

Required Software

Generating webservice ear

  1. Create a config.xml file
    class="com.evermind.sql.DriverManagerDataSource" name="OracleDS" location="jdbc/OracleCoreDS" xa-location="jdbc/xa/OracleXADS" ejb-location="jdbc/OracleDS" connection-driver="oracle.jdbc.driver.OracleDriver" username="store"
    password="store"
    url="jdbc:oracle:thin:@localhost:1521:ORCL" inactivity-timeout="30"/>

  2. Run the following command
    set JAVA_HOME=c:\j2sdk1.4.2_06set
    ORACLE_HOME=c:\oracle\oc4j
    set CLASSPATH=.;%ORACLE_HOME%\webservices\lib\wsdl.jar;%ORACLE_HOME%\lib\xmlparserv2.jar;%ORACLE_HOME%\soap\lib\soap.jar
    call %JAVA_HOME%\bin\java -jar %ORACLE_HOME%\webservices\lib\WebServicesAssembler.jar -config .\config.xml

Thursday, June 26, 2008

Flash Recovery usiing Image Copy

Flash Recovery using Image Copy
Image Copy
Oracle RMAN image copies are exact copies of the datafiles, with all the blocks—used or not. Oracle RMAN takes this image copy while the database is up and running, and the database need not be put into any special mode.
Here is how to make an Oracle RMAN image copy backup:
run {
   backup as copy
   database; }

Instant Recovery
Image copies in the FRA become truly useful when you need an "instant recovery." Remember that these image copies are copies of the datafiles—a fact recorded in the Oracle RMAN catalog and the control file. In case of a disaster, you don't need to restore the file; you can use the copy as the principal datafile immediately.
Here is the description of the recovery process, assuming that the USERS tablespace has been damaged: First, check the file ID (number) and name of the datafile of the tablespace. The output is shown in vertical format:
select file_id, file_name  from dba_data_files 
where tablespace_name  = 'USERS'; 
FILE_ID : 4 NAME    : /home/oracle/oradata/PRODB2/users01.dbf 
RMAN> sql 'alter tablespace users offline';
 sql statement: alter tablespace users offline 
RMAN> switch datafile 4 to copy;
 datafile 4 switched to datafile copy "/home/oracle/FRA/PRODB2/datafile/o1_mf_users_2kmqr57t_.dbf" 
RMAN> recover datafile 4;
 Starting recover at 26-SEP-06 using channel ORA_DISK_1
 starting media recovery media recovery complete,
 elapsed time: 00:00:03
 Finished recover at 26-SEP-06  
RMAN> sql 'alter tablespace users online';
 sql statement: alter tablespace users online
 
Switchback 

Even though the datafile has been quickly brought online to minimize downtime, it is now in the backup location, which may be on slower disks than what the main database is on. You may not want to run the database with the datafile at this location for long; you would typically want to move the datafile back to the original location—/home/oracle/oradata/PRODB2/—as soon as it becomes available. You can use Oracle RMAN to accomplish this. Here is a summary of the steps:
1. Make an image copy of the datafile at the original location. 2. Take the tablespace offline. 3. Switch the datafile to the "copy" (however, in this case, the "copy" is at the original location). 4. Recover the tablespace. 5. Place the tablespace online.
These steps are presented in Listing 4. After the switchover, you can make sure the datafile is back in its original location:
select name from v$datafile  where file# = 4;
   NAME ---------------------------------------
 /home/oracle/oradata/PRODB2/users01.dbf
 
RMAN> backup as copy datafile 4 format '/home/oracle/oradata/PRODB2/users01.dbf';
   Starting backup at 27-SEP-06 using channel
 ORA_DISK_1 channel ORA_DISK_1: starting datafile
 copy input datafile fno=00004 name=/home/oracle/FRA/PRODB2/datafile/o1_mf_users_2kmqr57t_.dbf
 output filename=/home/oracle/oradata/PRODB2/users01.dbf
 tag=TAG20060927T103710 recid=45 stamp=602246230 channel
 ORA_DISK_1: datafile copy complete,
 elapsed time: 00:00:01
 Finished backup at 27-SEP-06
   Starting Control File Autobackup at 27-SEP-06 piece handle=/home/oracle/FRA/PRODB2/autobackup/2006_09_27/ o1_mf_n_602246232_2ko34s42_.bkp comment=NONE 
Finished Control File Autobackup at 27-SEP-06 RMAN> sql 'alter tablespace users offline'; ... 
RMAN> switch datafile 4 to copy;   datafile 4 switched to datafile copy "/home/oracle/oradata/PRODB2/users01.dbf"  
RMAN> recover datafile 4; ... 
RMAN> sql 'alter tablespace users online'; ... 
 
In case of a failure, you save valuable time by quickly using the image copy of the datafile in the FRA, and there is no need to restore it first. The same concept can be applied to the entire database as well. If the original location of all the datafiles is damaged, you can easily switch the entire database to the copy stored in the FRA. To switch to the FRA copy, issue the following, which directs the whole database to use all the latest image copies in the FRA location as its datafiles: 
 
RMAN> switch database to copy;  
 


Recover database after disk loss

Control Files

 
Normally, we have multiplexing of controlfiles and they are expected to be placed in different disks.
 
If one or more controlfile is/are lost,mount will fail as shown below:
....
ORA-00205: error in identifying controlfile, check alert log for more info
 
**If at least one copy of the controlfile is not affected by the disk failure, 
   When the database is shutdown cleanly:
   (a) Copy a good copy of the controlfile to the missing location
   (b) Start the database 
 
   Alternatively, remove the lost control file location specified in the nit parameter control_files and start the database.
 
   **If all copies of the controlfile are lost due to the disk failure, then: Check for a backup controlfile. Backup controlfile is normally taken using either of the following commands:
   (a) SQL> alter database backup controlfile to '/backup/control.ctl';
    -- This would have created a binary backup of the current controlfile --
 
    -->If the backup was done in binary format as mentioned above, restore the file to the lost controlfile locations using OS copying utilities.
    --> SQL> startup mount;
    --> SQL> recover database using backup controlfile;
    --> SQL> alter database open;
 
   (b) SQL> alter database backup controlfile to trace;
    -- This would have created a readable trace file containing create controlfile script --
 
    --> Edit the trace file created (check user_dump_dest for the location) and retain the SQL commands alone. Save this to a file say cr_ctrl.sql
รจ      Run the script
 

Redo logs

In normal cases, we would not have backups of online redo log files. But the inactive logfile changes could already have been checkpointed on the datafiles and even archive log files may be available.
 
SQL> 
     ORA-00313: open failed for members of log group 1 of thread 1
     ORA-00312: online log 1 thread 1: '/ORACLE/ORADATA/H817/REDO01.LOG'
     ORA-27041: unable to open file
     OSD-04002: unable to open file
     O/S-Error: (OS 2) The system cannot find the file specified.
 
** Verify if the lost redolog file is Current or not.
     SQL> select * from v$log;
     SQL> select * from v$logfile; 
 
     --> If the lost redo log is an Inactive logfile, you can clear the logfile:
 
     SQL> alter database clear logfile GROUP 1;
 
     Alternatively, you can drop the logfile if you have atleast two other logfiles:
     SQL> alter database drop logfile group 1;
     
     --> If the logfile is the Current logfile, then do the following:
     SQL> recover database until cancel;
     SQL>alter database open resetlogs;
 
If the database is in noarchivelog mode and if ORA-1547, ORA-1194 and ORA-1110 errors occur, then you would have restore from an old backup and start the database.
 
Note that all redo log maintenance operations are done in the database mount state
    

Parameter file

This is not a major loss and can be easily restored. Options are:
1.       If there is a backup, restore the file
2.       If there is no backup, copy sample file or create a new file and add the required parameters. Ensure that the parameters db_name, control_files,vdb_block_size, compatible are set correctly
3.    If the spfile is lost, you can create it from the init parameter file

Flash Recovery using Image Copy

Flash Recovery using Image Copy


Image Copy
Oracle RMAN image copies are exact copies of the datafiles, with all the blocks—used or not. Oracle RMAN takes this image copy while the database is up and running, and the database need not be put into any special mode.
Here is how to make an Oracle RMAN image copy backup:



 
run {
   backup as copy
   database; }
 



Instant Recovery 

Image copies in the FRA become truly useful when you need an "instant recovery." Remember that these image copies are copies of the datafiles—a fact recorded in the Oracle RMAN catalog and the control file. In case of a disaster, you don't need to restore the file; you can use the copy as the principal datafile immediately.  
Here is the description of the recovery process, assuming that the USERS tablespace has been damaged: First, check the file ID (number) and name of the datafile of the tablespace. The output is shown in vertical format:





 select file_id, file_name from dba_data_files where tablespace_name = 'USERS';
FILE_ID : 4 NAME : /home/oracle/oradata/PRODB2/ users01.dbf








 RMAN> sql 'alter tablespace users offline';
sql statement: alter tablespace users offline
RMAN> switch datafile 4 to copy;
datafile 4 switched to datafile copy "/home/oracle/FRA/PRODB2/datafile/o1_mf_users_2kmqr57t_.dbf"
RMAN> recover datafile 4;
Starting recover at 26-SEP-06 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:03 Finished recover at 26-SEP-06
RMAN> sql 'alter tablespace users online'; sql statement: alter tablespace users online



 
Switchback 

Even though the datafile has been quickly brought online to minimize downtime, it is now in the backup location, which may be on slower disks than what the main database is on. You may not want to run the database with the datafile at this location for long; you would typically want to move the datafile back to the original location—/home/oracle/oradata/PRODB2/—as soon as it becomes available. You can use Oracle RMAN to accomplish this. Here is a summary of the steps: 

1. Make an image copy of the datafile at the original location.
2. Take the tablespace offline.
3. Switch the datafile to the "copy" (however, in this case, the "copy" is at the original location).
4. Recover the tablespace.
5. Place the tablespace online. 

These steps are presented in Listing 4. After the switchover, you can make sure the datafile is back in its original location: 

select name from v$datafile  where file# = 4;
NAME ---------------------------------------
/home/oracle/oradata/PRODB2/users01.dbf
 
 
RMAN> backup as copy datafile 4 format '/home/oracle/oradata/PRODB2/users01.dbf';
Starting backup at 27-SEP-06 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile fno=00004 name=/home/oracle/FRA/PRODB2/datafile/o1_mf_users_2kmqr57t_.dbf output filename=/home/oracle/oradata/PRODB2/users01.dbf tag=TAG20060927T103710 recid=45 stamp=602246230 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 27-SEP-06 Starting Control File Autobackup at 27-SEP-06 piece handle=/home/oracle/FRA/PRODB2/autobackup/2006_09_27/ o1_mf_n_602246232_2ko34s42_.bkp comment=NONE Finished Control File Autobackup at 27-SEP-06 RMAN> sql 'alter tablespace users offline'; ... RMAN> switch datafile 4 to copy; datafile 4 switched to datafile copy "/home/oracle/oradata/PRODB2/users01.dbf" RMAN> recover datafile 4; ... RMAN> sql 'alter tablespace users online'; ...
In case of a failure, you save valuable time by quickly using the image copy of the datafile in the FRA, and there is no need to restore it first. The same concept can be applied to the entire database as well. If the original location of all the datafiles is damaged, you can easily switch the entire database to the copy stored in the FRA. To switch to the FRA copy, issue the following, which directs the whole database to use all the latest image copies in the FRA location as its datafiles: 
RMAN> switch database to copy;  



Wednesday, June 18, 2008

All About Explain Plan

Introduction

The EXPLAIN PLAN statement displays execution plans chosen by the Oracle optimizer for SELECT, UPDATE, INSERT, and DELETE statements. A statement's execution plan is the sequence of operations Oracle performs to run the statement.

Using V$SQL_PLAN

In addition to running the EXPLAIN PLAN command and displaying the plan, you can use the V$SQL_PLAN views to display the execution plan of a SQL statement:

 
Using Explain Plan
Steps
  • EXPLAIN PLAN FOR   SELECT last_name FROM employees;
  • SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());

About Autotrace

  1. cd $oracle_home/rdbms/admin

  2. log into sqlplus as system

  3. run SQL> @utlxplan

  4. run SQL> create public synonym plan_table for plan_table

  5. run SQL> grant all on plan_table to public

  6. exit sqlplus and cd $oracle_home/sqlplus/admin

  7. log into sqlplus as SYS

  8. run SQL> @plustrce

  9. run SQL> grant plustrace to public

 

You can control the report by setting the AUTOTRACE system variable.
  • SET AUTOTRACE ON EXPLAIN - The AUTOTRACE report shows only the optimizer execution path. 
  • SET AUTOTRACE ON STATISTICS - The AUTOTRACE report shows only the SQL statement execution statistics.  
  • SET AUTOTRACE ON  - The AUTOTRACE report includes both the optimizer execution path and the SQL statement execution statistics.  
  • SET AUTOTRACE TRACEONLY - Like SET AUTOTRACE ON, but suppresses the printing of the user's query output, if any. 


Wednesday, June 11, 2008

How to bypass Oracle installer check

Is there a way to get Oracle10g installed on other linux not specified in the pre-requities list?

<< ./runInstaller Starting Oracle Universal Installer... Checking installer requirements... Checking operating system version: must be redhat-2.1, UnitedLinux-1.0 or redhat-3 Failed <<<< ./runInstaller -ignoreSysPrereqs

Friday, May 23, 2008

OraPerf : Oracle Free Performance Monitor

Some of the program I did during my free time. This is a the first program in Visual Basic Express using Oracle connection string.


Most Oracle DBA have to face question like
  • In general, how well is my database running? What defines efficiency?
  • What average response time are my users experiencing?
  • OraPerf is a little tool which captures Oracle database information such as session and memory usage. It is based on Oracle 10g Dynamic views V$. The information will be update every seconds.

    http://download.cnet.com/OraPerf/3000-10254_4-10816959.html

    Update :
    • Include response time metrics
    Get it from CNET Download.com!
     

    Monday, May 12, 2008

    Oracle Wait Interface v$view

    Oracle Wait Interface

    Oracle Wait Interface has had the following four V$ views :

    • V$EVENT_NAME
    • V$SESSION_WAIT
    • V$SESSION_EVENT
    • V$SYSTEM_EVENT

    For 10g

    Oracle Database 10g Release 1 introduces the following new views to display wait information from several perspectives:

    • V$SYSTEM_WAIT_CLASS
    • V$SESSION_WAIT_CLASS
    • V$SESSION_WAIT_HISTORY
    • V$EVENT_HISTOGRAM
    • V$ACTIVE_SESSION_HISTORY

    V$EVENT_NAME

    It is a reference view that contains all the wait events defined for your database instance

    select event#, name, parameter1, parameter2, parameter3 from v$event_name order by name;

    V$SESSION_WAIT

    The V$SESSION_WAIT view provides detailed information about the event or resource that each session is waiting for. This view contains only one row of information per session, active or inactive, at any given time. Unlike the other views, this view displays session-level wait information in real time.

    V$SYSTEM_EVENT

    The V$SYSTEM_EVENT displays aggregated statistics of all wait events encountered by all Oracle sessions since the instance startup. It keeps track of the total number of waits, total timeouts, and time waited for any wait event ever encountered by any of the sessions.

    select b.class, a.*, c.startup_time
    from v$system_event a,
    v$event_name b,
    v$instance c
    where a.event = b.name
    order by b.class, a.time_waited;

    V$SESSION_EVENT

    The V$SESSION_EVENT view contains aggregated wait event statistics by session for all sessions that are currently connected to the instance. This view contains all the columns present in the V$SYSTEM_EVENT view and has the same meaning, but the context is session-level. It keeps track of the total waits, time waited, and maximum wait time of each wait event by session.

    break on sid skip 1 dup
    col sid format 999
    col event format a39
    col username format a6 trunc
    select b.sid,
    decode(b.username,null,
    substr(b.program,18),b.username) username a.event,
    a.total_waits,
    a.total_timeouts,
    a.time_waited,
    a.average_wait,
    a.max_wait,
    a.time_waited_micro
    from v$session_event a, v$session b
    where b.sid = a.sid + 1

    order by 1, 6;

    Wednesday, April 09, 2008

    Steps of recovering database using Rman from a barebone system. (ie you have lost everything). This is tested on Oracle 10g database.

    For setting up Rman, you should set controlfile autobackup on.

    Before you do this, you need to create the oradata and admin (bdump, cdump...) directories.


    C:\>rman target /
    connected to target database: orcl2 (not mounted)

    RMAN> set dbid=632410335
    RMAN> startup nomount;
    RMAN> set controlfile autobackup format for device type disk to 'c:\backup\%F';
    RMAN> restore spfile from autobackup;
    RMAN> restore controlfile from autobackup;
    RMAN> startup force mount;
    RMAN> restore database;
    RMAN> recover database;
    RMAN> alter database open resetlogs;

    Thursday, March 20, 2008

    Oracle Import Export GUI Tools



    Check out this tool "OraExport" which allow you to export Oracle data using a GUI interface. It generate a oracle export script and run it. This tool is especially useful to those Oracle DBA who often transfer data objects between Oracle database.

    Oracle newbie may also find it is very easy to Export/Import data objects with this tool even without typing an Export/Import parameter.
    This is a free tool to share.
    Requirements

    Related link on Oracle exp
    http://wiki.oracle.com/page/Oracle+export+and+import+
          
     
    Get it from CNET Download.com!

    Friday, March 07, 2008

    Oracle High Availability Solutions

    Oracle provides four popular high availability solutions:
    • Oracle Advanced Replication
    • Oracle Real Application Clusters (RAC)
    • Oracle Data Guard (physical/logical standby database)
    • Oracle Streams

    Advanced Replication

    Replication is the process of copying and maintaining database objects, such as tables, in multiple database that make up a distributed database system. Changes applied at one site are captured and stored locally before being forwarded and applied at each of the remote locations.

    Replication supports a variety of applications that often have different requirements. Some applications allow for relatively autonomous individual materialized view sites. Other applications require data on multiple servers to be synchronized in a continuous, nearly instantaneous manner to ensure that the service provided is available and equivalent at all times.

    Real Application Clusters (RAC)

    Oracle Real Application Clusters (RAC) allows multiple instances accessing a single database. The typical installation involves a cluster of nodes with access to a set of shared disks.

    Data Guard

    Oracle Data Guard is the management, monitoring, and automation software that work with a production database and one or more standby databases to protect data against failures, errors, and corruption that might otherwise destroy your database.

    Streams

    Oracle Streams enables you to share data and events in a stream. The stream can propagate this information within a database or from one database to another. The stream routes specified information to specified destinations.

    Using Oracle Streams, you control what information is put into a stream, how the stream flows or is routed from database to database, what happens to events in the stream as they flow into each database, and how the stream terminates.

    Thursday, January 17, 2008

    Oracle Streams setup

    Streams is basically a queuing technology.

    Here is how I get started. You can use Oracle 10g Enterprise Manager to create a schema level stream but apparently it has some bugs and work only on the later version.

    Login as stradmin

    This is a simple example of streaming data (one way) from source schema to target schema
    1. run @startup.sql
    2. On the source database , turn on supplemental logging for table or database:
      ALTER TABLE scott.dept ADD SUPPLEMENTAL LOG GROUP dept_pk(deptno) ALWAYS;
      or
      alter database add supplemental log data (primary key, unique index) columns;
    3. export schema from the source database.
      exp USERID=SYSTEM/manager@rep2 OWNER=SCOTT FILE=scott.dmp LOG=exportTables.log OBJECT_CONSISTENT=Y STATISTICS = NONE
    4. import schema into target database.
      imp USERID=SYSTEM@pluto FULL=Y CONSTRAINTS=Y FILE=scott.dmp IGNORE=Y COMMIT=Y LOG=importTables.log STREAMS_INSTANTIATION=Y
    5. run @startup.sql

    Tuesday, January 15, 2008

    How to move an Oracle Forms application from Windows to Linux

    Log-in access as the "oracle" user

    1. Create a staging directory where the application source files (FMB, MMB, PLL, OLB) can be stored permanently or temporarily. This directory will also be where the compiled executables (FMX, MMX, PLX) will be created. For example:
      mkdir /u02/oracle/ias904_mid/forms90/myApplication
    2. Copy/transfer all of the Forms components which make up the application to the directory created in step 2. These will include FMB, MMB, PLL and OLB files.
      IMPORTANT: Unix is a case sensitive operating system. Be sure that any references to files within your application have been corrected to match files on the new file system. This will usually impact references to image (icon) files, other forms, menus, and libraries.
      Copy/transfer all other application files as needed. These files may include custom resource (.res), image or custom JARs files. These files will need to be placed in specific locations based on how you developed the application. IMPORTANT: If transferring using FTP, all files must be transferred in binary mode.
    3. Open a shell session.
    4. Set the ORACLE_HOME variable and point it to the Application Server installation. Be sure to use the appropriate syntax for the particular shell you are using. For example in csh the command would look something like this:
      export ORACLE_HOME=/u02/oracle/ias904_mid
    5. Set the FORMS90_PATH variable to the directory which was created in step 2. For example:
      export FORMS90_PATH=/u02/oracle/ias904_mid/forms90/myApplication
      Additional variables may be necessary or desired based on your needs and system configuration. Here are a few examples:
      TNS_ADMIN
      NLS_LANG
      CLASSPATH
      TERM
      DISPLAY
      In most cases, setting these will not be necessary if you use the provided script (.sh file) noted in the next step.
      When compiling a Forms application it is important to understand the application. Most important is to understand the dependencies which may exist between components. In other words, for example you will not be able to compile an FMB if it has a dependant PLL which has not yet been compiled. In most cases the order in which compiling should occur is as follows:
      PLL
      MMB
      FMB
      There are exceptions, but this will work in most cases.
    6. Using the compiler, generate "X" files for all of the application's binaries (PLL, MMB, FMB). The command will be something like the following:

      f90genm.sh module=myForm module_type=form compile_all=yes userid=scott/tiger@orcl

      Other possible module_type values:
      library
      menu
      form

    How to add icons into Forms 10g using JAR

    Icon image files can either be retrieved by Forms as individual files on the
    filesystem or from a Java Archive (JAR file). If an application uses lots of
    icon images it is recommended that they are stored in a JAR file to reduce the
    number of HTTP round trips.

    Steps to achieve this in a 9iDS/10gDS environments and are given below:

    Oracle 9iDS/10gDS (Forms Builder / Runtime)


    This example assumes an install of 9iDS/10gDS on a MS Windows.

    1. Copy all the icons files (gif or jpg) to a folder e.g c:\icons folder
    2. Open up a MS Dos/ Command prompt window
    3. Change to the target icons folder
      cd c:\icons
      and jar the icon files
      jar -cvf icons.jar *
    4. Copy icons.jar to \forms90\java
      or
      Copy icons.jar to \forms\java
    5. Changes have to be made in formsweb.cfg
      a) archive_jini=xxall_jinit.jar,icons.jar
      b) imageBase=codeBase
      This signifies that the jar file is placed under the forms90/java or forms/java
      folder.

    Monday, December 31, 2007

    Generic code for Oracle forms calling reports

    PROCEDURE CALL_REPORT(rptname varchar2,paramval varchar2 default null,paraform varchar2 default 'N') IS
    plid paramlist;
    a_paralist varchar2(4000);
    report_id Report_Object;
    report_job_id VARCHAR2(100);
    report_status VARCHAR2(100);
    vc_use_report_server char(1) := 'N';
    vs_report_server varchar2(256) := 'GEOREPSRV';
    vs_report_server_url varchar2(256) := 'dev60cgi/rwcgi60';
    vs_report_format VARCHAR2(100) := 'pdf';
    BEGIN
    dbms_application_info.set_module('GEORPT',rptname);
    if paramval is null then
    a_paralist := 'PARAMFORM=NO';
    else
    a_paralist := 'PARAMFORM=NO' paramval;
    end if;
    -- vincent
    -- replace spaces with %20 for web.show_document
    a_paralist := replace(a_paralist,' ','%20');
    --

    plid := buildparamlist(a_paralist);

    if instr(UPPER(a_paralist),'COPIES=') > 0 then
    delete_parameter(plid,'COPIES');
    end if;
    if instr(UPPER(a_paralist),'DESFORMAT=') > 0 then
    vs_report_format := substr(a_paralist,(10 + instr(UPPER(a_paralist),'DESFORMAT=')),(instr(UPPER(a_paralist),'',instr(UPPER(a_paralist),'DESFORMAT=')) - instr(UPPER(a_paralist),'DESFORMAT=') - 10));
    delete_parameter(plid,'DESFORMAT');
    end if;
    if instr(UPPER(a_paralist),'BACKGROUND=') > 0 then
    delete_parameter(plid,'BACKGROUND');
    end if;
    if instr(UPPER(a_paralist),'CURRENCY=') > 0 then
    delete_parameter(plid,'CURRENCY');
    end if;
    if instr(UPPER(a_paralist),'DECIMAL=') > 0 then
    delete_parameter(plid,'DECIMAL');
    end if;
    if instr(UPPER(a_paralist),'DESNAME=') > 0 then
    delete_parameter(plid,'DESNAME');
    end if;
    if instr(UPPER(a_paralist),'DESTYPE=') > 0 then
    delete_parameter(plid,'DESTYPE');
    end if;
    if instr(UPPER(a_paralist),'MODE=') > 0 then
    delete_parameter(plid,'MODE');
    end if;
    if instr(UPPER(a_paralist),'ORIENTATION=') > 0 then
    delete_parameter(plid,'ORIENTATION');
    end if;
    if instr(UPPER(a_paralist),'PRINTJOB=') > 0 then
    delete_parameter(plid,'PRINTJOB');
    end if;
    if instr(UPPER(a_paralist),'THOUSANDS=') > 0 then
    delete_parameter(plid,'THOUSANDS');
    end if;

    begin
    select REF_STRING into vc_use_report_server from SYS_REF_TABLE where ref_code = 'USEREPSRV';
    if vc_use_report_server not in ('Y','N') then
    vc_use_report_server := 'N';
    end if;
    exception
    when no_data_found then
    insert into SYS_REF_TABLE (REF_CODE,REF_TITLE,REF_STRING) values ('USEREPSRV', 'Use Report Server','N');
    commit;
    vc_use_report_server := 'N';
    when others then
    vc_use_report_server := 'N';
    end;



    begin
    select REF_STRING into vs_report_server from SYS_REF_TABLE where ref_code = 'GEOREPSRV';
    vs_report_server := nvl(vs_report_server,'GEOREPSRV');
    exception
    when no_data_found then
    insert into SYS_REF_TABLE (REF_CODE,REF_TITLE,REF_STRING) values ('GEOREPSRV', 'GeO Report Server','GEOREPSRV');
    commit;
    vs_report_server := 'GEOREPSRV';
    when others then
    vs_report_server := 'GEOREPSRV';
    end;
    begin
    select REF_STRING into vs_report_server_url from SYS_REF_TABLE where ref_code = 'GEOREPSRVURL';
    vs_report_server_url := nvl(vs_report_server_url,'GEOREPSRVURL');
    exception
    when no_data_found then
    insert into SYS_REF_TABLE (REF_CODE,REF_TITLE,REF_STRING) values ('GEOREPSRVURL', 'GeO Report Server URL','dev60cgi/rwcgi60');
    commit;
    vs_report_server_url := 'dev60cgi/rwcgi60';
    when others then
    vs_report_server_url := 'dev60cgi/rwcgi60';
    end;
    report_id:= find_report_object('REPORT1');
    if GET_APPLICATION_PROPERTY(USER_INTERFACE) <> 'WEB' then
    vc_use_report_server := 'N';
    END IF;
    if vc_use_report_server = 'N' then
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_EXECUTION_MODE,RUNTIME);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE,SCREEN);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_FILENAME,rptname);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESFORMAT,vs_report_format);
    report_job_id:=run_report_object(report_id,plid);
    else
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_EXECUTION_MODE,RUNTIME);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE,CACHE);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESFORMAT,vs_report_format);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_FILENAME,rptname);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_SERVER,vs_report_server);
    report_job_id :=run_report_object(report_id,plid);
    report_status := report_object_status(report_job_id);

    if report_status = 'FINISHED' THEN
    IF UPPER(vs_report_format) = 'RTF' THEN
    Web.Show_Document(vs_report_server_url '/' url_encode2('getjobid' substr(report_job_id,length(vs_report_server) + 2)) '?' url_encode2('server') '=' url_encode2(vs_report_server) '&mimetype=application/msword', '_blank');
    ELSE
    Web.Show_Document(vs_report_server_url '/' url_encode2('getjobid' substr(report_job_id,length(vs_report_server) + 2)) '?' url_encode2('server') '=' url_encode2(vs_report_server), '_blank');
    END IF;
    else
    msg('Report failed with message ' report_status chr(13) substr(a_paralist,instr(UPPER(a_paralist),'P_USERNAME'),30) );
    end if;
    end if;
    dbms_application_info.set_module('','');
    END;

    How to setup Oracle Forms 10g IAS

    How to setup Oracle Forms 10g IAS



    Login to "Enterprise Manager"
    URL : http://localhost:18100/
    Default userid = ias_admin






    Setting Form servers
    Adding user defined icons.jar into d:\oracle\oas10g\forms\java






    Try testing the website thru config
    URL : http://localhost:7777/forms/frmservlet?config=geo

    Setting Report servers
    Check the current environment
    http://localhost:7777/reports/rwservlet/showenv

    Check what options you have
    http://localhost:7777/reports/rwservlet

    At Application server
    Change the conf file
    D:\oracle\OAS10G\reports\conf.conf
    Uncomment the sourcedir and add the geo directory where the reports is located

    At GEO
    10200 - System Reference Table
    GEOREPSRV =
    GEOREPSRVURL = /reports/rwservlet
    USEREPSRV = Y

    Export data on webForm using DAD

    How to export data on webform using DAD?
    Using DAD to export data on Oracle webform without using javabean . You need to setup DAD on the Application server first.

    Code in the calling oracle forms
    if GET_APPLICATION_PROPERTY(USER_INTERFACE) = 'WEB' then
    select REF_STRING into a_url from SYS_REF_TABLE where ref_code = 'DAD';
    Web.Show_Document(a_url '/stkmas_export?v_org_no=' :global.orgno '&v_stk_flg=S' , '_blank');

    Code in the store procedure

    PROCEDURE STKMAS_EXPORT AS
    cursor c1 is select STK_FLG,STK_C,NAME from stk_mas where org_no = v_org_no and stk_flg = v_stk_flg order by org_no,stk_c;
    BEGIN
    owa_util.mime_header('text/plain');
    for c1rec in c1 loop
    htp.p('STK_FLG^STK_C^NAME'); for c1rec in c1 loop htp.p(c1rec.STK_FLG '^' c1rec.STK_C '^' translate(c1rec.name,chr(10),'') '^');
    end loop;
    END STKMAS_EXPORT;

    How to set up Developer reports Server 6.0 on NT

    This is a step by step guide that helps you in setting up the Reports Server
    6.0 on the NT platform


    Set-up Procedure

    1. Add the Reports Server to the network configuration file.
      Add a line of the following form to

      ORACLE_HOME/net80/admin/tnsnames.ora: = ( ADDRESS= (PROTOCOL=TCP) (HOST=) (PORT=))

      where is the name of the Reports Multi-Tier Server instance. If you are using a sqlnet.ora file and default_domain is specified, remember to fully qualify the Reports Multi-Tier Server TNS name with the default domain. For example, if the default_domain is world, the repserver.world would be a valid TNS name. is the IP-adress or the hostname of the Application Server machine, and is the port number to which the Reports Multi-Tier Server is listening (such as, 1949).
    2. Install the Reports Multi-Tier Server as a NT-service
      Run the following command to install the RMTS as a service (Start - Run):

      rwmts60 -install tcpip
    3. Verify the settings of the service
      For the Reports Multi-tier server to run properly, it must have access to printers. Note that by default, the SYSTEM user does not have access to printers. Therefore, you must either set up a separate user to run the Reports Server or give the SYSTEM user access to printers. Since the latter can prove difficult, it is best to set up a separate user to run the Reports Server. In order to change the start-up account of the service, go to the Control Panel - Services.

      Look for the entry "Oracle Reports Server ." Click on Startup. From this startup dialog, select "This Account" on the Log On As section, and type in your operating system username and password. This specifies that the Reports Multi-tier Server is run as you. In addition, you can also set the service to be started automatically (when the system is booted up) or manually. If you install the service to run under a user other than SYSTEM, make sure that the user account:
      · Has the Password Never Expires option selected in the User Manager. · Has membership in the appropriate groups to run the Reports Multi-tier Server and access to the report files. · Has at least print permission to a default printer. · Can log on to a service. Go to Administration Tools User Manager, Policies, User Rights. Check Show Advanced User Rights; choose Log on a Service, and click the Add button.
    4. Starting/Monitoring/Stopping the service
      To start the service, go to the Control Panel, Services, and select the service, optionally enter command line arguments in Startup Parameters, and click on the Start button. If the service fails to start, check the Reports Server logfile for more information. The file is ORACLE_HOME\report60\ server\.log.
      In order to see if your Reports Server is running, simply go to Task manager, Processes, and check to see if the process ‘rw60mts.exe’ is listed.
      To stop the service, go to the Control Panel, Services, and select the service. Click on the Stop button.
    5. The Reports Server Configuration file
      A configuration file is created when the Reports Multi-tier Server is first started. The file is ORACLE_HOME\report60\server\.ora. Note that if you manually edit the file, the changes are not picked up by the Reports Multi-Tier Server until you shut it down and restart it. The four optional server command line arguments (minengine, maxengine, initengine, and maxidle) can be specified in the Startup Parameters in the Control Panel Services window to override the settings in the configuration file.

      So for the set-up, you can repeat steps 2 through 6 to set up and run multiple Reports Multi-tier Servers on one machine. Make sure that you specify different port numbers.

      NOTE: To uninstall the Reports Multi-tier Server service, go to the Control Panel, Services and stop the service. Then run the following command line:

      rwmts60 -uninstall

      NOTE: When running the Reports Server as a service, there is a known problem with Windows NT not sending report output to mail (DESTYPE=MAIL). Microsoft plans to fix this in Microsoft Exchange Server 5.0. In the meantime, you can get around this problem by running the Reports Server not a service.

    2.2.2 Installing the Reports Server as a non-service

    1. Be sure the PATH contains ORACLE_HOME/bin.
      Go to the Control Panel, System. and verify the value of the system variable PATH contains the ORACLE_HOME/bin directory.
    2. Add the Reports Server to the network configuration file.
      Add a line of the following form to ORACLE_HOME/net80/admin/tnsnames.ora: = ( ADDRESS= (PROTOCOL=TCP) (HOST=) (PORT=))
      where is the name of the Reports Multi-Tier Server instance. If you are using a sqlnet.ora file and default_domain is specified, remember to fully qualify the Reports Multi-Tier Server TNS name with the default domain. For example, if the default_domain is world, the repserver.world would be a valid TNS name. is the IP-adress or the hostname of the application server machine, and is the port number to which the Reports Multi-Tier Server is listening (such as, 1949).
    3. Start the Reports Multi-tier Server
      Run the following command to start the reports server manually.
      Rwmts60 -listen name= [minengine= maxengine= initengine= maxidle=]
      You can use Task manager, Processes to ensure that the reports server is running.
      4. Stopping the Reports Multi-tier Server
      If the listener is running, the Task Manager will display a process called RWMTS60.EXE. Select RWMTS60.EXE and click End Process.

      2.2.3 The Reports Server Configuration File
      The configuration file specifies runtime parameters for the Reports Multi-tier Server. When the Reports Multi-tier Server is started, it gets a TNS name from the installation or the command line. The server will listen to this TNS address for RPC calls. The server then looks for a file that is named after the TNS name with .ora as the file extension and that is located in the server subdirectory in ORACLE_HOME\REPORT60\SERVER. If the configuration file is not present, a default one is created. Decide for yourself if this file requires modification. Note that your changes only take effect if you restart the Reports Server. Note that because of its importance, you should restrict access to the configuration file.
      The format of the configuration file is:
      identifier=
      maxconnect=
      sourcedir=
      cachedir=
      tempdir=
      cachesize=
      minengine=
      maxengine=
      initengine=
      maxidle=
      security=
      englife=

      If two servers are running on the same Windows machine, they will have to share the same ORACLE_HOME, REPORTS60_PATH, and REPORTS60_TMP. However, each server listens to a different TNS name and therefore, has a unique configuration file, that can specify different sourcedir, cachedir, and tempdir settings, optionally on different drives. The minengine, maxengine, maxidle, and cachesize settings can be viewed and changed from the queue manager. The queue administrator userid and password can also be changed. The configuration file can be overwritten by the server process when these settings change or when it needs to. Any optional arguments on the command line override the settings in the configuration file.

      Some remarks on the syntax in the configuration file: strings must be quoted if they contain spaces, and do not put spaces around the equal sign. (Follow the rules of an Oracle Reports command file.)

    Friday, November 23, 2007

    User Defined Metrics

    Oracle Enterprise Manager 10g

    You can monitor a OS process using Oracle Enterprise Manager. Here are the steps which I use to monitor the memory usage on a Linux box.


    Steps


    1. write a script eg "getmem.sh"

    2. export em_result = `freegrep Memawk {'print $3'}`
      echo em_result=$em_result

    3. Login to Grid Control > Targets > > User-Defined Metrics

    4. Create an User Defined Metric to run the shell script.

    Note : you need to use "em_result=....." where em_result is the keyword.


    Monday, September 10, 2007

    Inserting Custom Messages in Oracle Alert/Trace files

    DBMS_SYSTEM package that allows us to insert our own customized messages in Alert log and/or trace files. I tried this feature and found it to be quite powerful as regards its usage.

    Routines in DBMS_SYSTEM package
    The following routines can be used to write vital information to Alerts and Trace files.

    • KSDIND:
      Does an indent in the form of inserting colons (:) before the next write is carried out. The indent levels are from 0 to 30. This option could be used to separate the custom messages from the existing oracle messages. For example, I could search the Alert Log for messages starting with 5 colons to identify Application generated messages. The default is 0. This process fails to work in some cases (mentioned below). As a safety, I also add a standard prefix to all messages to identify application related messages.
    • KSDWRT:
      Writes a message to the alert file. The first parameter DEST takes input as 1 (write to trace file), 2 (write to alert log) or 3 (write to both trace and alert log files). The second parameter TST is the actual text message that should go into the file(s).

    Example

    SQL> exec dbms_system.ksdwrt(2, 'testing for alert log writing');

    http://www.dbasupport.com/oracle/ora9i/custom_messages.shtml