Oracle: eval function


create or replace function eval (expr varchar2) return varchar2
as
ret varchar2(4000);
begin
execute immediate 'begin :result := ' || expr || '; end;' using out ret;
return ret;
end;
/

The discussion and examples could be found there

Topics: Oracle, parameter | No Comments »

Oracle: list of the system events


set serveroutput on
declare
event_level number;
begin
dbms_output.enable(20000) ;
for i in 10000..33999 loop
sys.dbms_system.read_ev(i,event_level);
if (event_level > 0) then
dbms_output.put_line('Event '||to_char(i)||' set at level '||
to_char(event_level));
end if;
end loop;
end;

Topics: Oracle, internal | No Comments »

Oracle: list of the running transactions


SELECT a.sid, a.status, a.username, b.xidusn, b.used_urec, b.used_ublk, b.START_TIME
FROM v$session a, v$transaction b
WHERE a.saddr = b.ses_addr
order by START_TIME desc;

Topics: Oracle, transaction | No Comments »

Oracle: sql types

Here is the list of the Oracle SQL types and their internal codes:


SELECT t.typecode,o.name
FROM sys.type$ t, sys.obj$ o
WHERE
BITAND (t.properties, 16) = 16
AND t.toid = o.oid$
ORDER BY t.typecode

Topics: Oracle, internal | No Comments »

Oracle: wait statisics by block class


SELECT
inst_id,
DECODE (indx,
1,'data block',
2,'sort block',
3,'save undo block',
4,'segment header',
5,'save undo header',
6,'free list',
7,'extent map',
8,'1st level bmb',
9,'2nd level bmb',
10,'3rd level bmb',
11,'bitmap block',
12,'bitmap index block',
13,'file header block',
14,'unused',
15,'system undo header',
16,'system undo block',
17,'undo header',
18,'undo block'
), count, time
FROM x$kcbwait
WHERE indx != 0;

Topics: Oracle | No Comments »

Using the clipboard in WSH

How to get the text from the clipboard


set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
textFromClipboard = objIE.document.parentwindow.clipboardData.GetData("text")
objIE.Quit
WScript.Echo textFromClipboard

How to put the text into clipboard


textIntoClipboard = "Some text" & VbCrLf & "Some more text"

Set objIE = WScript.CreateObject("InternetExplorer.Application")
objIE.Navigate "about:blank"
Do Until objIE.ReadyState = 4
WScript.Sleep 100
Loop

objIE.document.ParentWindow.ClipboardData.SetData "text", textIntoClipboard
objIE.Quit

The detailed explanation could be found here.

Topics: Windows scripts, clipboard, copy | No Comments »

Oracle: check the existance of logon/logoff triggers


select decode((count(trigger_name)),0,'LOGON trigger missing', 'Number of logon triggers: ' || count(trigger_name) ) "INFO"
from sys.dba_triggers
where TRIGGERING_EVENT like 'LOGON%' and status='ENABLED' and owner='SYS'
union
select decode((count(trigger_name)),0,'LOGOFF trigger missing','', 'Number of logoff triggers:' || count(trigger_name)) "INFO"
from sys.dba_triggers
where TRIGGERING_EVENT like 'LOGOFF%' and status='ENABLED' and owner='SYS'

The field TRIGGERING_EVENT could have the spaces at the end! Very clever...

Topics: Oracle, login, trigger | No Comments »

Unix shell: workaround for loop problem

It's not possible to get the value of the loop variables in some versions of ksh.

Example:

#!/bin/ksh

num=0
cat $0 | while read line ; do
let num=num+1
done

echo "Number=$num"

This script will return "Number=0" as the result.

Here is the workaround for the problem: You should change the redirection method for the input file.

#!/bin/ksh

l=0
while read line ; do
let l=l+1
done < $0

echo "Number=$l"

The last script will return the correct result: "Number=9"

Topics: Unix Shell | 1 Comment »

JavaScript: edit web page in browser

Here is small bookmarklet, which allows to edit the web page for any site (ok, You could save the results on Your local machine only).


javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

Topics: browser, javascript | No Comments »

Oracle: redo log switches by date

The following script help to find, how often the redo logs were switched.
It calculates the number by date and by hour.

Read the rest of this entry »

Topics: Oracle | No Comments »

« Previous Entries