FRM-40506: Oracle error: unable to check for record uniqueness

April 13th, 2007

I run into this problemevery now and then and I keep forgetting how to solve it. Here it is:

If you have a block based on a table, and the primary key is automatically filled with a database trigger, do not set “Enforce primary key” to YES for the block.

creating materialized views on view from a remote database

April 11th, 2007

It’s been a while but here is a pretty bug, which occurs even in the newest Oracle Database versions:

I tried to create six materialized views on views in a remote database through a database link. (for whomever is interested: the remote database used the CDM Ruleframe with VAPIs so I was asked to select from the views instead of the tables).

Four of the six compiled nicely. The other two gave me this error (on 10.1.0.2 and 10.2.0.1):

ORA-00942: table or view does not exist
ORA-06512: at “SYS.DBMS_SNAPSHOT_UTL”, line 960
ORA-06512: at line 1

and when I tried on another database (10.2.0.3) the error turned out to be an ora-00600!

I solved this by making the materialized view complex, i.e. just putting select * from () around it.

The bug on metalink for this is here

Windows uptime

January 17th, 2007

I found this, might come in handy to others:

http://www.petefreitag.com/item/86.cfm

Javascript issues

July 17th, 2006

I have a special situation in which I have about 8 webpages, which all have the same button to open a new window.

My problem is that when I press the button on page 1 (which opens a new window), browse to page 2 and press the same button, the url in the popupwindow changed but the data is *not*. In the original situation the url was the same and server vars had been changed, so I figured the browser simply did not make a new request, but even after changing a dummy variable in the url the data does not refresh until I press F5. I tried delaying setting the new url, to make sure the server was ready for the request but this didn’t help either. As a last resort I wrote this code, which is ugly as hell but fast enough not to be noticed:

l_Window = window.open(pURL,pName, pParameters);
l_Window.close();
l_Window = window.open(pURL,pName, pParameters);

Now I get fresh data everytime I click the link….
If anyone has a better solution please tell me because I am not very happy with this one…

Export result from query to Excel

June 23rd, 2006

I found a good post on the Oracle Forums that can export the result of any query to a csv file. It can be found at http://forums.oracle.com/forums/thread.jspa?messageID=1160117

Autoextend tablespaces

June 23rd, 2006

Today I learned that even if you let tablespaces autoextend themselves, you also need to think about how much the maximum space is they are allowed to extend themselves to.

My customer complained about not being able to see their uploaded pdf files and all the tablespaces had autoextend on so I was quite confused, until I saw that one of them had reached its maximum size……

Apache 2.0 and mod_plsql

April 26th, 2006

do not go together (yet).

Today I needed a standalone Apache and what seemed logical to me is that I installed it from the Application Server Companion CD (10.1.3). It never occurred to me that the Apache you get with your iAS is not the same you get when you install it from the Companion CD. The companion CD will give you Apache 2.0, which according to http://www.oracle.com/technology/products/ias/ohs/htdocs/ohs-1013-faq.pdf does not support mod_plsql, even thought the startpage says this at the bottom:

mod_plsql users should refer to the “Creating a DAD” section in the Oracle HTTP Server Standalone Administrator’s Guide Based On Apache 2.0.

(I haven’t been able to locate this guide yet)

Instead, there is an advanced option on the iAS installation CD, which lets you select a standalone webserver, which is indeed Apache 1.3.

Cloning your database

April 3rd, 2006

Today I wanted to run a copy of the database on my laptop on a machine at home, and this is what I did:

  • I logged onto the database as SYSDBA
  • I backed up my control files using ALTER DATABASE BACKUP CONTROLFILE TO TRACE RESETLOGS;

This resulted in the following script:

CREATE CONTROLFILE REUSE DATABASE "OLD_SID" RESETLOGS ARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 32
MAXINSTANCES 16
MAXLOGHISTORY 1815
LOGFILE
GROUP 1 'E:ORACLEORADATAOLD_SIDREDO03.LOG'  SIZE 1M,
GROUP 2 'E:ORACLEORADATAOLD_SIDREDO02.LOG'  SIZE 1M,
GROUP 3 'E:ORACLEORADATAOLD_SIDREDO01.LOG'  SIZE 1M
DATAFILE
'E:ORACLEORADATAOLD_SIDSYSTEM01.DBF',
'E:ORACLEORADATAOLD_SIDRBS01.DBF',
'E:ORACLEORADATAOLD_SIDTEMP01.DBF',
'E:ORACLEORADATAOLD_SIDTOOLS01.DBF',
'E:ORACLEORADATAOLD_SIDINDX01.DBF',
'E:ORACLEORADATAOLD_SIDDR01.DBF',
'E:ORACLEORADATAOLD_SIDWORK01.DBF',
'E:ORACLEORADATAOLD_SIDTEMP02.DBF'
CHARACTER SET WE8ISO8859P1;
  • I changed REUSE to SET and added the extra datafiles that the database I want to copy has.
  • I shutdown the database
  • I copied the datafiles from the old database to the new
  • I started the database using STARTUP NOMOUNT
  • I ran the create controlefile statement
  • I tried to open the database using ALTER DATABASE OPEN RESETLOGS; This gave me this error:

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: ‘C:ORACLEPRODUCT10.1.0ORADATAORCLSYSTEM01.DBF’

  • I solved this by recovering the database using one of the redologs :

SQL> recover database using backup controlfile;

  • and as the redolog I entered

C:oracleproduct10.1.0oradataorclREDO01.log
Log applied.
Media recovery complete.

  • I then shut the database down and started it up again:
    alter database open resetlogs;

This worked

(EDIT)

I discovered my temp tablespace didn’t have any files, so I added one with this command:

ALTER TABLESPACE TEMP ADD TEMPFILE ‘C:ORACLEPRODUCT10.1.0ORADATAORCLTEMP01.DBF’
SIZE 20971520  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

Existing state of … has been invalidated

March 27th, 2006

I get this error every now and then when I push a button in a Form to run a report on a view that bases its where clause on variables in a package (think of usernames, dates etc), even though in TOAD all my views and packages are valid, and running the report from the builder works just fine too.
Usually trying again compiles the package and makes it work, but not this time. After trying all sort of things, restarting the reports server did the trick. No idea why though, the reports server makes a new connection for every report, so it’s not pooling that causes this.

Put .; in front of your classpath stupid

March 23rd, 2006

I need to remember this……