Thursday, November 29, 2007

How to capture the IP Address of the Oracle client making the data request

The key player is SYS_CONTEXT as in:

Select SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual


Here's a trigger that captures the ip addresses of clients deleting rows from a table:

CREATE OR REPLACE TRIGGER "MYSCHEMA"."SESSIONWATCHER" BEFORE

DELETE ON "MYSCHEMA"."CURRENTUSERSESSION" DECLARE

SInfo MYSCHEMA.SESSIONHISTORY.INFO%TYPE;
BEGIN
SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') INTO SInfo FROM dual;
INSERT INTO MYSCHEMA.SESSIONHISTORY VALUES (SInfo);
END SessionWatcher;

Wednesday, February 21, 2007

NCover and NCover Console

For a free code coverage solution NCover is pretty darn nifty and NCover Explorer Rocks on top of it:

NCover
NCover Explorer

Tuesday, February 06, 2007

Unable to load DLL 'OraOps10.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

That pesky problem has reared its ugly head again!
I remembered that its a permissions problem but forgot the wrinkle where you have to REMOVE THE PERMISSION AND THEN GIVE IT BACK.

See bold type below:

Solution Description:
Follow these steps to restore default access to Read and Execute access for Windows authenticated users:

1. Log on to Windows with administrator privileges.
2. Launch Windows Explorer from the Start Menu.
3. Navigate to the ORACLE_HOME directory and right click on the ORACLE_HOME folder icon.
4. Select the "Properties" option from the drop down list. A "Properties" window should appear.
5. Click on the "Security" tab on the "Properties" window.
6. Click on Autheticated Users in the "Name" list.
7. Uncheck the "Read and Execute" box in the "Permissions" list. This box will be under the "Allow" column.
8. Check the "Read and Execute" box. This is the box you just unchecked.

9. Click the "Apply" button.
10. Click the "OK" button.

Why I audah ......

Friday, January 26, 2007

Quiet BackgroundWorker Exceptions

The System.ComponentModel.BackgroundWorker catches all of its exceptions as well as those emanating from the delegate that you wired up as a DoWorkEventHandler. If you don't check the e.Error property of the RunWorkerCompletedEventArgs passed to the delegate you wired
up as a RunWorkerCompletedEventHandler then you've set yourself up with a real trooper of a BackgroundWorker. All hell could break loose during its processing but it won't make a peep!

Spinning off threads via:
 
Thread th = new Thread(new ThreadStart(myThreadStartMethod));
th.Start();

Is not nearly so tolerant.


private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// IF YOU DON'T CHECK e.Error != null THEN BAD THINGS CAN
// HAPPEN IN YOUR WORKER BUT NO ONE WILL EVER KNOW!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if(e.Error != null) {
MessageBox.Show(e.Error.Message);
}
else if(e.Cancelled) {
// Next, handle the case where the user canceled
// the operation.
// Note that due to a race condition in
// the DoWork event handler, the Cancelled
// flag may not have been set, even though
// CancelAsync was called.
resultLabel.Text = "Canceled";
}
else {
// Finally, handle the case where the operation
// succeeded.
resultLabel.Text = e.Result.ToString();
}

// Enable the UpDown control.
this.numericUpDown1.Enabled = true;

// Enable the Start button.
startAsyncButton.Enabled = true;

// Disable the Cancel button.
cancelAsyncButton.Enabled = false;
}

Friday, January 12, 2007

Checking Status of Currently Open Cursors in ORACLE

Pesky too many open cursors error from ORACLE can be investigated with the help
of the following code:

--total cursors open, by username & machine
select sum(a.value) total_cur, avg(a.value) avg_cur, max(a.value) max_cur,
s.username, s.machine
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current'
and s.machine in ('MY Machine', 'His Machine', 'Her Machine')
group by s.username, s.machine
order by 1 desc;

Visit this nice link for more info

C# Sucks!

JK!! Seriously, though, somewhere around C#-3 we should have inculcated ourselves with the question: "Does 'CAN' == 'SHOULD...