{"id":118,"date":"2009-08-28T12:05:00","date_gmt":"2009-08-28T15:05:00","guid":{"rendered":"http:\/\/www.soudba.com.br\/?p=118"},"modified":"2009-08-28T12:05:00","modified_gmt":"2009-08-28T15:05:00","slug":"dbms_application_info","status":"publish","type":"post","link":"https:\/\/www.soudba.com.br\/?p=118","title":{"rendered":"DBMS_APPLICATION_INFO"},"content":{"rendered":"<p>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.<\/p>\n<p>Once the program initiates it registers itself using the SET_MODULE procedure. In doing so it also sets the initial action:<\/p>\n<p>    BEGIN<br \/>      DBMS_APPLICATION_INFO.set_module(module_name =&gt; &#8216;add_order&#8217;,<br \/>                                       action_name =&gt; &#8216;insert into orders&#8217;);<\/p>\n<p>      &#8212; Do insert into ORDERS table.<br \/>    END;<br \/>    \/<\/p>\n<p>Subsequent processing can use the SET_ACTION procedure to make sure the action description stays relevant:<br \/>Assuming that the &#8220;fireid&#8221; user is to be audtited:<\/p>\n<p>    BEGIN<br \/>      DBMS_APPLICATION_INFO.set_action(action_name =&gt; &#8216;insert into order_lines&#8217;);<\/p>\n<p>      &#8212; Do insert into ORDER_LINES table.<br \/>    END;<br \/>    \/<\/p>\n<p>The SET_CLIENT_INFO procedure can be used if any additional information is needed:<\/p>\n<p>    BEGIN<br \/>      DBMS_APPLICATION_INFO.set_action(action_name =&gt; &#8216;insert into orders&#8217;);<br \/>      DBMS_APPLICATION_INFO.set_client_info(client_info =&gt; &#8216;Issued by Web Client&#8217;);<\/p>\n<p>      &#8212; Do insert into ORDERS table.<br \/>    END;<br \/>    \/<\/p>\n<p>The information set by these procedures can be read from the V$SESSION view as follows:<\/p>\n<p>    SET LINESIZE 500<br \/>    SELECT sid,<br \/>           serial#,<br \/>           username,<br \/>           osuser,<br \/>           module,<br \/>           action,<br \/>           client_info<br \/>    FROM   v$session;<\/p>\n<p>The SET_SESSION_LONGOPS procedure can be used to show the progress of long operations by inserting rows in the V$SESSION_LONGOPS view:<\/p>\n<p>    DECLARE<br \/>      v_rindex     PLS_INTEGER;<br \/>      v_slno       PLS_INTEGER;<br \/>      v_totalwork  NUMBER;<br \/>      v_sofar      NUMBER;<br \/>      v_obj        PLS_INTEGER;<br \/>    BEGIN<br \/>      v_rindex     := DBMS_APPLICATION_INFO.set_session_longops_nohint;<br \/>      v_sofar     := 0;<br \/>      v_totalwork := 10;<\/p>\n<p>      WHILE v_sofar &lt; 10 LOOP<br \/>        &#8212; Do some work<br \/>        DBMS_LOCK.sleep(5);<\/p>\n<p>        v_sofar := v_sofar + 1;<br \/>        DBMS_APPLICATION_INFO.set_session_longops(rindex      =&gt; v_rindex, <br \/>                                                  slno        =&gt; v_slno,<br \/>                                                  op_name     =&gt; &#8216;Batch Load&#8217;, <br \/>                                                  target      =&gt; v_obj, <br \/>                                                  context     =&gt; 0, <br \/>                                                  sofar       =&gt; v_sofar, <br \/>                                                  totalwork   =&gt; v_totalwork, <br \/>                                                  target_desc =&gt; &#8216;BATCH_LOAD_TABLE&#8217;, <br \/>                                                  units       =&gt; &#8216;rows processed&#8217;);<br \/>      END LOOP;<br \/>    END;<br \/>    \/<\/p>\n<p>The information in the V$SESSION_LONGOPS view can be queried using:<\/p>\n<p>    SELECT  opname,<br \/>            target_desc,<br \/>            sofar,<br \/>            totalwork,<br \/>            units<br \/>    FROM    v$session_longops;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. Once the program initiates it registers itself using the SET_MODULE procedure. In doing so it also sets the &hellip; <a href=\"https:\/\/www.soudba.com.br\/?p=118\">Continue lendo <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-dbms_application_info"],"_links":{"self":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":0,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}