Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
composite Unique constraint and null

composite Unique constraint and null

2005-10-18       - By sandeep dubey

Reply:     1     2     3     4     5     6     7     8     9     10  

Amit - I thought of this but this may fail. Here my columns are
varchar2. Values like ('A-X' , 'A') and ('A' , '-XA') will fail.

I figured out another way of doing it. I have synthetic primary key on
the table.

I created index on (col1, nvl(col2, pk_column))

Thanks for all replies.

Regards

Sandeep



On 10/18/05, amit poddar <amit.poddar@(protected)> wrote:
> How about this
>
> SQL> create table test (id1 number(10), id2 number(10));
>
> Table created.
>
> SQL> create unique index test_ind on test (case when id2 is not null
> then to_char(id1)||'-'||to_char(id2) end)
>  2  /
>
> Index created.
>
> SQL> insert into test values (1,null);
>
> 1 row created.
>
> SQL> insert into test values (1,null);
>
> 1 row created.
>
> SQL> insert into test values (1,1);
>
> 1 row created.
>
> SQL> insert into test values (1,1);
> insert into test values (1,1)
> *
> ERROR at line 1:
> ORA-00001 (See ORA-00001.ora-code.com): unique constraint (APPS.TEST_IND) violated
>
>
> Sandeep Dubey wrote:
>
> >Hi,
> >
> >I want to enforce a business rule on two columns such that col1, col2
> >should be unique. However for a given value of col1 nulls should be
> >allowed in col2. I can not implement that using a simple composite
> >unique constraint.
> >
> >Eg.
> >
> >create table foo(id number, name varchar2(10));
> >
> >insert into foo values(1,1);
> >insert into foo values(1,1); -- should not be allowed
> >
> >But following should be allowed
> >
> >insert into foo values(1,null);
> >insert into foo values(1,null); -- should be allowed
> >
> >Any ideas!!
> >
> >Thanks
> >
> >
> >Sandeep
> >Sandeep
> >--
> >http://www.freelists.org/webpage/oracle-l
> >
> >
> >
>
>
--
http://www.freelists.org/webpage/oracle-l