Wednesday, August 6, 2008

Strange procedure executions, and dbms_lock.sleep(7)

I had executed a number of procedures (approx. 80) from TOAD as follows:



exec <schema_name>.<procedure name>;

...

exec <schema_name>.<procedure name>;

exec <schema_name>.<procedure name>;

Although it says as:


PL/SQL procedure successfully completed.


It does not. Because the tables that must be accumulated by those procedures are empty. For this reason I tried it in SQL*Plus, but it does not work either. After then, I put the executions of the procedures in a PL/SQL block with dbms_lock.sleep(3) as follows:



begin
<schema_name>.<procedure name>;

dbms_lock.sleep(3);

<schema_name>.<procedure name>;

dbms_lock.sleep(3);

...

<schema_name>.<procedure name>;

 Then it worked!


I amcurrently using, Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit on a ia64 hp server rx4640 box.

Monday, May 5, 2008

Removing duplicate rows from a table

Removing duplicate rows from a table has several ways. I prefer below method, because it is easy to implement. For table, schema1.table1 having columns col1, col2, col3 which will be primary key or unique key columns after removing duplicate entries will be accomplished by below SQL:
DELETE FROM schema1.table1 a
WHERE a.ROWID >
ANY (SELECT b.ROWID
FROM schema1.table1 b
WHERE a.col1 = b.col1
AND a.col2 = b.col2
AND a.col3 = b.col3);

Wednesday, January 30, 2008

rename table

Renaming table can be surprising, if you tried both rename and alter table for renaming.

If you issue below statement, you will get following error:
alter table schema1.T1 rename to schema1.T2;

ORA-14047: ALTER TABLE|INDEX RENAME may not be combined with other operations

and if you issue below statement, you will get another surprising error:
rename schema1.T1 to schema1.T2;

ORA-01765: specifying table's owner name is not allowed

The last resort and true one is issueing:
alter table schema1.T1 rename to T2;

Windows (powershell) counterparts of Linux commands

You may find Windows mostly powershell equivalent of frequently used Linux commands here. I will update this post, with newer ones by the ti...