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.
İ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

Similar Messages

  • Is it possible to create a form with multiple form fields on a single line?

    Is it possible to create a form with multiple form fields on a single line?  I can't find anything in the documentation or a template that does this.
    I am trying to create a "documents received" checklist with a check box on the left margin, a date-received field to the right of the check box and and a description of the document (Formatted Text) on the far right.
    In the past I have entered the Fixed Text with a word processor, published it to a PDF file, then added the check box and date fields with the Acrobat Forms editor.  I would prefer to use FormsCentral if it is possible.

    We now support multiple fields on one line. This post provides a brief overview.
    Give it a try and send us your feedback.
    Sorry it took so long.
    Randy

  • Is it possible to create a Column with Conditional Mandatory with another Column?

    Is it possible to create a Column with Conditional Mandatory with another Column?
    For example
    In a Table we have column A, B, C.
    A is Primary Column.
    B is Optional
    C is Conditional Mandatory.
    A B
    C
    12345 ABC
    OK
    12346 NULL
    NULL
    12347 ABC
    OK
    Only if the B Column has the value then only C column should be mandatory

    I guess you can't create a condtional mandatory column directly. However, you can use check constraint to on the column
    create table YourTable
      A int primary key,
      B char(3),
      C int,
      constraint ch_con check(
                                B
    is not null
    or C is null

  • Is it possible to create DVD Templates with Motion for burning Blue Ray DVDs from Final Cut Pro X?

    Is it possible to create DVD Templates with Motion for burning Blue Ray DVDs from Final Cut Pro X?

    As far as I know, motion templates can only be used with DVD Studio Pro. FCP X only lets you add a background image to the DVD menu.

  • Is it possible to create a timestamp with an accuracy of 1ms?

    I want to acquire data with PCI-6023 and write them with a precise timestamp to a file. Is it possible to create a timestamp with an accuracy of 1ms?
    Maybe somebody can tell me experiences with logging data over a time periode up to 24 hours (and time-accuracy of 1ms)?

    Hi Hans, This forum is related to one of National Instruments' automation products rather than data aquisition. Perhaps you will acheive better results if you post your question to one of the "Measurement Devices" forms instead.

  • Is it possible to create a tree with drag-and-drop functionality using ajax

    I saw these samples;
    Scott Spendolini's AJAX Select List Demo
    http://htmldb.oracle.com/pls/otn/f?p=33867:1:10730556242433798443
    Building an Ajax Memory Tree by Scott Spendolini
    http://www.oracle.com/technology/pub/articles/spendolini-tree.html
    Carl Backstrom ApEx-AJAX & DHTML examples;
    http://htmldb.oracle.com/pls/otn/f?p=11933:5:8901671725714285254
    Do you think is it possible to create a tree with drag-and-drop functionality using ajax and apex like this sample; http://www.scbr.com/docs/products/dhtmlxTree/
    Thank you,
    Kind regards.
    Tonguç

    Hello,
    Sure you can build it, I just don't think anyone has, you could also use their solution as well in an APEX page it's just a matter of integration.
    Carl

  • Is it possible to create purchase order with zero value ?

    Is it possible to create purchase order with zero value ?

    Hi,
    There are two scenarios where the purchase order is created with zero value.
    1. Standard Purchase order with Free tick indicator.
    Whenever we expect a material with free of cost from vendor, we use to put the free indicator in item overview.  This means the material is valuated at zero price irrespective of price control in material master. Quanitiy is updated while receipts.
    Conditions tab in item detail doesnt appear.
    2. Consignment PO.
    While creating a purchase order for consignment, the system doesnt ask us the price and the condition tab doesnt appear in item detail.
    An info record for consignment must be maintained before making the GR.
    Hope i have clarified.  If you want any further clarification. please do reply.

  • Is it possible to create sub-client with in SAP production (PRD) client

    Hello Experts,
    Is is possible to create sub client with in SAP production client?
    The question came to mind is that if I am the father company of two child/sub companies and both these function under my company and the users of all the companies will have different SAP log in . But, I can I create a Main PRD client say 'PRD L1 and under this client I create PRD L2 and PRD L3.
    Is that possible and seems logical?
    Thanks & Regards
    Saurabh

    This is not a question for this forum, because you are trying to discuss security where you should be trying (or rather your FI/CO department should be) to discuss business scenarios.
    I never dreamed (after 20 years doing SAP), that I'd quote the original SAP documentation on clients vs. company codes again, ever - but here it goes:
    Company Code
    Definition
    Smallest organizational unit of external accounting for which a complete, self-contained set of accounts can be created. This includes the entry of all transactions that must be posted and the creation of all items for legal individual financial statements, such as the balance sheet and the profit and loss statement.
    The definition of the company code organizational unit is obligatory .
    Anything bigger goes to a different client.
    Try to come up with a business architecture first and adapt security after, accordingly.

  • Is it possible to create a dynamic dispatch VI from parent VI as a template

    Hi all,
    I'm new to LVOOP and wondering if it's possible to create a dynamic dispatch VI from the parent VI as a template.
    For example:
    I've got a Class-method in the parent class. All child-classes use this method except of one child, which needs a little tweak on this VI.
    So I need to overload the VI in the child class.
    When I choose "New -> New Dynamic Dispatch VI" I get an VI based on a template
    (As described by Darren Nattinger here: http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-07-07-2010/m-p/1172483/highlight/true#M510414 )
    Is it possible to get a copy of the parent VI instead that I can tweak ?
    Thanks you in advance!
    Best regards,
    Balze

    An over-ride VI is not that special.
    The input and output classe must be "Dynamic".
    The icon connectors have to be the same.
    The Over-ride VI must have the same name as the parent and be a member of the child class.
    So Save-as add to project but not to class.
    Move to child class.
    Rename.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Create a dynamic form where selected text boxes appears, based on options chosen in a drop-down box

    HELP!!! Can anyone please provide some guidance on how to create a dynamic form where selected text boxes appears, based on options chosen in a drop-down box.
    I have a form which – based on the department that's selected from a drop-down box – will have different form fields/text boxes, etc, made available.
    Is this possible in LiveCycle, if so, can you please provide the script/info - as needed.
    Thanks,

    In the preOpen event of the second dropdown list you put something like (in formCalc):
    if (dropdown1 == 1) then
    $.clearItems()
    $.setItems("Year, 2 Year,  3 Year")
    elseif (dropdown1 == 2) then
    $.clearItems()
    $.setItems("3 Year,  4 Year")
    endif

  • How to create a table with multiple select on???

    Hi all,
            I am  new to webdynpro and my requirement is to create a  table with multiple selection on.I have to add abt 10 rows in the table but only 5 rows should be visible and moreover a verticalscroll should be available to view other rows.Can anybody explain me in detail how to do that.Please reply as if you are explaining  to a newcomer.Reply ASAP as i have to do it today.
                                                                           Thanxs

    Hi,
    1. Create a value node in your context name Table and set its cardinality to 0:n
    2. Create 2 value attributes within the Table node name value1 and value2
    3. Goto Outline view> Right click on TransparentUIContainer>Apply Template> Select Table>mark the node Table and it's attributes.
    you have created a table and binded its value to context
    Table UI properties
    4.Set Selection Mode to Multi
    5.Set Visible Row Count to 5
    6.ScrollableColCount to 5
    In your implemetaion, you can add values to table as follow:
    IPrivate<viewname>.ITableElement ele = wdContext.nodeTable().createTableElement();
    ele.setValue1(<value>);
    ele.setValue2(<value>);
    wdContext.nodeTable().addElement(ele);
    The above code will allow you to add elements to your table node.
    Regards,
    Murtuza

  • Is it possible to create controls dynamically.

    Hai,
    Is it possible to create control or arrays dynamically in LabVIEW.That means i want to create controls at run time depending on the dynamic data.
    Please help me in this regard.

    Ben wrote:
    Christian's "Create Controls on the Fly"
    Just for reference, Here's the original fly post. Makes it easier to find my old stuff.
    (Of course there could be other interpretations of "on the fly": The 1971 album cover of "Sticky Fingers" but the Rolling stones comes to mind. )
    LabVIEW Champion . Do more with less code and in less time .

  • Is it possible to create a panel with JavaScript?

    Hi friends
    As I´m studying JavaScript and the user interface creation...would like to ask (more for curiosity):
    Is it possible to create a new panel for Illustrator using JavaScript? Or this is only possible using C++?
    (in the Window Class UI we have the "palette" creation method..so wondering the result of it too)
    Thank you a lot
    Gustavo

    Hi Larry
    Thank you a lot for sharing this reference. This has alternative explanations from the JavaScript Tools Guide that already come with the Extended Script Toolkit SDK (I´m reading this and finding very very useful).
    My question, however, is not covered in any of the manuals.
    I´d like to confirm if a panel (like Brushes, Swatches, Appearance and Layer Illustrator panels) can be made only via C++??? (and not via JavaScript).
    Can I assume the Script UI capabilites in JavaScript can resume itself on creating dialog boxes only (not panels that persist, keep opened in the software, also could be docked in the side of app)?
    Thank you
    Gustavo.

  • Is it possible to create a page with a signature, that can be then applied to other pages?

    I want to know if I can create a page, with a place for an ink signature, and that signature can be then copied onto other pages within the pdf where the same person's signature is needed.

    I would like to invite you to take a look at my Nugget on Action Engines.
    Since you have a data value that must be available for live updates in more than one place in the code, an Action Engine will provide a reliable method to share that value. You will update the Action Engine any time the control changes. All other function that require that information can read the the value form the Action Engine.
    That method has been in use since LV version 2 and provided the AE is implemented correctly (see Nugget) it gives good performance and helps keep code modular.
    I hope that help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Is it possible to create a Synonym with different column names

    Hi,
    I want to create a Synonym with different columns names (Columns not in original table) . I am not sure if this can be done . Any suggessions...
    Thanks in advance....

    Synonyms are not limited to tables. Accroding to the SQL Reference, a synonym is:
    an alternative name for a table, view, sequence, procedure, stored function, package, materialized view, Java class schema object, user-defined object type, or another synonym.
    In fact, synonyms are not even validated until they are used:
    SQL> create synonym my_synonym for table_which_does_not_exist;
    Synonym created
    SQL> select * from my_synonym;
    select * from my_synonym
    ORA-00980: synonym translation is no longer valid

Maybe you are looking for

  • Need help in Group by query

    Hi All, I am using Oracle 11 g. I have a query which is giving output as SELECT o.campgn_no , m.lang , COUNT(1) FROM tg_main m, sp_offer o WHERE m.offer_id = o.offer_id AND o.campgn_no IN (SELECT campgn_no FROM sp_campgn_cntrl WHERE product_code = 'O

  • EJB does not connect to IP through WebLogic

              Hi All--           Here is the problem. My servlet makes calls to EJB's in the hopes of connecting           to an IP address outside of my firewall through WebLogic. It doesn't attempt           a connection. I know my code is correct beca

  • Buying music credit in another country

    i have a family member living in another country in europe and i would like to buy him some music credit, is it possible/will it work in his country?? Message Edited by renrut04 on 19-Apr-2009 12:07 PM

  • Queries to extract slow moving stock

    Hi All, I have the following queries to extract the item list.  May I know how to modify this queries to filter slow moving item where Purchase date are over 90 days older than today date.  Example, today is 01/05/15 the report will list only item wh

  • Re: Material Text- Tag colunm

    Hi,       this is the issue regarding material master(mm02). user want to fetch the data related to the TAG column for all the materials. Ex: There are 1000's of materials only some materials are maintained with TAG column(sales text tab in the mater