Archive for the ‘Oracle Queries’ Category

Enable Pluggable Database(PDB) Archivelog Mode

August 26th, 2019, posted in Oracle Queries
Share

Enabling archive log mode -12c pluggable database/Container database

Since the Redologs are created at container database level in 12c and not at pluggable database level.
(Enabling archivelog at pluggable database level is not possible). Archiving is done at CDB’s.

You can check archive log mode either by querying v$database or archive-log list :

 

SQL> select name,open_mode,log_mode from v$database;

NAME      OPEN_MODE            LOG_MODE
--------- -------------------- ------------
CDB      READ WRITE           NOARCHIVELOG

(OR)

SQL> archive log list
Database log mode        Archive Mode
Automatic archival        Disabled
Archive destination        USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     11
Next log sequence to archive   13
Current log sequence        13

***************  ***************
To enable the Archive-log mode
***************  ***************immam_dba,dba immam,imam dba,dba imam,oracle clone issue,oracle database,oracle application,oracle clone issue,ora oracle

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.

Total System Global Area  788529152 bytes
Fixed Size      2929352 bytes
Variable Size    541068600 bytes
Database Buffers   239075328 bytes
Redo Buffers      5455872 bytes
Database mounted.

SQL> ALTER DATABASE ARCHIVELOG;
Database altered.

SQL> ALTER DATABASE OPEN;
Database altered.

SQL> select name,open_mode,log_mode from v$database;

NAME      OPEN_MODE            LOG_MODE
--------- -------------------- ------------
CDB      READ WRITE           ARCHIVELOG



SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     413
Next log sequence to archive   415
Current log sequence           415

SQL> show parameter DB_RECOVERY_FILE_DEST

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      /u03/app/oracle/fast_recovery_area
db_recovery_file_dest_size           big integer 27G

 

Share

Without Editing tnsnames.ora file Creating a Database Link in Oracle

June 19th, 2019, posted in Oracle Queries
Share

Developers needed access to some objects from one schema to another using database link. To enable database link he tried to create entry in tnsnames.ora file but had a problem with insufficient permissions. As a developer he has limited privileges on Unix machines so he can’t edit and save tnsnames.ora file.

But there is solution for this little problem.
You can create functional database link without editing tnsnames.ora file.

 

Little Demo Case:

system@TEST11> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production

5 rows selected.


system@TEST11> select * from dba_db_links;

1. no rows selected

Create database link testlink_db2 using full tns entry:

system@TEST11> create database link testlink_db2
connect to system identified by oracle
using
'(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=10.2.10.18)
(PORT=1525))
(CONNECT_DATA=
(SID=test10)))'
/

Database link created.

Now little check and cleanout:

system@TEST11> select * from v$version@testlink_db2;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

5 rows selected.

-- cleanout
system@TEST11> drop database link testlink_db2;

Database link dropped.

 

From documentation:

http://download.oracle.com/docs/html/B13951_01/net.htm#i1153728

http:https://docs.oracle.com/cd/E18283_01/server.112/e17118/statements_5005.htm

server_name = (DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(PORT=port_number)
(HOST=host_name)
)
(CONNECT_DATA=(SERVICE_NAME=service_name)
)
)

where:

server_name is the name of an Oracle server that matches an entry in the RDB directory. An entry in the RDB directory can be added using the ADDRDBDIRE command.

TCP is the TCP protocol used for TCP/IP connections.

port_number is the port number of the Oracle Net listener. This is usually port number 1521.

host_name is the name that defines the system where the target Oracle server resides. This name must be in the local host definition on the AS/400 or in a name server on your network. The host name can also be entered as an IP address, for example, 161.14.10.12.

service_name is the service name of the Oracle server.

Share

Oracle 11g – MEMORY_MAX_TARGET and MEMORY_TARGET

May 22nd, 2019, posted in Oracle Queries
Share

Adjusting the memory_max_target based on available memory. 
This example is Linux x86-64.

If you can afford to set the memory_max_target higher then the memory_target this will give you room to grow the memory_target without restarting the database. 

SQL> show parameters memory_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_target big integer 17920M

SQL> show parameters memory_max_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_max_target big integer 17920M

System has 36GB physical RAM available.

SQL> !grep MemTotal /proc/meminfo
MemTotal: 36912956 kB

Server has now set aside 24GB for use with Oracle. Kernel shared memory parameter.

SQL>!df -h /dev/shm/

Filesystem Size Used Avail Use% Mounted on
tmpfs 24G 11G 14G 44% /dev/shm

Increase memory_max_target to 24GB.

SQL> ALTER SYSTEM SET memory_max_target = 24G SCOPE=SPFILE;
System altered.

Shutdown Oracle.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

Startup Oracle.
SQL> startup
ORACLE instance started.

Total System Global Area 2.5655E+10 bytes
Fixed Size 2213776 bytes
Variable Size 2.0133E+10 bytes
Database Buffers 5368709120 bytes
Redo Buffers 151166976 bytes
Database mounted.
Database opened.

Update your pfile.

SQL> create pfile from spfile;
File created.

Verify the new settings. Max now 24GB and memory target is 17.9GB. We can now increase the memory_target if the need arises without shutting the database down.

SQL> sho parameters memory_max_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_max_target big integer 24G

SQL> sho parameters memory_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_target big integer 17920M
Share

Function To Convert Number To Arabic Number

April 28th, 2019, posted in Oracle Queries
Share
Function To Convert Number To Arabic Number,Arabic Number,English Arabic Number,Oracle Numbers,Oracle DBA,Oracle Apps DBA,Oracle Coding,Oracle Arabic Number Query
FUNCTION convert_to_arabic (p_input IN VARCHAR2, p_msg OUT VARCHAR2)
    RETURN VARCHAR2
    IS
    --

    l_output VARCHAR2(20) DEFAULT NULL;
    CURSOR csr_convert (cp_value VARCHAR2)

    IS

    SELECT TRANSLATE (cp_value,'0123456789',

                         UNISTR ('\0660')
                      || UNISTR ('\0661')
                      || UNISTR ('\0662')
                      || UNISTR ('\0663')
                      || UNISTR ('\0664')
                      || UNISTR ('\0665')
                      || UNISTR ('\0666')
                      || UNISTR ('\0667')
                      || UNISTR ('\0668')
                      || UNISTR ('\0669')
                    ) arabic_numerals
       FROM DUAL;

    BEGIN


    IF p_input IS NOT NULL THEN

      
        OPEN csr_convert(p_input);
        FETCH csr_convert INTO l_output;
        CLOSE csr_convert;

    END IF;

    RETURN l_output;
    EXCEPTION     
    WHEN OTHERS THEN
        IF csr_convert%ISOPEN THEN
            CLOSE csr_convert;

        END IF;
      
       p_msg := SUBSTR(SQLERRM,1,200);
       RETURN l_output;
    END convert_to_arabic;

 

Share

How To Cancel or Restart the Cost Manager

December 18th, 2018, posted in Oracle Queries
Share

Behavior of Cost Manager:

Cost manager is not a typical concurrent manager that it finishes after is costing some transactions.

Cost manager it is rescheduling itself based on the the process interval specified in interface managers form.

Cost Manager should stay in this status : “Pending Scheduled” and will restart itself based on the process interval specified in interface managers form. It calculates the re-launch time as start time + process interval.

 

2 – Run the cmclean.sql script available from MOS Note 134007.1

3 – Restart the Cost Manager

     Inventory> Setup : Transactions> Interface Managers

     Select  ‘Cost Manager’ – choose Tools > Launch Manager

Also review << Note 304313.1>>

  1. Restart the concurrent processes.
  2. Run the below select and update scripts to update the uncosted and/or erred records in the tables indicated.
  3. Relaunch the Cost Manager. Select and Update scripts for paragraph 5. above:

SQL> select count(*) from MTL_MATERIAL_TRANSACTIONS where COSTED_FLAG = ‘E’;

SQL> select count(*) from MTL_MATERIAL_TRANSACTIONS where COSTED_FLAG = ‘N’;

SQL > Update MTL_MATERIAL_TRANSACTIONS set COSTED_FLAG = ‘N’, TRANSACTION_GROUP_ID = NULL where COSTED_FLAG = ‘E’ or COSTED_FLAG = ‘N’;

If there are unprocessed records in MTL_MATERIAL_TRANSACTIONS_TEMP, then, also run the following:

  1. To see if there are records in mtl_material_transactions_temp, run:

SQL> select * from mtl_material_transactions_temp;

  1. If rows are returned from the SQL in a. above, then run:

SQL> Update MTL_MATERIAL_TRANSACTIONS_TEMP Set PROCESS_FLAG = ‘Y’, LOCK_FLAG = ‘N’, TRANSACTION_MODE = 3, ERROR_CODE = NULL Where TRANSACTION_HEADER_ID = ;

(OR)

Resubmit all transactions using this procedure:

  • Shut down the cost manager
  • Make a backup of the table mtl_material_transactions
  • Perform the following update

SQL > update mtl_material_transactions

set costed_flag = ‘N’,

transaction_group_id = NULL,

transaction_set_id = NULL

where costed_flag = ‘E’ or costed_flag = ‘N’ ;

Commit ;

 

 

Update MTL_MATERIAL_TRANSACTIONS set COSTED_FLAG = ‘N’, TRANSACTION_GROUP_ID = NULL where COSTED_FLAG = ‘E’ or COSTED_FLAG = ‘N’;


 

Uncosted/failed transactions can be resubmitted through the application itself.
Costs -> View Transactions -> Material Transactions.
From the menu, Tools Select All: Tools Submit All

Else, use the following script to submit the records in MMT table:

    update mtl_material_transactions MMT
    set MMT.costed_flag = 'N',
    MMT.error_code = NULL,
    MMT.error_explanation = NULL,
    MMT.transaction_group_id = NULL,
    MMT.transaction_set_id = NULL
    where MMT.organization_id = &organization_id
    and MMT.costed_flag in ('N','E')
    and NOT  EXISTS ( SELECT 1
    FROM MTL_TRANSACTION_ACCOUNTS MTA
    WHERE MMT.TRANSACTION_ID = MTA.TRANSACTION_ID);

commit;

  1. Re-start the cost manager.
    Restart the cost manager via Inventory > Setup > Transactions >
    Interface Managers > Tools > Launch Manager. Set up a periodic scheduling interval of every five
    minutes.
    Note — Cost Manager should not be scheduled through request form to run Periodically.
    Cost Manger  should be scheduled through Interface managers only.
Share