IT Community - Software Programming, Web Development and Technical Support

Applications Info

This is a discussion on Applications Info within the Database Support forums, part of the Web Development category; Hi all, In ORACLE The DBMS_APPLICATION_INFO package allows programs to add information to the V$SESSION and V$SESSION_LONGOPS views ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-24-2007, 08:49 AM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Applications Info

Hi all,

In ORACLE

The DBMS_APPLICATION_INFO package allows programs to add information to the V$SESSION and V$SESSION_LONGOPS views to make tracking of session activities more accurate.

Check it out,

Code:
DECLARE
  v_rindex     PLS_INTEGER;
  v_slno       PLS_INTEGER;
  v_totalwork  NUMBER;
  v_sofar      NUMBER;
  v_obj        PLS_INTEGER;
BEGIN
  v_rindex     := DBMS_APPLICATION_INFO.set_session_longops_nohint;
  v_sofar     := 0;
  v_totalwork := 10;

  WHILE v_sofar < 10 LOOP
    -- Do some work
    DBMS_LOCK.sleep(5);
    v_sofar := v_sofar + 1;
    DBMS_APPLICATION_INFO.set_session_longops(rindex      => v_rindex,
                                              slno        => v_slno,
                                              op_name     => 'Batch Load',
                                              target      => v_obj,
                                              context     => 0,
                                              sofar       => v_sofar,
                                              totalwork   => v_totalwork,
                                              target_desc => 'BATCH_LOAD_TABLE',
                                              units       => 'rows processed');
  END LOOP;
END;
/
PL/SQL procedure successfully completed
__________________
-Murali..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-07-2007, 06:57 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: Applications Info

dbms_application_info package contains several subprogram which are used to setup/retrieve these parameter values. You can obtain list of subprograms of the package using following SQL.

Code:
SQL> desc dbms_Application_info
This will list all the subprograms of the package along with their arguments. Following is the list of all procedures in a package.

• READ_CLIENT_INFO
• SET_CLIENT_INFO
• READ_MODULE
• SET_ACTION
• SET_MODULE
• SET_SESSION_LONGOPS

Let us test this using an example. We will start with creating table and test procedure and we will set the module and action in the procedure.

Code:
CREATE TABLE TEST
(
TEST_ID NUMBER(9),
TEST_DESC VARCHAR(30),
TEST_DATE DATE,
UserID VARCHAR(15)
);

CREATE OR REPLACE PROCEDURE TEST_PROC
AS
BEGIN
/* Registering Module and Action both */
DBMS_APPLICATION_INFO.SET_MODULE
(
module_name => ‘TEST_PROC’,
action_name => ‘Adding records’
);

INSERT INTO TEST(TEST_ID,TEST_DESC,TEST_DATE)
SELECT ROWNUM, TABLE_NAME, SYSDATE
FROM USER_TABLES
WHERE ROWNUM < 10;

DBMS_APPLICATION_INFO.SET_MODULE(null,null);

/* Registering only Action */
DBMS_APPLICATION_INFO.SET_ACTION(action_name => ‘Update Records’);

UPDATE TEST
SET UserID = USER
WHERE TEST_ID < 10;

DBMS_APPLICATION_INFO.SET_ACTION(null);

END;
/
Once procedure is created successfully execute it from SQL*Plus prompt.

Code:
SQL> exec test_proc
In above procedure we are setting value for Module and Action parameters using SET_MODULE and SET_ACTION procedures of the package. We can retrieve these values by either using READ_MODULE procedure or by querying v$sqlarea view. Following is an example to retrieve data back. Query is followed by result.

Code:
SQL> SELECT Action, Fetches, Executions, Rows_PRocessed
2 FROM v$Sqlarea
3 WHERE Module = ‘TEST_PROC’
4 OR Action = ‘Update Records’
5 /
ACTION FETCHES EXECUTIONS ROWS_PROCESSED
————— ———- ———- ————–
Update Records 0 1 4
Adding records 0 1 4

We can retrieve any value we are interested in from v$sqlarea for the module and action parameters. Similarly we can set and retrieve the client_info value using SET_CLIENT_INFO and READ_CLIENT_INFO procedures. It will retrieve value from client_info column of v$session table.

This becomes very helpful during performance tuning. By going against v$sqlarea using module and action, we exactly know what procedure or PL/SQL block needs any attention. It also helps us to track resources like cpu time, elapsed time etc, for a specific module.
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-07-2007, 07:00 AM
Sundaram Sundaram is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Location: chennai
Posts: 117
Sundaram is on a distinguished road
Send a message via MSN to Sundaram Send a message via Yahoo to Sundaram
Talking Re: Applications Info

PL/SQL Packages DBMS_APPLICATION_INFO

Record the name of an executing module (or transaction) in the database for later use with Oracle Trace and the SQL trace facility.

Subprocedures:

SET_MODULE Set the name of the module that is currently
running to a new module.

SET_ACTION Set the name of the current action
within the current module.

READ_MODULE Read the values of the module and
action fields of the current session.

SET_CLIENT_INFO Set the client info field of the session.

READ_CLIENT_INFO Read the value of the client_info field of
the current session.

SET_SESSION_LONGOPS Set a row in the V$SESSION_LONGOP table.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Languages or Applications? Pixel Game Development 6 01-28-2008 06:44 PM
Difference between applications and applets vijayanand Java Programming 0 09-20-2007 11:18 PM
How to write Multithreaded applications using C++? Sabari C and C++ Programming 1 07-31-2007 12:30 AM
How do I test web-related applications? devarajan.v Testing Tools 1 07-26-2007 11:22 PM
Unit tests for .Net applications devarajan.v Software Testing 0 07-16-2007 08:44 AM


All times are GMT -7. The time now is 09:45 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0