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,
Romano

It 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

Similar Messages

  • 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.VINODH

    h
    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

  • Business Functions of type Validation/Constraint not used when defined in the Glossary

    Hi,
    the problem is the following: in the Glossary, we have some Business Rules defined. They are of type Validation or Constraint and shall be used to validate the data in the system. These Business Rules are used in Domains in a CDM model.
    From that CDM model we are generating a PDM model (for HANA, but it's not working for any of the databases available for selection). Now: I would expect, as this has been defined in the CDM, the Business Rules replicated in the PDM model and used as constraints.
    This is unfortunately working only for Business Functions, which are directly defined in the CDM model, not for those ones, defined in the Glossary and reused in the CDM model.
    Working case:
    - define Business Rule in CDM
    - define Domain in CDM and assign Business Rule
    - assign the domain to a attribute
    - generate PDM from the CDM model
    - the Business Rule is replicated in the PDM model, the check constraint for the table is generated correctly
    NOT working case:
    - define Business Rule in Glossary
    - define Domain in CDM and assign the Business Rule from the Glossary
    - assign the domain to a attribute
    - generate PDM from the CDM model
    - the Business Rule is NOT replicated in the PDM model, the check constraint for the table is MISSING
    Do you think it's a bug, or am I doing something wrong?
    P.S.
    We are on 16.5 SP05
    Thanks,
    Rafal

    Looks like a bug to me; I would expect the source of the rule to be irrelevant, assuming the PDM has access to the relevant metadata at the time of generation. Perhaps Glossary shortcuts don't have access to all the metadata?

  • Using a CHECK constraint to check for minimum age

    Is it possible to use a check constraint in a table to check whether a person meets a minimum age? For example, if a person is registering as a member, I want to make sure the person is at least 18 years old (contract age), so that a minor doesn't try to register as an adult.
    From what I understand, I can't use SYSDATE in a check statement. Is there another way? What about using CURRENT_DATE and FLOOR to form a statement for this check?
    Here's the DDL for the table (table is not fully decomposed to keep it simple; "dob" represents "Date of Birth" and "zipcode" is a FK to this table):
    CREATE TABLE member     (
    member_id     VARCHAR2(10)     NOT NULL,
    fname          VARCHAR2(30)     NOT NULL,
    lname          VARCHAR2(30)     NOT NULL,
    address1     VARCHAR2(50),
    address2     VARCHAR2(25),
    zipcode     NUMBER(5)     NOT NULL,
    phone          VARCHAR2(15)     NOT NULL,
    dob          DATE          NOT NULL,
    gender     CHAR(1)          NOT NULL,
    CONSTRAINT ck_gender     gender IN ('M','F'),
    CONSTRAINT pk_member     PRIMARY KEY (member_id),
    CONSTRAINT fk_member_zipcode (zipcode) REFERENCES zipcode)
    Thanks for your help.

    Like SYSDATE, CURRENT_DATE is a non-deterministic function and so cannot be used in this context.
    From the manual:
    Restrictions on Check Constraints
    You cannot specify a check constraint for a view. However, you can define the view using the WITH CHECK OPTION clause, which is equivalent to specifying a check constraint for the view.
    The condition of a check constraint can refer to any column in the table, but it cannot refer to columns of other tables.
    Conditions of check constraints cannot contain the following constructs:
    Subqueries and scalar subquery expressions
    Calls to the functions that are not deterministic (CURRENT_DATE, CURRENT_TIMESTAMP, DBTIMEZONE, LOCALTIMESTAMP, SESSIONTIMEZONE, SYSDATE, SYSTIMESTAMP, UID, USER, and USERENV)
    Calls to user-defined functions
    Dereferencing of REF columns (for example, using the DEREF function)
    Nested table columns or attributes
    The pseudocolumns CURRVAL, NEXTVAL, LEVEL, or ROWNUM
    Date constants that are not fully specified
    To achieve this sort of checking you will need to use a trigger

  • Where-used list, Other WF template, Check functions

    Hi all.....within the Workflow Template screen, there are 4 icons at the top left-hand corner.....one is a 'Display-Change' function.  The other 3 however I'm not sure what they are, and what function they serve.  Can someone explain what these are, and in what scenarios they would be used?:
    Check
    Where-used List
    Other WF template
    Thanks!
    Steve

    Hi Steve,
    I hope by this tme, you might have explored these options..But if not , go ahead and try them out..
    Anyway, just for an easy way, I'll brief it:
    <b>Check</b>: Used to do the syntax check for workflow template
    <b>Where-used list</b>: SImilar to Other ABAP objects, i.e. to find out in which other places , this particular takss are used
    <b> Other WF -Template</b> : When you want to work with  workflow template other than that presented by workflow builder.
    Hope with htis you wil explore more on this front .
    Regds,
    Akshay

  • Spell Check using the function module LXE_SP_CHECKSPELLING_TABLE_MS

    Hi,
    I am using this function module to do a spell check on description and text/note fields. This works great using IC WinClient (SAP GUI). When this is called from IC WebClient (BSP), the function module is returning NO_ACTIVEX error. Did someone encounter the same issue?
    Please let me know.
    Thanks
    Venny

    Hi,
    This might also be of help....
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/library/technologies/ms%20word-like%20spell%20checker%20for%20sap%20gui%20fields">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/library/technologies/ms%20word-like%20spell%20checker%20for%20sap%20gui%20fields</a>
    <b><i>Do reward each useful answer..!</i></b>
    Thanks,
    Tatvagna.

  • New to PL/SQL and need help on check sum using ASCII function

    Hello,
    Need your expertise to help in figuring out how to write
    code to calculate using ASCII function to return value for a character. For example ASCII('A') is 58. I want to do the check sum to sum-up the value for each character in the name. For example 'Jack'
    Appreciate your help.
    CK

    Hi,
    Please post all the technical queries in the respective forums. For more details and answers in SQL and PL/SQL, use the following forum:
    PL/SQL
    Sample PL/SQL code for your requirement:
    -- make sure you have the serveroutput on using command.
    -- set serveroutput on
    DECLARE
    sumval NUMBER(10);
    tempval NUMBER(10);
    colval VARCHAR2(20);
    BEGIN
    SELECT USER INTO colval FROM dual;
    sumval := 0;
    FOR i IN 1..LENGTH(colval)
    LOOP
    SELECT ASCII(SUBSTR(colval,i,1)) INTO tempval FROM dual;
    sumval := sumval+tempval;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE('sum is: '||to_char(sumval));
    END;
    The output of this pl/sql block will be:
    sum is: 397
    Please note: ASCII('A') is 65 and not 58.
    Hope that helps.
    Savitha.
    http://otn.oracle.com/sample_code/content.html

  • Domain check constraint using column name

    Hello,
    in the domain administration of Data Modeler, I defined a domain "age",
    and set it to logical type "Integer". Now I want to define a check constraint
    for that domain, saying, that every attribute of domain "age" must have
    values greater than 18.
    But how should I specify the column name for that check-constraint, since
    I cannot know now, to which columns this domain will be applied to, and
    these columns could have different names!
    I tried {column} > 18 and hoped that {column} might be substituted by
    the appropriate column name when generating DDL but it was not,
    the DDL contained "check ( {column} > 18 ) which did of course not work.
    Does anybody have an idea?

    Thanks a lot, that solved the problem. I noticed additionally, that %COLUMN% is case sensitive, so %COLUMN% gets substituted by the column name in the DDL, while %column% does not.

  • Crash of Oracle XE when check constraint uses in-operator with desc. values

    ORA-03113 and other errors in conjunction with lost of connection occur in Oracle XE under the following conditions:
    /* Crash (values of check constraint in descending order) */
    DROP TABLE CRASHTEST CASCADE CONSTRAINTS;
    CREATE TABLE CRASHTEST
    CRASHTEST_ID NUMBER(9),
    CRASHTEST_OK NUMBER(1) DEFAULT 0
    ALTER TABLE CRASHTEST ADD (CONSTRAINT CRASHTEST_CK CHECK (CRASHTEST_OK IN (0,-1)));
    INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (1, 0);
    INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (2, -1);
    COMMIT;
    SELECT * FROM CRASHTEST WHERE CRASHTEST_OK = 0;
    If all values of the in-clause within the check constraint are entered in ascending order, no error occurs:
    /* No Crash (values of check constraint in ascending order) */
    DROP TABLE CRASHTEST CASCADE CONSTRAINTS;
    CREATE TABLE CRASHTEST
    CRASHTEST_ID NUMBER(9),
    CRASHTEST_OK NUMBER(1) DEFAULT 0
    ALTER TABLE CRASHTEST ADD (CONSTRAINT CRASHTEST_CK CHECK (CRASHTEST_OK IN (-1,0)));
    INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (1, 0);
    INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (2, -1);
    COMMIT;
    SELECT * FROM CRASHTEST WHERE CRASHTEST_OK = 0;
    Especially interesting is the fact, that the error is caused by a check constraint in conjunction with a select statement!
    Hopefully, there are no other hidden bombs stealing my time...
    Have a nice day,
    Sven

    It might be interesting to post that in the XE forum to notify Oracle developers and XE users.
    Oracle Database Express Edition (XE)
    C.

  • Is it possible to create a dynamic(with a select) check constraint?

    create table a (col_to_be_coded_fora number);
    create table b (col_to_be_coded_forb number);
    create table c (col_name varchar2(20), col_code number, col_desc varchar2(20));
    insert into c values ('col_to_be_coded_fora', 1, 'active');
    insert into c values ('col_to_be_coded_fora', 2, 'de-active');
    insert into c values ('col_to_be_coded_fora', 3, 'pending');
    insert into c values ('col_to_be_coded_forb', 10, 'school');
    insert into c values ('col_to_be_coded_forb', 20, 'hospital');
    insert into a values ( 1); -- meaning 'active' for table a, column col_to_be_coded_fora, can go in
    insert into a values (10); -- meaning nothing for table a, column col_to_be_coded_fora, must give error
    insert into b values ( 1); -- meaning nothing for table b, column col_to_be_coded_forb, must give error
    insert into b values (10); -- meaning 'school' for table b, column col_to_be_coded_fora, can go in
    I know i can handle this problem with dividing table c into to tables and creating foreign key relationship.
    in this demo case i have only a and b, 2 tables but i want to encode thousands of tables with a table like c.
    &#304;s it possible to create a dynamic check constraint on a table which selects c table for the inputs that have permision?
    Or do i have to use after insert, update triggers on table a and b to ensure this functionality?
    Is there a smarter implementation for this need, may be a design change?
    Thank you,
    Kind regards.
    Tonguç

    Hi Tonguç,
    A small design change makes it possible to do this with simple foreign key constraints.
    I would do something like:
    ual303@ORKDEV01> CREATE TABLE c (
      2    col_name VARCHAR2(20),
      3     col_code NUMBER,
      4     col_desc VARCHAR2(20),
      5     PRIMARY KEY (col_name, col_code)
      6  );
    Tabel is aangemaakt.
    ual303@ORKDEV01> CREATE TABLE a (
      2    col_to_be_coded_fora NUMBER PRIMARY KEY,
      3     col_name VARCHAR2(20) DEFAULT 'col_to_be_coded_fora' CHECK (col_name = 'col_to_be_coded_fora'),
      4     FOREIGN KEY (col_name, col_to_be_coded_fora) REFERENCES c
      5  );
    Tabel is aangemaakt.
    ual303@ORKDEV01> CREATE TABLE b (
      2    col_to_be_coded_forb NUMBER PRIMARY KEY,
      3     col_name VARCHAR2(20) DEFAULT 'col_to_be_coded_forb' CHECK (col_name = 'col_to_be_coded_forb'),
      4     FOREIGN KEY (col_name, col_to_be_coded_forb) REFERENCES c
      5  );
    Tabel is aangemaakt.
    ual303@ORKDEV01> insert into c values ('col_to_be_coded_fora', 1, 'active');
    1 rij is aangemaakt.
    ual303@ORKDEV01> insert into c values ('col_to_be_coded_fora', 2, 'de-active');
    1 rij is aangemaakt.
    ual303@ORKDEV01> insert into c values ('col_to_be_coded_fora', 3, 'pending');
    1 rij is aangemaakt.
    ual303@ORKDEV01> insert into c values ('col_to_be_coded_forb', 10, 'school');
    1 rij is aangemaakt.
    ual303@ORKDEV01> insert into c values ('col_to_be_coded_forb', 20, 'hospital');
    1 rij is aangemaakt.
    ual303@ORKDEV01> -- meaning 'active' for table a, column col_to_be_coded_fora, can go in
    ual303@ORKDEV01> insert into a(col_to_be_coded_fora) values ( 1);
    1 rij is aangemaakt.
    ual303@ORKDEV01> -- meaning nothing for table a, column col_to_be_coded_fora, must give error
    ual303@ORKDEV01> insert into a(col_to_be_coded_fora) values (10);
    insert into a(col_to_be_coded_fora) values (10)
    FOUT in regel 1:
    .ORA-02291: integrity constraint (UAL303.SYS_C0033537) violated - parent key not found
    ual303@ORKDEV01> -- meaning nothing for table b, column col_to_be_coded_forb, must give error
    ual303@ORKDEV01> insert into b(col_to_be_coded_forb) values ( 1);
    insert into b(col_to_be_coded_forb) values ( 1)
    FOUT in regel 1:
    .ORA-02291: integrity constraint (UAL303.SYS_C0033540) violated - parent key not found
    ual303@ORKDEV01> -- meaning 'school' for table b, column col_to_be_coded_fora, can go in
    ual303@ORKDEV01> insert into b(col_to_be_coded_forb) values (10);
    1 rij is aangemaakt.
    ual303@ORKDEV01>Cheers,
    Colin

  • Using analytical function - value with highest count

    Hi
    i have this table below
    CREATE TABLE table1
    ( cust_name VARCHAR2 (10)
    , txn_id NUMBER
    , txn_date DATE
    , country VARCHAR2 (10)
    , flag number
    , CONSTRAINT key1 UNIQUE (cust_name, txn_id)
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9870,TO_DATE ('15-Jan-2011', 'DD-Mon-YYYY'), 'Iran', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9871,TO_DATE ('16-Jan-2011', 'DD-Mon-YYYY'), 'China', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9872,TO_DATE ('17-Jan-2011', 'DD-Mon-YYYY'), 'China', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9873,TO_DATE ('18-Jan-2011', 'DD-Mon-YYYY'), 'Japan', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9874,TO_DATE ('19-Jan-2011', 'DD-Mon-YYYY'), 'Japan', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9875,TO_DATE ('20-Jan-2011', 'DD-Mon-YYYY'), 'Russia', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9877,TO_DATE ('22-Jan-2011', 'DD-Mon-YYYY'), 'China', 0);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9878,TO_DATE ('26-Jan-2011', 'DD-Mon-YYYY'), 'Korea', 0);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9811,TO_DATE ('17-Jan-2011', 'DD-Mon-YYYY'), 'China', 0);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9854,TO_DATE ('13-Jan-2011', 'DD-Mon-YYYY'), 'Taiwan', 0);
    The requirement is to create an additional column in the resultset with country name where the customer has done the maximum number of transactions
    (with transaction flag 1). In case we have two or more countries tied with the same count, then we need to select the country (among the tied ones)
    where the customer has done the last transaction (with transaction flag 1)
    e.g. The count is 2 for both 'China' and 'Japan' for transaction flag 1 ,and the latest transaction is for 'Japan'. So the new column should contain 'Japan'
    CUST_NAME TXN_ID TXN_DATE COUNTRY FLAG country_1
    Peter 9811 17-JAN-11 China 0 Japan
    Peter 9854 13-JAN-11 Taiwan 0 Japan
    Peter 9870 15-JAN-11 Iran 1 Japan
    Peter 9871 16-JAN-11 China 1 Japan
    Peter 9872 17-JAN-11 China 1 Japan
    Peter 9873 18-JAN-11 Japan 1 Japan
    Peter 9874 19-JAN-11 Japan 1 Japan
    Peter 9875 20-JAN-11 Russia 1 Japan
    Peter 9877 22-JAN-11 China 0 Japan
    Peter 9878 26-JAN-11 Korea 0 Japan
    Please let me know how to accomplish this using analytical functions
    Thanks
    -Learnsequel

    Does this work (not spent much time checking it)?
    WITH ana AS (
    SELECT cust_name, txn_id, txn_date, country, flag,
            Sum (flag)
                OVER (PARTITION BY cust_name, country)      n_trx,
            Max (CASE WHEN flag = 1 THEN txn_date END)
                OVER (PARTITION BY cust_name, country)      l_trx
      FROM cnt_trx
    SELECT cust_name, txn_id, txn_date, country, flag,
            First_Value (country) OVER (PARTITION BY cust_name ORDER BY n_trx DESC, l_trx DESC) top_cnt
      FROM ana
    CUST_NAME      TXN_ID TXN_DATE  COUNTRY          FLAG TOP_CNT
    Fred             9875 20-JAN-11 Russia              1 Russia
    Fred             9874 19-JAN-11 Japan               1 Russia
    Peter            9873 18-JAN-11 Japan               1 Japan
    Peter            9874 19-JAN-11 Japan               1 Japan
    Peter            9872 17-JAN-11 China               1 Japan
    Peter            9871 16-JAN-11 China               1 Japan
    Peter            9811 17-JAN-11 China               0 Japan
    Peter            9877 22-JAN-11 China               0 Japan
    Peter            9875 20-JAN-11 Russia              1 Japan
    Peter            9870 15-JAN-11 Iran                1 Japan
    Peter            9878 26-JAN-11 Korea               0 Japan
    Peter            9854 13-JAN-11 Taiwan              0 Japan
    12 rows selected.

  • Check constraint in Data Modeler

    Hi
    I have a problem with merging two logical models.
    in first I have a table with column ranking number(2),
    in second model I modify this column:
    ranking varchar2(10) default 'A'
    and create check constraint ranking_ch:
    ranking..... check ('A', 'B',.....)
    Then I compare models I have only
    alter table....
    modify ranking varchar2(10) default 'A'
    but I have not constraint ranking_ch.
    Why?

    Thanks.
    Another topic:
    I have a problem with reverse engineering with Data Modeler:
    1.I have a simple script (*.sql):
    create table jw
    (a number(2),
    b varchar2(30)
    2.I use function file/import/ddl file - on Relational diagram is OK:
    I have table with two columns.
    3. I use function Engineer to Logical Model and I see entity with:
    a numeric_0_2_0
    b varchar_0_0_30
    Modeler creates two new domains.
    Why?

  • Tabular Form Validation: Comparing Two Columns vs Check Constraint

    What is the best approach for validating that one column needs to be greater than another column in a tabular form when attempting to save. (E.g. An effective date and expirey date column. The expirey date column >= effective date column)
    At the moment I have a check constraint on the two columns at the database level which is fine but it returns and passes up a pretty cryptic (from a business user perspective) unfriendly message to the user as follows:
    Error in mru internal routine: ORA-20001: Error in MRU: row= 1, ORA-02290: check constraint (IDMTC.ADDRESS_TYPE_CON) violated, update "IDMTC"."ADDRESS_TYPE" set "ID" = :b1, "CODE" = :b2, "NAME" = :b3, "LOV_SORT_ORDER" = :b4, "DESCRIPTION" = :b5, "EFFECTIVE_DATE" = :b6, "EXPIRY_DATE" = :b7 where "ID" = :p_pk_col
    Unable to process update.
    Is there a way to inject, detect and/or replace this with a friendlier business user message? I have confirmed that the "Unable to process update." text at the bottom below the MRU Internal routine error raised from my check constraint is the process error message for my Apply MRU process.
    I was hesitating going down a larger page level validation where I loop through the tabular form array and/or inject some client side Javascript.
    Any advice? Have I simply overlooked some tabular form options for validating using cross column values?
    Thanks,
    Jeff

    Jeff..Thanks for the response.
    However because I am working in a tabular form at design time I don't know which controls I can reference in a dynamic action, or custom Javascript routine other than selecting all elements in a column using JQuery, etc.
    I have decided to go with for the time being an approach I found here: doing validation on tabular form
    My code ended up looking something like and was entered into a page level validation as a PL/SQL function body returning error text.:
    DECLARE
    l_error VARCHAR2 (4000);
    BEGIN
    FOR i IN 1 .. apex_application.g_f02.COUNT
    LOOP
    --If Expiry date is older then effective date
    IF nvl(apex_application.g_f08 (i), to_date('31-DEC-9999', 'dd-mon-yyyy')) < apex_application.g_f07 (i) THEN
    l_error :=
    l_error
    || '</br>'
    || 'Row '
    || i
    || ': Expiry date must be greater than effective date '
    || ' for maintenance item name: '
    || apex_application.g_f03 (i);
    END IF;
    END LOOP;
    RETURN LTRIM (l_error, '</br>');
    END;
    I had been hoping with Apex 4+ that there was additional native functionality to do this type of validation or somehow be able to reference a column or control name instead of a generic array column so that my code was better self documenting.
    It works for now...but would love to revisit with maybe a cleaner client side solution that does the validation and highlights the invalid element since I still maintain data integrity at the db with the check constraint.
    Thanks,
    Jeff

  • 10g 10.2.0.1.0 - Check Constraint with negative values possibly BUG.

    Hello,
    Why this doesn't work ?
    create table a (b numeric(1));
    alter table a
    add constraint b CHECK (b in (0, 1, -1)) ENABLE;
    select * from a where b = -1;
    I get the following error: java.sql.SQLException: No more data to read from socket
    - Through the jdbc client. It happens with the Oracle Client too.
    When i change my check constraint to this:
    alter table a
    add constraint b CHECK (b in (-1, 0, 1)) ENABLE;
    It works.
    It's a (known) bug ?
    Regards,
    Francisco

    hi dear,
    I want to upgrade my OMS server 10.2.0.1 to 10.2.0.5
    I downloaded the patch 10.2.0.5 and read the README.txt
    Part of the README is:
    1.2 Enter the following command to extract the installation files:
    $ unzip GridControl_10.2.0.5_<platform name>.zip
    This command extracts the following files and directory:
    |- p3731593_10205_<platform name>.zip
    |- 3731596.zip
    |- 3822442.zip
    |- README.txt
    |- doc/
    NOTE: <platform name> will be "LINUX" or "Win32" depending on the platform for which you are installing. For installing Enterprise Manager 10g Grid Control Release 5 (10.2.0.5), refer to the Release Notes available in the "doc" directory.
    - p3731593_10205_<platform name>.zip is the ZIP file that contains 10.2.0.5 patch set software.
    This zip can be used for:
    - Upgrading Oracle Management Service Release 2 (10.2.0.x) or higher to Oracle Management Service Release 5 (10.2.0.5)
    - Upgrading Oracle Management Repository (sysman schema)
    - Upgrading Oracle Management Agent on the host where OMS is running.
    NOTE: This will not upgrade the database in which the Management Repository (sysman schema) resides.
    - 3731596.zip is for patching Management Agent by staging the patch set. To understand how you can apply the Management Agent 10.2.0.5 patch set, refer to method 2 described in section 4.3.3 "Upgrading Management Agent - Multiple Hosts at a Time" of the Release Notes. The Release Notes can be found in the "doc" directory.
    - 3822442.zip is for patching Management Agent by distributing the full patch set.  To understand how to apply the Management Agent 10.2.0.5 patch set, refer to method 1 described in section 4.3.3 "Upgrading Management Agent - Multiple Hosts at a Time" of the Release Notes. The Release Notes can be found in the "doc" directory.3731596.zip - by staging
    3822442.zip - by distributing
    Does the two above have the same function or purpose?
    I can not understand the meaning of the two :( . which do you think is the right one for my setup?
    Thanks a lot

Maybe you are looking for

  • Internal Server Error while running JSP file (Oracle AS - HP Unix)

    Hello Friends, I have created a JSP file in which I am trying to connect the database using oracle.jdbc.pool directory. But it shows an error message as: Internal Server Error The server encountered an internal error or misconfiguration and was unabl

  • Data Server  for Microsoft acces

    Hello, How can I define Data Server in ODI for Microsoft acces? Does anyone have experience with Microsoft acces and ODI? I want to use Microsoft accessions as a source for data migration. Thanks in advance..

  • PS Organizer Photo Import Fails

    I am experiencing a problem importing photos already stored on my hard drive into my Organizer catalog. When I attempt to Get Photos, Organizer returns the message saying "import failed". It goes on to tell me nothing was imported. The files or folde

  • HT201210 my friends ipod is stuck on recovery mode

    Hi, My friend asked me to do a softwear update on her ipod, because she couldnt do it through the wifi so i plugged it into my lap and did the update but write after it said it need to restore and update i didnt understand why so i just went with it,

  • How do I change the incoming mail server settings in Mac Mail?

    I have a Mac 27" update to Yosemite 10.10.2. I have 25 GB free in storage. I have been having trouble with road runner email and found out today that they are changing their email settings. How do I change the incoming mail server settings in Mac Mai