Constraint for possible values

I have the table named "test1":

CREATE TABLE test1)

site_number VARCHAR2 (255),

number of criteria_number

criteria_value varchar2 (255));

INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (1, 1, 'Yes');

INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (1, 2, 'No');

INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (2, 1, 'Yes');

INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (2, 2, 'Probable');

If the criteria_number is 1, then the possible values are either 'yes' or 'no '.

If the criteria_number is 2, then the possible values are 'Yes', 'No', or 'of nature. "

How to create a constraint on the criteria_value column or something similar that would guarantee the integrity of the data by preventing a person from inserting a line with criteria_number 1 and criteria_value '' probably '' still would allow a line to be inserted with criteria_number 2 and criteria_value "likely"?

I am using Oracle 11g

Use the constarint control. You does not say what criteria value may be for the number of criteria other than 1 or 2, so I guess it can be almost anything:

ALTER TABLE test1

ADD CONSTRAINT test1_chk1

CHECK)

(

criteria_number = 1

AND

IN criteria_value ('yes', 'No')

)

OR

(

criteria_number = 2

AND

IN criteria_value ('yes', 'No', "Probable")

)

OR criteria_number NOT IN (1,2)

)

/

Modified table.

SQL > INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (1, 1, 'Yes');

1 line of creation.

SQL >
SQL > INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (1, 2, 'No');

1 line of creation.

SQL >
SQL > INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (2, 1, 'Yes');

1 line of creation.

SQL >
SQL > INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (2, 2, 'Probable');

1 line of creation.

SQL > INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (1, 1, 'Probable');
INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (1, 1, 'Probable')
*
ERROR on line 1:
ORA-02290: check constraint (SCOTT. TEST1_CHK1) violated

SQL > INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (1, 1, 'X');
INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (1, 1, 'X')
*
ERROR on line 1:
ORA-02290: check constraint (SCOTT. TEST1_CHK1) violated

SQL > INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (2, 2, 'Y');
INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (2, 2, 'Y')
*
ERROR on line 1:
ORA-02290: check constraint (SCOTT. TEST1_CHK1) violated

SQL > INSERT INTO test1 (site_number, criteria_number, criteria_value) VALUES (3.99, 'Whatever');

1 line of creation.

SQL >

SY.

Tags: Database

Similar Questions

  • A workflow that lists all the possible values for VirtualMachineGuestOsIdentifier

    I want to set up a workflow that will present you with a list of values VirtualMachineGuestOsIdentifier and their long name equivalents. My goal is to create a service that other people can use to select the operating system they run on a new virtual machine. It is in favour of a 'portal' that develops where users will be "order" new virtual machines and manage their existing virtual machines.

    I know I can get the list of the VirtualMachineGuestOsIdentifier of the vim file - types.xsd our vCenter server but it is a huge file and it does not list the long names for possible values of the BONES. I want to somewhat make life easier for our web developers about it.

    I know how to get a guest operating system object, if I already have the value corresponding to the call to VcVirtualMachineGuestOsIdentifier.fromString (). But if I can get a list of all possible values?

    Please and thank you.

    Colin j.

    If you want to get the values of interactively simply use the input type.

    If you want to list these programmatically, use:

    var array = Server.findAllForType("VC:VirtualMachineGuestOsIdentifier");
    
    for each (var element in array) {
        System.log(element.value);
    }
    
  • possible values for limit forced help

    Hi all

    I've got table t1 with column period. The possible values for the period of the column: 1 or 2.

    How can I restrict the possible values by using the constraint?

    You can add a constraint check as follows:

    ALTER TABLE t1 ADD CONSTRAINT t1_chk CHECK (period IN (1,2))
    
  • What are the possible values for APP_COMPONENT_TYPE?

    The possible values of APP_COMPONENT_TYPE documented anywhere?

    Also, I want to ask all the components in my APEX application. My current query of multiple views unions APEX (apex_application_page_items, apex_application_page_buttons, apex_application_page_regions,...)-a point of view by each component type. Is there a better way to list components?

    Thank you

    -Kris

    Select * from APEX_APPLICATION_ALL_AUTH

    View: APEX_APPLICATION_ALL_AUTH
    Description: All the authorisation schemes for all components of the Application
    Column Name Comments
    WORKSPACE Model authorization workspace
    WORKSPACE_DISPLAY_NAME Full name of the workspace
    APPLICATION_ID Number of request of authorization Scheme
    APPLICATION_NAME Name of the schema to request authorization
    PAGE_ID ID of Page authorization regime
    COMPONENT_TYPE APEX authorization schema component type
    NAME OF THE COMPONENT Name of the component system APEX authorization
    AUTHORIZATION_SCHEME Name of schema authorization
    STATUS Situation of authorisation system

    See http://eberapp.com/pls/apex/f?p=447:1301:35096966318357:CLEAR_SORT:RP, 1301:P1301_VIEW:APEX_APPLICATION_ALL_AUTH

  • The possible values for fFileType when you add a file in frame files?

    Hello

    I did experiment with creating links to files in the framework Folders pane. Currently I have it works using the following parameters:

    fParentGUID: the GUID of the folder parent where the new link will be created.
    fFileType: the type of link that you want to create.
    dDocName: the name of the document to the target of the link.

    I was unable to find out what the possible values of fFileType. The value that I know is 'owner' but, my understanding of fFileType stops.

    I tried to find valid values in the 'Configuration Manager' applet (views-> FoldersFileTypes), but I'm unable to view/edit all values. It is said:
    "Cannot get to change the"FoldersFileTypes"view information. The "FoldersFileTypes" view isn't a view on a table. »
    While at the same time, it says in its description:
    "View of system on SharedObjects table FrameworkFoldersFileTypes.

    I guess then SharedObjects tables are not considered in tables (DB?). Then the question would be how to access the SharedObjects.

    Alternatively, if anyone knows of the documentation on that?

    Kind regards
    Niels

    The only two possible values are 'owner' and 'soft '.
    'soft' will create a shortcut to the item content link.
    It can be one and only one "owner" a link to a piece of content (consider this canonical location in the folder for the element tree).
    There may be several 'soft' links (shortcuts) for the content item.

  • Is it possible to add more than one constraint for a column?

    Dear team,

    Is there any possible to add more than one constraint for a column?
    I add a unique for a column, but I try to only add is not null for the same coloumn.
    His throws error

    ERROR on line 1:
    ORA-01430: column being added already exists in the table

    Thank you
    Augustine

    You can see here

    SQL>CREATE TABLE test_cons( N1 NUMBER);
    
    Table created.
    
    SQL>ALTER TABLE test_cons ADD CONSTRAINT UK_TEST_CONS UNIQUE(N1); 
    
    Table altered.
    
    SQL>ALTER TABLE test_cons MODIFY ( N1 NOT NULL);
    
    Table altered.
    
    SQL>
    

    Concerning
    Arun

  • XML - a list of possible values for filtering

    Hello world

    I have a bunch of data from AMFPHP to be edited by flex. The data is a combination of data is is attached to various SQL tables. The format is similar to:

    < date = October 10, 2008 ">"
    ... < grade_number rank = "1" >
    ... < name of the subject 'English' = >
    ... < name type = 'homework' >
    ... < input id = "1" >
    ... < entry_e > create new homework < / entry_e >
    ... < date > 10/10/2008 < / date >
    ... < object > 10/10/2008 < / topic >
    ... < Adder > 1 < / Adder >
    ... < / Entry >
    ...

    I used to send these data on an object, and then use a collection of grouping and a filter function to extract relevant data when an opportunity chose the date, subject, category, type. This barely worked and given with the binding problems. I feel, the best solution is to use an EX4 object instead. To do this, however, I need the following information:
    -A list of all possible values for each grade, subject, date and type. These values would then fill controls to choose fields to filter data to allow the user to drill down to the entry they wish to change.

    I'm on the right track with this idea? How do you get a single list of all possible values, you can filter the dataset? It is d ' assign focus in the books about how to filter data with an e4x expression, but little discussion of how to get all possiblve values so that the filter (for example to fill a combo box that lists the possible values)

    In addition, when the data is returned via an e4x expression, is a copy or a pointer to the source data? IE, if I change the data returned, does it also change it in the source data?

    Thank you

    Stone

    I don't know how your application is designed, but does a good job up front in the design data exchange will save you tons of time/bandwidth later.

    In my application, there are semi-static data, driven by the table (for example, tables search db). These data do not change frequently (for example, possible to assign grades a student 'A, B, C, D, F').

    Then, the user starts the questioning of the system (for example, the list of students in a course). In the query result, the information may be changed (for example, assign a student a grade from the menu drop-down). Once all changes have been made, a 'Save' may be issued. A 'Cancel' might pull down new data (i.e., re-run the last query) and reset the visible screen to a non-altered state.

    Quote:
    So from what I understand you query the PB often enough?

    Not really. The initial list of data loading can be slow... but we did things like caching server-side to speed up a bit. This initial list of data is retrieved only ONCE per logon session.

    Queries are short and return summary of results. The entire record of the data extraction is fast enough because things are indexed on the back-end.

    Quote:
    I tried to limit the bandwidth by downloading a copy of the week and then classes allowing the user to "save changes". I'm not too worried about getting a data collision since the classes are unique to each connection.

    Looks like your application protocol design is simple. The user logs and data are extracted by user id. The user updates the data and record visits. Fact.

    In this scenario, if I'm right about your application, I would always break cela in two different HttpService calls to get a sort of simultaneous treatment. A HttpService would be responsible for downloading the data to fill in the boxes on the menu drop down. The other to download the classes for that day there.

    In fact, this raises the question; the user can update the other than just the current day? If so, looks like you will need to allow the user to choose a day, extract the data for this date, allow updates/save, then choose another day to update.

    In this scenario, the separation of the HttpServices is paying off, since the query to extract semi-static data to fill drop-down list boxes is done only once when the user connects to the departure.

    Again, I'm not sure the design of your application, so I talk only through different scenarios.

    Quote:
    Therefore, there is no way to obtain the unique values of the dataset object directly?

    I'm not sure that understand this issue. You would get the values to fill your combo boxes through a HttpService (for semi-static data). It can then return something like:


    ....
    ........ English Spanish Spanglish
    ....

    ....
    ........
    ....

    Then you might have something like:

    I hope this helps.

  • Contact Data Normalizer Cloud Connector - Documentation of possible values?

    I'm testing the connector of normalizer cloud of Contact data for the standardization of title (role, level) job.

    Is there a documentation about the possible values that it can return? Searched around topliners and support without result site. It's a black box.

    Everyone tested out and you to share what they think?

    Although I like the idea of a an easy solution to use, titles of employment for our targets are so all over the map that I probably have to build my own, but this use to take a first pass might the way to go

    I tested this out today on a subset of k title records about 25 that we have in our database. I use the title role and the level standardizations. For some of you (like me) who are eager to see the role and the level of the values here are what I see. Obviously maybe not exhaustive.

    Level values:

    Account Manager

    Assistant

    Level C (including the President)

    Creative Director (even if it is strange, because it shows only on the title of the owner)

    Director

    Executive Vice President

    Director-general

    Individual contributor

    Level unspecified

    Not valid

    Manager

    Senior Vice President

    Vice President

    Role values:

    Academic

    Creative Director (although with the owner)

    Engineering

    Finance

    General

    Health care

    Hospitality

    Human resources

    Information technology

    Not valid

    Legal

    Manufacturing

    Marketing

    Operations

    Editing

    Real estate

    Sales

    Service

    My question is why owner becomes a value of Creative Director for the role and the level?

    Hope that helps some of you out there looking for values.

  • When you use a left and right axis, how to choose what issed axis for the value of y GetGraphCursor?

    I use a graph with a left and right axis (2 data sets).  I try to use a slider to select a point in time (x) and the values of y in the two sets of data.  I can't understand how the control, the value that is returned for the value is when you use the GetGraphCursor call.

    GetGraphCursor (panelHandle, PANEL_GRAPH, yourCursorNumber, & x & y)

    Using SetCursorAttribute with the attribute ATTR_CURSOR_YAXIS must be what you are looking for. The online help for this attribute explains wery well:

    Description: Used to change the y-axis which is associated with the bar graph.
    When a graphics cursor is created, the Y axis with which it is associated is determined by the value of ATTR_ACTIVE_YAXIS.  Subsequently, the association can be changed using ATTR_CURSOR_YAXIS.
    The y-axis associate serves as reference for the coordinates of the cursor position in calls to SetGraphCursor and GetGraphCursor.

  • How can I find and open/search the 32 GB of data that fills the disk for possible deletion?

    Using XP: I have only about 2 GB (2 000 MB) of the programs on my hard drive Go 37 and less than 3 GB of space left.

    How can I find and open/search the 32 GB of data that fills the disk for possible deletion?

    Thank you.

    * original title - full hard drive. *

    Using XP: I have only about 2 GB (2 000 MB) of the programs on my hard drive Go 37 and less than 3 GB of space left.

    How can I find and open/search the 32 GB of data that fills the disk for possible deletion?

    Thank you.

    Download and run JDiskReport.

    There are a number of things you can do to- temporarily - free up disk space.  The only real solution, however, is to get a larger hard drive.

    • You can run Disk Cleanup (start > run > cleanmgr > OK)
    • You can reduce the size allocated for the restoration of the system to about 1 GB (right click on desktop > properties > system restore > settings)
    • You can disable hibernation (if you don't use it) (right click on an empty spot on the desktop > properties > screen saver > power > Hibernate)
    • You can disable the indexing of the drive, which will also speed up your computer a bit (http://lifehacker.com/031440/turn-off-indexing-and-speed-up-windows-xp)
    • You can reduce the size of your Internet browser cache (depending on the browser that you use)
    • You can remove most of the $NTUninstallKBxxxxxx files $ following the directions here: http://windowsxp.mvps.org/Hotfix_backup.htm (read the warnings in the gray box first)

    But none of these answers you will earn really large amounts of space for very long.  The term solution time is a bigger hard drive.

    In the meantime, download and run JDiskReport, that will show you graphically what files take up more space and seem to so indicate what files to delete or uninstall applications.

  • iTunes stopped responding and looking for possible solutions

    Original title: ITune HELP REQUIRED

    I downloaded the latest version of ITunes for Vista (at least 3 x / 2 desktops on the same computer). Whenever I try to access get the terms, and once I did, I get a message "ITunes has stopped responding and looking for possible solutions. The solution is to download the latest version of ITunes.

    Hi Nancy Garrett.

    I suggest you to open Event Viewer and check for more details on the error code.

    Open event viewer

    http://Windows.Microsoft.com/en-us/Windows-Vista/open-Event-Viewer

     

    What are the information in event logs? (Event Viewer)

    http://Windows.Microsoft.com/en-us/Windows-Vista/what-information-appears-in-event-logs-Event-Viewer

    In the meantime, you can also check out the link that has the similar problem of Apple's Support.

    iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits unexpectedly, freezes, or launch issues

    http://support.Apple.com/kb/TS1717

    Let us know the results.

  • 10g BEEP format-number for negative values does not

    Hi all

    I tried the following methods to get the negative number locked up with symbols ().

    1 update the mask of BI Publisher properties of field format to

    "#, # 0.00;(#,##0.00).

    2 tried the Oracle formatting options

    <? format - number:A.INVOICE_AMOUNT; "PT999G999G999G999G999G999G999D00? >

    What gives me the result as below,

    Output value

    23.45 23.45 - print correctly

    -12.90 (12.90 - closing paren "")' does not print

    Please help me get the parenthesis when generating the PDF file.

    Thank you

    I had the question.

    This is the format that was used in your model

    ###,###,###,###,###,###,###,##0.00;(#)

    The first half before; does the mask so no problem.

    But after; which is for negative values and that is not the correct format.

    Please use this format on the properties of form field that gives you good number format

    #, ##0.00;(#,##0.00)

  • FDMEE mapping for a value empty in the cloud of SEEP

    Because we cannot write scripts in SEEP Cloud, how you géreriez mapping for empty values from the source file?

    For example, if the cost center is < white >, map it to C1111.

    You could create a residual mapping, try fundamentally to the scope of all your entity with explicit values, between, multidim, in several parts, such as maps and let the last as mapping to map to C1111.

    For example, if you have 5 entities A, B, C, D, E, you could create 5 explicit as cards:

    A-> E1

    B-> E2

    C-> E3

    D-> E4

    E-> E5

    and a supplement like the (residual) mapping

    *-> C1111

    Note: you must ensure that all other entities of vacuum are covered with your mappings but the residue.

    Hope that helps

  • MEV: Column level of masking - error: ORA-28104: entry for sec_relevant_cols value is invalid

    Hi gurus,

    I try to hide the column to secure the table for a specified user, here are the details of the code that I use to apply security and DB:

    Version of DB: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0

    Security features:

    create or replace function kr_sec_function_papf (p_object_schema IN VARCHAR2,

    nom_objet_p VARCHAR2)

    return varchar2

    as

    p_nid varchar2 (200);

    Whoami varchar2 (100);

    Start

    If SYS_CONTEXT (' USERENV', 'SESSION_USER' ") ="VPDTEST ".

    then

    p_nid: = 'national_identifier = national_identifier';

    return (p_nid);

    on the other

    p_nid: = '1 = 2';

    return (p_nid);

    end if;

    end kr_sec_function_papf;

    /

    Code to add the policy:

    BEGIN

    DBMS_RLS. () ADD_POLICY

    object_schema = > 'APPS,'

    object_name = > "PER_ALL_PEOPLE_F"

    POLICY_NAME = > "secure_emp"

    policy_function = > 'kr_sec_function_papf ',.

    statement_types = > "SELECT."

    sec_relevant_cols = > 'NATIONAL_IDENTIFIER ',.

    sec_relevant_cols_opt = > DBMS_RLS. ALL_ROWS);

    END;

    /

    I get the error message when executing the above plsql block, the error is:

    ORA-28104: entry for sec_relevant_cols value is invalid

    ORA-06512: at "SYS." DBMS_RLS", line 20

    ORA-06512: at line 2

    Someone please help me solve the problem.

    Thanks in advance.

    ~ Krishna Nand Singh

    Hello world

    I had this problem to be solved.

    The problem is with the object_schema-online 'APPS', setting the schema name of the object is 'HR' and APPS a with the same name.

    The Correct code should be:

    BEGIN

    DBMS_RLS. () ADD_POLICY

    object_schema-online 'HR ',.

    object_name-online "PER_ALL_PEOPLE_F."

    POLICY_NAME-online "secure_emp."

    policy_function-online "kr_sec_function_papf."

    statement_types-online "SELECT."

    sec_relevant_cols-online "NATIONAL_IDENTIFIER."

    sec_relevant_cols_opt-online DBMS_RLS. ALL_ROWS);

    END;

    /

    Thank you

    Krishna Nand Singh

  • Report shows a string "null" for null values.

    Hello

    I am new to BI Publisher and creating a report in the BI Publisher. In the game of null values, report prints as "null". I checked the query, it gives data blank (empty value) for null values. But in the report, it comes as value 'null' (string "null"). I need to show the report in the form of empty data for null values. Can you please help me to find the solution for this?

    Thank you much in advance.

    Concerning
    Garza.

    I responded to your cheque send only once.

Maybe you are looking for

  • Firefox PDF reader does not display Watermarks

    Firefox PDF reader shows no watermarks. People can see (and print) my free samples less the watermarks that are in them. for example, in the lauriewilliamsmusic.com/composers/laurie-williams/auld-lang-syne/ Watermarks put in by free PDFill PDF and al

  • 17-e112dx HP: hp 17-e112dx usb does not work

    I install the new Windows 7 64 bit on this computer: HP 17-e112dx. But the USB 3.0 port does not work.What can I do?

  • HP scan multiple pages

    Have been scanning for years using HP Scan.  Have always been able to scan several pages by selecting the button after each scan.  Today, this button "+" is no longer present.  Any thoughts why this would have changed?

  • Games - spider solitaire

    We have 3 computors with windows XP, Vista & windows7, but the only decent version of spider solitaire is the original on XP. Is it at all possible to transfer this version on the two most recent computors?

  • Photosmart C4599 suddenly lost driver

    Tried to print a picture from Photoshop & got the error message saying that, in addition to printing, I have to configure my printer. Printer was working well 4 days ago, I didn't update/update anything that either does not have something new. I trie