Enforcing UNIQUE as well as CHECK constraint
I have a database table in which I want the unique constraint enforced based on following condition:
unique(parent_id, name) and parent_type != 'abcd'
What is the best way to achieve this?.
Thanks.
Unfortunately unique constraints do not allow
declaritive expressions like this. You will need to
use a function-based index. See my reply above.That wont work..
SQL> create unique index your_index
2 on test (
3 case when parent_type <> 'abcd' then parent_id
4 else null end ,
5 case when parent_type <> 'abcd' then name
6 else null end);
Index created.
SQL> insert into test values(1,'xx','abcd');
1 row created.
SQL> insert into test values(1,'xx','abcd');
insert into test values(1,'xx','abcd')
ERROR at line 1:
ORA-00001: unique constraint (SYS.YOUR_INDEX) violated
Similar Messages
-
Unable to Enforce Unique Values, Duplicate Values Exist
I have list in SP 2010, it contains roughly 1000 items. I would like to enforce unique values on the title field. I started by cleaning up the list, ensuring that all items already had a unique value. To help with this, I used the export
to excel action, then highlight duplicates within Excel. So as far as I can tell, there are no duplicates within that list column.
However, when I try to enable the option to Enforce Unique Values, I receive the error that duplicate values exist within the field and must be removed.
Steps I've taken so far to identify / resolve duplicate values:
- Multiple exports to Excel from an unfiltered list view, then using highlight duplicates feature > no duplicates found
- deleted ALL versions of every item from the list (except current), ensured they were completely removed by deleting from both site and site collection recycle bins
- Using the SP Powershell console, grabbed all list items and exported all of the "Title" type fields (Item object Title, LinkTitle, LinkTitleNoMenu, etc) to a csv and ran that through excel duplicate checking as well.
Unless there's some rediculous hidden field value that MS expects anyone capable of attempting to enforce unique values on a list (which is simple enough for anyone to figure out - if it doesn't throw an error), then I've exhausted anything I can think
of that might cause the list to report duplicate values for that field.
While I wait to see if someone else has an idea, I'm also going to see what happens if I wipe the Crawl Index and start it from scratch.
- JonFirst, I create index for a column in list settings, it works fine no matter duplicate value exists or not;
then I set enforce unique values in the field, after click OK, I get duplicate values error message.
With SQL Server profiler, I find the call to proc_CheckIfExistingFieldHasDuplicateValues and the parameters. After reviewing this stored procedure in content database,
I create the following script in SQL Server management studio:
declare @siteid
uniqueidentifier
declare @webid
uniqueidentifier
declare @listid
uniqueidentifier
declare @fieldid
uniqueidentifier
set @siteid='F7C40DC9-E5D3-42D7-BE60-09B94FD67BEF'
set @webid='17F02240-CE04-4487-B961-0482B30DDA84'
set @listid='B349AF8D-7238-419D-B6C4-D88194A57EA7'
set @fieldid='195A78AC-FC52-4212-A72B-D03144DC1E24'
SELECT
* FROM TVF_UserData_List(@ListId)
AS U1 INNER
MERGE JOIN
NameValuePair_Latin1_General_CI_AS
AS NVP1 WITH (INDEX=NameValuePair_Latin1_General_CI_AS_MatchUserData)
ON NVP1.ListId
= @ListId AND NVP1.ItemId
= U1.tp_Id
AND ((NVP1.Level
= 1 AND U1.tp_DraftOwnerId
IS NULL)
OR NVP1.Level
= 2)
AND NOT((DATALENGTH(ISNULL(NVP1.Value,
= 0)) AND U1.tp_Level
= NVP1.Level
AND U1.tp_IsCurrentVersion
= CONVERT(bit, 1)
AND U1.tp_CalculatedVersion
= 0 AND U1.tp_RowOrdinal
= 0 INNER
MERGE JOIN
NameValuePair_Latin1_General_CI_AS
AS NVP2 WITH (INDEX=NameValuePair_Latin1_General_CI_AS_CI)
ON NVP2.SiteId
= @SiteId AND NVP2.ListId
= @ListId AND NVP2.FieldId
= @FieldId AND NVP2.Value
= NVP1.Value
AND NVP2.ItemId <> NVP1.ItemId
CROSS APPLY TVF_UserData_ListItemLevelRow(NVP2.ListId, NVP2.ItemId,
NVP2.Level, 0)
AS U2 WHERE ((NVP2.Level
= 1 AND U2.tp_DraftOwnerId
IS NULL)
OR NVP2.Level
= 2)
AND NOT((DATALENGTH(ISNULL(NVP2.Value,
= 0))
I can find the duplicate list items based on the result returned by the query above.
Note that you need to change the parameter values accordingly, and change the name of NameValuePair_Latin1_General1_CI_AS table based on the last parameter of the
proc_CheckIfExistingFieldHasDuplicateValues stored procedure. You can review the code of this stored procedure by yourself.
Note that direct operation on the content database in production environment is not supported, please do all these in test environment. -
How to create this check constraint
create table emplt
( emplt_pk number,
indvl_pk number,
start_dt date,
end_dt date,
lct_fl char(1),
sup_fl char(1),
br_pk number,
nro_pk number,
default_fl char(1) default 'N' );
INSERT INTO emplt
values(
1001, 101, to_date('01-01-2005', 'MM-DD-YYYY' ), NULL, 'Y','N',123,NULL,NULL );
INSERT INTO emplt
values(
1002, 101, to_date('02-01-2005', 'MM-DD-YYYY' ), NULL, 'Y','N',NULL,0001,NULL );
INSERT INTO emplt
values(
1003, 102, to_date('02-01-2005', 'MM-DD-YYYY' ), NULL, 'Y','N',NULL,0001,NULL );
Is it possible to create a check constraint on this table that enforces that for a given indvl_pk, br_pk and nro_pk
there is only one row with dflt_fl = 'Y'?
Thanks in advance!Say,
SQL> create unique index empli_ui on emplt(case default_fl when 'Y' then indvl_pk end,
2 case default_fl when 'Y' then br_pk end,
3 case default_fl when 'Y' then nro_pk end
4 )
5 /
 
Index created.
 
SQL> insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
2 values(1,2,3,'J');
 
1 row created.
 
SQL> insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
2 values(1,2,3,'J');
 
1 row created.
 
SQL> insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
2 values(3,2,1,'A');
 
1 row created.
 
SQL>
SQL> insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
2 values(3,2,1,'A');
 
1 row created.
 
SQL> insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
2 values(3,2,1,'Y');
 
1 row created.
 
SQL>
SQL> insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
2 values(3,2,1,'Y');
insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.EMPLI_UI) violated
 
SQL> insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
2 values(1,2,3,'Y');
 
1 row created.
 
SQL> insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
2 values(1,2,3,'Y');
insert into emplt (indvl_pk,br_pk,nro_pk,default_fl)
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.EMPLI_UI) violatedRgds. -
Primary key and relevant not null check constraints....
Hi ,
There are some constraints of primary key type and not null check constraints on columns which constitute each primary key....
Should I/Do I have to drop them....????
Do they burden the db at the time of data validation....????
Thanks...
SimHi,
>>There are some constraints of primary key type and not null check constraints on columns which constitute each primary key..
In fact, a column that constitutes a primary key, by default cannot accept NULL values. In this case, defines a PK column as NOT NULL would not be necessary.
LEGATTI@ORACLE10> create table x (id number constraint pk_x primary key);
Table created.
LEGATTI@ORACLE10> desc x
Name Null? Type
ID NOT NULL NUMBER
LEGATTI@ORACLE10> select constraint_name,constraint_type,table_name,search_condition from user_constraints where table_name='X';
CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
PK_X P X
LEGATTI@ORACLE10> create table y (id number not null constraint pk_y primary key);
Table created.
LEGATTI@ORACLE10> desc y
Name Null? Type
ID NOT NULL NUMBER
LEGATTI@ORACLE10> select constraint_name,constraint_type,table_name,search_condition from user_constraints where table_name='Y';
CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
SYS_C006327381 C Y "ID" IS NOT NULL
PK_Y P Y
LEGATTI@ORACLE10> alter table y drop constraint SYS_C006327381;
Table altered.
LEGATTI@ORACLE10> desc y
Name Null? Type
ID NOT NULL NUMBER
LEGATTI@ORACLE10> insert into y values (NULL);
insert into y values (NULL)
ERROR at line 1:
ORA-01400: cannot insert NULL into ("LEGATTI"."Y"."ID")
LEGATTI@ORACLE10> insert into y values (1);
1 row created.
LEGATTI@ORACLE10> insert into y values (1);
insert into y values (1)
ERROR at line 1:
ORA-00001: unique constraint (LEGATTI.PK_Y) violated
>>Should I/Do I have to drop them....????
I don't see any problem, otherwise, drop the NOT NULL constraint is the same with alter the column table like below:
LEGATTI@ORACLE10> create table z (id number not null constraint pk_z primary key);
Table created.
LEGATTI@ORACLE10> select constraint_name,constraint_type,table_name,search_condition from user_constraints where table_name='Z';
CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
SYS_C006328420 C Z "ID" IS NOT NULL
PK_Z P Z
LEGATTI@ORACLE10> desc z
Name Null? Type
ID NOT NULL NUMBER
LEGATTI@ORACLE10> alter table z modify id NULL;
Table altered.
LEGATTI@ORACLE10> select constraint_name,constraint_type,table_name,search_condition from user_constraints where table_name='Z';
CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
PK_Z P Z
LEGATTI@ORACLE10> desc z
Name Null? Type
ID NOT NULL NUMBERCheers
Legatti -
The above error occurs when I place unique constraint on a column in a custom list. This error only occurs because the custom list has been configured to only allow creaters to view and edit their own list items.
I just can't see why that should prevent SP from placing a unique value constraint though.
One easy workaround would be to place the unique constraint on the SQL Server table that represents this list. However, in a hosted environment, it is not always possible to gain access to the backend server. What is more, I am uncomfortable with this
approach as it may break other parts of SP 2010.
Is there any other approach?Hi,
If SharePoint were to enforce uniqueness on a column in a list where users are only allowed to see and edit list items that have created, then you could have a scenario where -
a. user1 tries to add a new item to the list which violates the uniqueness constraint
b. SharePoint reports an error
c. user1 gets to know that there is another item containing the same value in this list
d. this violates the security settings that you configured (each user should be allowed to only see the items that they have created). Now if you change the permissions settings to allow users to SEE all items, but only
edit items that they have created, this error disappears (obviously).
Now getting to the workaround you mentioned (creating a unique constraint on the SQL Server table). This is not going to be possible for numerous reasons -
a. Modifying (or for that matter, even performing SELECT operations on) the SQL Server tables is an unsupported operation and it will definetely break other things in SharePoint, not
to mention that you will lose all support options from Microsoft. However if you don't care about this, then it will still not be technically possible because...
1. SharePoint does not create a new SQL Server table for every list/library.
2. If you did get around to enforcing a unique constraint in the one single table that SharePoint uses for all lists, then you will be enforcing this constraint on each and every list in all the sites and in all the site
collections that are assigned to that content database.
Please "Mark as Answer" if a post has answered your question or "Vote as Helpful" if it was helpful in some way. Here's
why -
All I could come up with is this:
check (column_name like '____');
But That doesn't enforce the first character to be a letter and the other three to be numbers.Hi,
"PS: Why the f***you have so many subforums here?"
Because it is much easier to seperate and let experts answer to specific details of SQL Server. SQL Server is not a small product as many people think ;-)
Here is the solution:
CREATe table SampleA (A INT, B VARCHAR(MAX) CHECK (B LIKE '[A-Z][0-9][0-9][0-9]'))
INSERT INTO SampleA VALUES (1,'0000')
Msg 547, Level 16, State 0, Line 2
The INSERT statement conflicted with the CHECK constraint "CK__SampleA__B__38B96646". The conflict occurred in database "master", table "dbo.SampleA", column 'B'.
The statement has been terminated.
INSERT INTO SampleA VALUES (1,'L000')
--(1 row(s) affected)
INSERT INTO SampleA VALUES (1,'L0001')
Msg 547, Level 16, State 0, Line 2
The INSERT statement conflicted with the CHECK constraint "CK__SampleA__B__38B96646". The conflict occurred in database "master", table "dbo.SampleA", column 'B'.
The statement has been terminated.
-Jens
Jens K. Suessmeyer http://blogs.msdn.com/Jenss -
Using a function in a check constraint
Hi,
I created a domain table(id, code, domain_code, description) and foreign keys to this table. To ensure that a valid domain is put in the column I created a function that returns a boolean and has two parameters (id and domain_code). It returns true if the id and domain belong together.
I want to know if it is possible to create a check constraint which validates the data in the refering table with the data in the domain table.
Does anyone know if this is possible? Or do I have to use a db-trigger?
Regards,
RomanoIt still sounds like all you need is a foreign key constraint. Please see the example below, based on your revised criteria.
scott@ORA92> create table domain
2 (id number,
3 code number,
4 domain_code number,
5 constraint domain_pk primary key (id),
6 constraint domain_uk unique (code, domain_code))
7 /
Table created.
scott@ORA92> insert into domain values (1, 10, 2)
2 /
1 row created.
scott@ORA92> create table domain_values_table
2 (id number,
3 domain_code number,
4 constraint domain_values_table_uk unique (id, domain_code))
5 /
Table created.
scott@ORA92> insert into domain_values_table values (1, 2)
2 /
1 row created.
scott@ORA92> commit
2 /
Commit complete.
scott@ORA92> create table referring
2 (id number,
3 domain_code number,
4 status number,
5 constraint referring_fk foreign key (status)
6 references domain (id),
7 constraint referring_fk2 foreign key (id, domain_code)
8 references domain_values_table (id, domain_code))
9 /
Table created.
scott@ORA92> insert into referring values (1, 2, null)
2 /
1 row created.
scott@ORA92> insert into referring values (3, 4, null)
2 /
insert into referring values (3, 4, null)
ERROR at line 1:
ORA-02291: integrity constraint (SCOTT.REFERRING_FK2) violated - parent key not found -
Max number of CHECK constraints on a column in Oracle9i?
What is the maximum number of CHECK constraints that can be defined on a column when creating a table in Oracle 9i database?
Also could some one tell me what are the limitations on CHECK constraints?Well, in Oracle 8.1.7 documentaion it is stated that number of constraints is also unlimited. I haven't such a database now to test but here is a little test for Oracle 9iR2
SQL> drop table test;
Table dropped.
SQL> create table test (a number
2 check (a > 1)
3 check (a > 2)
4 check (a > 3)
5 check (a > 4)
6 check (a > 5)
7 check (a > 6)
8 check (a > 7)
9 check (a > 8)
10 check (a > 9)
11 check (a > 10)
12 check (a > 11)
13 check (a > 12)
14 check (a > 13)
15 check (a > 14)
16 check (a > 15)
17 check (a > 16)
18 check (a > 17)
19 check (a > 18)
20 check (a > 19)
21 check (a > 20)
22 )
23 /
Table created. -
Creating a check constraint with a join
Hi,
is it possible to create a check constraint under the data models using a join on lookup table?
I would like to filter out tuples in the target table involving conditions from an another table.
RegardsNumbers has checkable boxes but they don't work once exported to PDF.
And there is iBooks Author as well which can create ePubs.
If it is just for yourself on your Mac I highly recommend Qu-s.
Peter -
How to enforce uniqueness to my database table
Hello
One of my database will be updated based on two columns c1 and c2.
Previous i created an index on these two columns. But forgot to enforce uniqueness. Now my table has some duplicate data.Means columns c1 and c2 contained same value for more than one record. Now i deleted all the duplicate data. And i also want to allow any duplicate data into my table in future. While i was creating an unique index on these two columns it is not allowing and prompting errors. Can someone guide me how to enforce uniqueness for my tableAnd i also want to allow any
duplicate data into my table in future.
Can someone guide
me how to enforce uniqueness for my tableSo you want to enforce uniqueness or not?
Look at alter table add constraint clause in sql reference manual.
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/clauses002.htm#g1053592
In case you have duplicate values you can
"ENABLE NOVALIDATE ensures that all new DML operations on the constrained data comply with the constraint. This clause does not ensure that existing data in the table complies with the constraint and therefore does not require a table lock."
Gints Plivna
http://www.gplivna.eu -
Hi I've got a problem and was wondering if anyone could shed some light on the problem.
Recently we started using designer 10g. When I generate a table using "generate database from server model" all the columns which are defined by a domain and have a check constraint, due to the specified values in the domain, are no longer part of the create statement of the table. Designer seems to put them in the constraint file as part of an alter table along with a weird name.
Is it possible, as in designer 2000, to make the check constraint part of the create statement in 10g and making it a sys constraint ? And how ?
I've been looking around but can't seem to find the solution (or the problem causing it).
Thnx for any help on the subject.Well we are planning to migrate our old designer (designer 2000) to the 10g version. One of the things that was possible in designer 2000 was defining a domain for a column and when you generated the SQL DDL it would generate a check constraint but as part of the create table statement.
eg:
type VARCHAR2(2) NOT NULL CHECK ( opvolging_type IN 'VC' , 'NL' , 'WW' , 'LB' ) ),
The check constraint would then be defined as a check constraint with name SYS...
Apparently some ppl at my company do not want to use explicit names for check constraints and they were wondering if it was at all possible to make them part of the create table script again. -
Difference between a check constraint and a trigger
Hi, I wanted to know the exact usage of a trigger within a database.
Suppose I want to have a restriction on an insert into a Employees table that provides a check on the time that a particular employee signs in,
I could do that with the help of a before insert trigger that prevents certain values fgrom being inserted.
But cant I do the same thing with the help of a simple check constraint?
Where exactly does the distincton lie between a constraint and a trigger?
Edited by: user8680847 on Sep 24, 2009 11:55 PMA trigger is fired due to DML operations(Insert,Update,Delete) ot on Database events like startup, shutdown etc. You can write your piece of logic into the trigger to do the necessary operations when the event occurs.
For example, if you want you track the changes made to +(emp)+ table data you can place a before update trigger on the table and place your code inside the triiger to insert the old values into an audit table +(emp_audit)+. Everytime an update is made on the table data the trigger will get fired and will insert the old values of the record into the audit table and the new value in the +(emp)+ table.
A constraint is completely different from a trigger. A constraint is like a validation on the data to be inserted. There are different types of constraints.
I will give you a simple example.
You place the not null constraint on the dept column of the emp table. While you try to insert a new record into the emp table the the dept value cannot be null. Oracle will validate the data you are trying to insert into the table with the constraint and will give you an error if the validation fails.
There are other constraints like:
unique key
foreign key
etc.
Precisely a constraint does not handle a database event as a trigger rather it validates the column data.
Edited by: Priyabrat on Sep 25, 2009 12:27 AM -
DB Diagram: Modality Difference between NOT NULL and check constraint
Hi,
I am using jdev 11g (11.1.1.10) I am trying to create a db diagram from two tables. I have a FK that is NOT NULL (defined on the column). When i try to display these two tables modality, it does not show up in the diagram. I noticed that there are two ways NOT null can be defined on a table (right click on the db object to edit it; a) under column definitions there is a check box for not null, b) there is a check constraint that one can add to do not null.
I am confused and was wondering whether I must I have check constraints on the database in order to display modality (optional versus mandatory). Logically speaking it does not make any sense though.Hi Susan,
Thanks for your email. I understand that in order to show modality under
UML notation, one must define a COLUMN being NOT NULL instead of defining a check constraint.
I still do not understand how modality (optional versus mandatory) is shown in ERD notation in JDev. I tried flipping ERD/UML notations and made sure icons for tables were showing, but no MODALITY is shown in ERD notation ( an '0" icon or a "|" icon for optional and mandatory). Is it the solid line versus dotted line in the ERD diagram? I am confused because generally under Crawfoot ERD notation '0" icon or a "|" icon is shown for modality.
Modality gets picked up in jdev diagram when COLUMN not null is specified and UML notation is used
ALTER TABLE DETAILAJ MODIFY EMPID not null;
Modality does not get picked up in jdev db diagram when check constraint is specified and UML notation is used
ALTER TABLE DETAILAJ
ADD CONSTRAINT CK_NN_DETAILAJ__EMPID CHECK(EMPID IS NOT NULL) ;
Another question i have related to the matter mentioned above is as follows. Since I want to see modality in db diagram, it follows that I must define a column as not null instead of a check constraint. I must also use NO VALIDATE on NOT NULL column because i have prior data that does not meet the new restriction. I noticed that if i use the following syntax to define a NOT NULL column, two things happen.
a) A constraint is defined as not null automatically and a system generated name is given to the constraint.
b) DB diagram in Jdev does not show the modality.
My question is whether there is a way to see modality in this case.
alter table DETAILAJ
MODIFY EMPID NOT NULL ENABLE NOVALIDATE ;
Edited by: user11219846 on Nov 19, 2009 11:07 AM -
Peculiar problem in oracle 10g on AIX 5.3.0 With Check constraints
Hi Every One,
I am facing peculiar problem in oracle 10.2.0.1.0,AIX 5.3.0. I created table with check constraints like this
create table test1 (name nvarchar2(1),check (name in('Y','N')));
SQL> create table test1 (name nvarchar2(1),check (name in('Y','N')));
Table created.
SQL> insert into test1 values ('Y');
1 row created.
SQL> COMMIT;
SQL> select from test1 where name = 'Y';* Why this statement is n't working
no rows selected
SQL> select * from test1;
N
Y
ANOTHER INTERSTING ONE IS
SQL> select * from test1 where name in('Y'); Why this statement is n't working
no rows selected
SQL> select * from test1 where name in('Y','Y'); it's working
N
Y
SQL> select * from test1 where name in('','Y'); it's working
N
Y
SQL> select * from test1 where name in('7','Y'); it's working
N
Y
Like
SQL> select * from test1 where name like 'Y'; it's not working
no rows selected
I created a table without check constraints
SQL> create table test2 (name nvarchar2(1));
Table created.
SQL> insert into test2 values ('Y');
1 row created.
SQL> select * from test2;
N
Y
SQL> select * from test2 where name ='Y'; it's working
N
Y
SQL> select * from test2 where name like 'Y'; it's working
N
Y
Database Details
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CHARACTERSET WE8MSWIN1252
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
PARAMETER VALUE
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_RDBMS_VERSION 10.2.0.1.0
Why it's happening. Whehter check constraint is valid or not in Equallity operator and like and in .
Whereever we using single character column with check constraint,it's working with Equality operator and like and in.
IT'S WORKING FINE WITHOUT CHECK CONSTRAINTS.WE HAVE TWO AIX MACHINES WITH ORACLE10G.THE SAME PROBLEM OCCURING IN TWO MACHINES
PLEASE HELP ME .
THANK YOU,
WITH REGARDS,
N.VINODHh
Edited by: user3266490 on Dec 3, 2008 2:30 AM -
How to use external functions in check constraints
I created my own function:
create or replace
function if_num_get_num (inval in varchar2)
return number
is
dummy number;
Begin
dummy := to_number(inval);
return dummy;
exception
when others then return null;
end;Can I use it in table check constraint?
When I use standard function INSTR everything is OK.
ALTER TABLE A_S
ADD CONSTRAINT A_S_CHK1 CHECK
(INSTR(NAZWA_ZA, ':') > 0)
ENABLE;but when I try to create it with my function:
ALTER TABLE A_S
ADD CONSTRAINT A_S_CHK1 CHECK
(IF_NUM_GET_NUM(INSTR(NAZWA_ZA, ':')) > 0)
ENABLE;I get a message "Invalid column IF_NUM_GET_NUM"Read the restrictions.
>
Restrictions on CHECK Constraints
A CHECK constraint requires that a condition be true or unknown for every row of the table. If a statement causes the condition to evaluate to false, then the statement is rolled back. The condition of a CHECK constraint has these limitations:
* The condition must be a boolean expression that can be evaluated using the values in the row being inserted or updated.
* The condition cannot contain subqueries or sequences.
* The condition cannot include the SYSDATE, UID, USER, or USERENV SQL functions.
* The condition cannot contain the pseudocolumns LEVEL or ROWNUM.
* The condition cannot contain the PRIOR operator.
** The condition cannot contain a user-defined function.*
>
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17125/adfns_constraints.htm#ADFNS282
Maybe you are looking for
-
How to populate a poplist through a record group?
Dear People, I use forms along with 10g.I have create a record group RG9 with query SELECT DNAME FROM DEPT;.now how to populate it to a list item?.i tried it using a the following code in When_new_form_instance trigger.The code is as follows, declare
-
Hi, Looking here suggestion . My requirment is to show profit center in report. for that i created 1 muliprovider. now i am getting G/L Account Data like "#/100010", which should like "100010" only. and profit center like "#/DP01" which should like
-
Default text in description for a task
Morning, I was wondering if it is possible within a task or appointment if a value is chosen from a pick list it would then load default text in a description field. For example i am hoping for users to choose a value then default text would appear i
-
Question about installing FCP Studio2
As per the advice on the boards, I am going to do a clean install of my OS and then reinstall FCP Studio1 and then my new upgrade to FCP Studio2. My question: what is the best workflow to accomplish this. my current OS is 10.5.7 and it looks like acc
-
Updating to iOS 5 but gets stuck on back up? What can I do to get iOS 5? :(
Hi, I'm trying to update my iPhone to iOS 5 but it gets stuck on back up. Why? I get a tiny bit of green bar and then it gets stuck. What can I do to get the update for my phone? Thanks