constraint - maximum one record has the status "active" in a table.

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
PL/SQL Release 10.2.0.5.0 - Production
CORE Production 10.2.0.5.0
AMT for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production

I thank in advance. I have a table like this:


CREATE THE TABLE FIFAPPS. FS_MST_SUPPLIER
(
SUPL_CODE VARCHAR2 (12-BYTE) NOT NULL,
SUPL_STATUS VARCHAR2 (12 BYTES) BY DEFAULT 'ACTIVE' NOT NULL
)

How the constraint such that no more than a supl_code supl_status = 'ACTIVE' table.

For example:

-BELOW IS NOT CORRECT BECAUSE THERE ARE TWO RECORDS WITH SUPL_STATUS = 'ACTIVE '.
sheet 1: (supl_code = '1', SUPL_STATUS = 'ACTIVE')
sheet 2: (supl_code = '2', SUPL_STATUS = 'NON ACTIVE')
record 3: (supl_code = '3', SUPL_STATUS = 'ACTIVE')

-BELOW IS CORRECT BECAUSE IT IS THERE ONLY ONE RECORD WITH SUPL_STATUS = 'ACTIVE '.
sheet 1: (supl_code = '1', SUPL_STATUS = 'ACTIVE')
sheet 2: (supl_code = '2', SUPL_STATUS = 'NON ACTIVE')
record 3: (supl_code = '3', SUPL_STATUS = 'NON ACTIVE')

-BELOW IS CORRECT BECAUSE IT IS THERE HAS A RECORD WITH SUPL_STATUS = 'ACTIVE '.
sheet 1: (supl_code = '1', SUPL_STATUS = 'NON ACTIVE')
sheet 2: (supl_code = '2', SUPL_STATUS = 'NON ACTIVE')
record 3: (supl_code = '3', SUPL_STATUS = 'NON ACTIVE')

Hello

Don't know what you're trying to achieve, but here's a way not to have a single file with the status "ACTIVE".

CREATE TABLE FS_MST_SUPPLIER
(
SUPL_CODE VARCHAR2(12 BYTE) NOT NULL,
SUPL_STATUS VARCHAR2(12 BYTE) DEFAULT 'ACTIVE' NOT NULL
)

insert into fs_mst_supplier VALUES(1,'ACTIVE');
insert into fs_mst_supplier VALUES(2,'INACTIVE');
insert into fs_mst_supplier VALUES(3,'INACTIVE');

create unique index idx_fs on FS_MST_SUPPLIER(case when supl_status ='ACTIVE' then 'ACTIVE' else null end);

insert into FS_MST_SUPPLIER values(4,'ACTIVE'); -- this would fail

Tags: Database

Similar Questions

  • FETCH ONE RECORD IN THE SECOND TABLE OF CORRELATED SUB QUERY

    Hi all

    I have provided the script below, I want to single fecth record in the second table in the join query,

    based on the example below, I want to go get one record of the table emp2 what matches with the emp_id of table emp1, please note emp2 may contain more record for the emp_id emp1 which respects

    all records can be selected in the table emp2.

    DROP TABLE emp1.

    CREATE TABLE emp1 (emp_id NUMBER);

    INSERT INTO emp1 VALUES (1);

    INSERT INTO emp1 VALUES (2);

    COMMIT;

    DROP TABLE emp2.

    CREATE TABLE emp2 (emp_id NUMBER, emp_name VARCHAR2 (100));

    INSERT INTO emp2 VALUES (1, 'Name1');

    INSERT INTO emp2 VALUES (2, 'Name2');

    INSERT INTO emp2 VALUES (1, 'Name3');

    INSERT INTO emp2 VALUES (2, 'Conjoint4');

    COMMIT;

    SELECT * from emp1.

    SELECT * from emp2.

    SELECT T1. EMP_ID, MIN (T2. EMP_NAME)

    FROM EMP1, EMP2 T2 T1

    WHERE T1. EMP_ID = T2. EMP_ID

    GROUP T1. EMP_ID;

    My output should be the same as the result set of query above, but I don't want this logic, please provide the solution by using a different logic, thanks in advance.

    2811876 wrote:

    Thanks for your comments :-)

    My business logic will change to 'Fetch N second timeline table', that's the reason why I asked for a different approach, if I use max, min to achieve this does not allow me to evolve dynamically.

    Although logic has not been expressed at all in your original question, so good job I asked.

    You could do something like:

    SQL > ed
    A written file afiedt.buf

    1 with emp1 (select 1 as the emp_id of union double all the)
    2. Select 2 double
    3               )
    4, emp2 (select 1 as emp_id, 'name 1' as emp_name double union all
    5. Select "name 2' Union double every 2
    6 select 1, 'name' 3' from dual union all
    7. Select 2, 'name 4' double union all.
    8 select 1, 'name 5' from dual union all '.
    9 select 2, 'name 6' from dual '.
    10               )
    11-
    12. end of test data
    13-
    14 select emp_id, emp_name
    15 of)
    16 select t1.emp_id, t2.emp_name
    17, row_number() over (partition by order of t2.emp_name t1.emp_id) rn
    emp1 t1 18
    19 join t2 emp2 (t1.emp_id = t2.emp_id)
    20       )
    21 * where rn<=>
    SQL > /.

    Enter the value for rows_required: 1
    21 Alumni: where rn<=>
    21 news: where rn<=>

    EMP_ID EMP_NA
    ---------- ------
    1 name 1
    2 name 2

    SQL > /.
    Enter the value for rows_required: 2
    21 Alumni: where rn<=>
    21 news: where rn<=>

    EMP_ID EMP_NA
    ---------- ------
    1 name 1
    1 name 3
    2 name 2
    2 name 4

  • no record in the main.active table?

    I just updated my Muse, made some changes to my site and saved. When recording, Muse crashed. Now when I try to open the site I get the message "cannot open this file in the Adobe Muse site. no record in the main.active table? I panic here a little... Please help. Thank you!

    The avalanche of reports of this error in November or in 2013 was due to a bug introduced in 7.0 Muse that has been fixed a week later under article 7.1. (The current Muse, 2015.0.1 equals Muse 12.1.)

    I am puzzled as to how this could happen while doing a backup, unless the file has been changed or renamed by someone else then only on the server? Or you were doing a save as (rather than a backup) over the original on the server?

    Could you send your file from MuseLog.txt to [email protected] as well as a link to this topic to the context? Can provide more information about what happened. Thank you.

  • Muse: message "records in the main.active table.

    Today, I got this message while he was trying to save my file of muse. "No record in the main.active table. Any help would be greatly appreciated.

    And my file will not be saved. I restarted my machine and now the file opens. How can I access this file?

    Thank you very much!

    Please send us the .muse file at [email protected] as well as a link to this topic. If the file is larger than 20 MB, you can use a service like Adobe SendNow, Dropbox, WeTransfer, etc. (if you use a service, please include your email address in the body of the message back, given that not all services to include it in the invite sharing they send.) Thank you.

    I have not seen a report of this error for more than a year and a half. I thought that we had eliminated any means to reach this State. You use 2014.2 Muse?

  • HP C6380 all in one _ does not print because has the status break

    Hello world

    We just bought a printer and we did all the installation as suggested and we could print, but why never the status has been changed to make a break and we do not know how to change it.

    We are able to copy and scan.

    Thanks in advance.

    Xavier and Antje

    Just right click on the printer icon and click resume printing.

  • Help with the query to select only one record from the result set in double

    Hello

    Please help with the query. Version of Oracle database we use is 10g R2.

    I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec

    ID
    Org
    DF
    Sec Sub-Sec

    (163)CQCPDMCPDMHD(163)PCENGENGENG(163)CQASICASICIS8888TSTACTACTAC(163)TSHEHESW6789CQINFOINFOFOS6789PCSECSYSSECSYSINFO16789TSSECSYSSECSYSINFO29009PCBMSBMSBMS1

    My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.

    ID
    DSB

    DF
    SEC
    Sub-Sec
    (163)CQCPDMCPDMHD8888TSTACTACTAC6789CQINFOINFOFOS9009PCBMSBMSBMS1


    Thank you

    Orton

    Hello

    This sounds like a job for ROW_NUMBER:

    WITH got_r_num AS

    (

    SELECT id, DSB, df, s, sub_sec org

    ROW_NUMBER () OVER (PARTITION BY ID.

    ORDER BY org

    ) AS r_num

    OF view_x

    )

    SELECT id, DSB, df, sub_sec s,

    OF got_r_num

    WHERE r_num = 1

    ;

    He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data.  (I know that you said that you were a view selection.  Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.  (I didn't quite understand the explanation above.  I don't know why you want to

    ID ORG DF DRY SUB_SEC

    --      ---     --      ---     -------

    1234 CQ DPRK DPRK HD

    and is not

    1234 IS CQ ASIC, ASIC

    or

    TS 1234 IT IT SW

    or

    1234 CQ ASIC ASIC HD

    )
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • Smartphones blackBerry how to remove the Group BBM that has the status "pending to join...." » ?

    Hello

    I recently changed to the last Bold 9900 of torch.  Since the change, I have a 2 additional icons for my existing BBM groups (Fam & friends).  They have the status of "Waiting to join...." ».  I am able to access these groups and to discuss with members.  However, the 2 additional icons are really bugging me.  Any way to remove them?  I couldn't not remove option for these 2 icons.  Thank you.

    Rgds,

    POH Huat

    Found the solution!  Just delete the application Blackberry Messenger via Options > device > application management.  Once deleted, reinstall Blackberry Messenger via App World.  Alto! 2 additional groups have disappeared!

    Note that you may need your group to withdraw from the Group and invite you.

  • Nested table of object type have only one record all the time

    Hi all

    I have a question regarding the storage of multiple records in a nested Table that is of type OBJECT.

    The program below that I wrote for the test and during the test, I was able to store only the last record in the nested Table.

    Please let me know what I did wrong here.

    Step 1:
    CREATE or REPLACE TYPE book_obj AS OBJECT (name varchar2 (25), author varchar2 (25), abstract varchar2 (4000));
    /

    Step 2:
    CREATE or REPLACE TYPE book_table IS TABLE OF THE book_obj;
    /

    Step 3: CREATE TABLE book (name, varchar2 (25), varchar2 (25) author, varchar2 (4000)) abstract;
    INSERT VALUES Accountants ('Harry Potter,' 'MK', 'It's magic');
    INSERT the book VALUES ("Ramayana', 'VK', 'It is mythiology'");
    COMMIT;

    Step 4:
    declare
    bookset book_table;
    ln_cnt pls_integer;
    Start
    bookset: = book_table (book_obj ('madhu', 'kongara', 'sudhan'));
    dbms_output.put_line (' the number is ' | bookset.) (Count); -> I see COUNT = 1
    bookset: = bookset_t(); -> Assignment to NULL.
    dbms_output.put_line (' the number is ' | bookset.) (Count); -> I see County 0
    for rec in (select * from book) loop-> now a loop twice.
    dbms_output.put_line (' name > ' |) Rec.Name);
    bookset: = bookset_t (book_t (rec.name, rec.author, rec.abstract));
    end loop;
    dbms_output.put_line (' the number is ' | bookset.) (Count); -> I can see COUNT = 1 (why?)
    END;

    I looped twice to fill two records in the TABLE IMBRIQUEE OF TYPE OBJECT. But when I see the Count I get only 1 and the data is also having the last record.

    Can you get it someone please let me know how to fill out the table nested with all records. Tell me where I am wrong.

    Very much appreciate your help here.

    Thank you and best regards,
    NKM

    Maldini says:
    dbms_output.put_line (' the number is ' | bookset.) (Count); -->, I can see COUNT = 1 (why?)

    Because instead of add to bookset collectionto set (ergo replacement) it a collection containing recovered book. Use:

    declare
        bookset book_table;
        ln_cnt pls_integer;
    begin
        bookset := book_table(book_obj('madhu','kongara','sudhan'));
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
        bookset := book_table(); --> Assigning back to NULL.
        dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
        for rec in (select * from book) loop --> Now Looping two times.
          dbms_output.put_line(' name > '||rec.name);
          bookset.extend;
          bookset(bookset.count) := book_obj(rec.name, rec.author, rec.abstract);
        end loop;
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
    end;
    /
    The count is 1
    The count is 0
    name > Harry Potter
    name > Ramayana
    The count is 2
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    Or better use bulk collect:

    declare
        bookset book_table;
        ln_cnt pls_integer;
    begin
        bookset := book_table(book_obj('madhu','kongara','sudhan'));
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
        bookset := book_table(); --> Assigning back to NULL.
        dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
        select  book_obj(name,author,abstract)
          bulk collect
          into  bookset
          from  book;
        for i in 1..bookset.count loop --> Now Looping two times.
          dbms_output.put_line(' name > '||bookset(i).name);
        end loop;
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
    end;
    /
    The count is 1
    The count is 0
    name > Harry Potter
    name > Ramayana
    The count is 2
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • Retrieve all records in the selected master child multi tables

    Hello
    I use JDeveloper 11.1.1.4 version and using ADF - BC in my project.
    I have a one-to-one simple child master [several] in my project.
    In my view page, I display this master child [Ex: EmpVo1-> DeptVo2] in the form of tables.

    I have multi-selection enabled for the main table.
    My requirement is that, on the multi by selecting the lines in the main tables, I want to get all the child records in my grain of support.
    If a master has 3 child records line and another main line has 4 child records and on the selection of several of these two records in the primary table, I should get all the child records in my grain of support.
    I need it to implement the cascade delete feature.
    Here is the sample code coin
    --------------------------------------------

    (1) called on selecting rows in the master table

    {} public void onRSCGrpSelect (SelectionEvent selectionEvent)
    Add the code in the event here...
    ADFUtil.invokeEL ("#{bindings.") RscGroupVO1.collectionModel.makeCurrent} «»
    new class [] {SelectionEvent.class},
    (New Object() {selectionEvent});

    RowKeySet rowKeySet = (RowKeySet) tblRSCGrp.getSelectedRowKeys ();
    CollectionModel cm = (CollectionModel) tblRSCGrp.getValue ();

    for (object facesTreeRowKey: rowKeySet) {}
    cm.setRowKey (facesTreeRowKey);
    RowData = JUCtrlHierNodeBinding
    (JUCtrlHierNodeBinding) cm.getRowData ();
    Line = rowData.getRow ();
    System.out.println ("\n" +)
    row.getAttribute (0) + ":" + row.getAttribute (1) +.
    (":" + row.getAttribute (2));

    System.out.println ("display the child records");
    displayChildRecords (row.getAttribute (0));

    }

    }

    2 private void displayChildRecords (Object rscGrp) {}
    ViewObject rscMapVo = getRscMapViewObj();
    RowSetIterator rsI = rscMapVo.createRowSetIterator (null);
    While (rsI.hasNext ()) {}
    Line = rsI.next ();
    System.out.println ("\n" +)
    row.getAttribute (0) + ":" + row.getAttribute (1) +.
    (":" + row.getAttribute (2));
    }
    rsI.closeRowSetIterator ();
    }

    But the problem is that he is always giving me the last selected lines child details.

    Please suggest the error that I do.

    Thank you
    Praveen

    Your problem is to use makecurrent, which should not be used on a multi selection table. Then, if you have a relationship master detail you should have a view link between them. In this case, you can expose a method as you master to get the related child line. Not need to get the VO itself you can use the accessors of child iterator to obtain registration of the child.

    public void onRSCGrpSelect(SelectionEvent selectionEvent) {
    // Add event code here...
    RowKeySet rowKeySet = (RowKeySet)tblRSCGrp.getSelectedRowKeys();
    CollectionModel cm = (CollectionModel)tblRSCGrp.getValue();
    
    for (Object facesTreeRowKey : rowKeySet) {
    cm.setRowKey(facesTreeRowKey);
    JUCtrlHierNodeBinding rowData =
    (JUCtrlHierNodeBinding)cm.getRowData();
    Row row = rowData.getRow();
    //cast to the right row class
    EmpEmpVoRow empRow = (EmpEmpVoRow) row;
    // now you cann access the child row iterator
    RowSetIterator it = empRow.getDepVO();
    //now you cna iterate over the child rows
    System.out.println("\n" +
    row.getAttribute(0) + " :: " + row.getAttribute(1) +
    " :: " + row.getAttribute(2));
    
    System.out.println("Displaying Child Records");
    //use hte child rows here
    
    }
    
    }
    

    Don't know if the code compiles out of the box (do this on the train :-)

    Timo

  • Cannot open this file in the Adobe Muse site.  No record in the main.active table

    The title says it all.  Well well the error at least. I pulled some search terms in the error message and seem to have no luck through several search engines and of this forum.  HALP!
    Evelyn

    How the file last record? Where it has been stored? Was it ' Save As'ed ' on removable media that was then removed shortly after recording finished, perhaps without first be ejected from the operating system?

    This error indicates that the file is empty (all contents are gone). You will need to return on any backup copy you have. If the file is stored in a synced folder (e.g., Dropbox, Creative Cloud Files, GoogleDrive, Apple iDrive, MS a disk, etc.) these services generally provide access to all the old versions synchronized for a number of days.

  • Why has the status of my friend now show that 'is a follower?

    Why was the location of a changed friend "is an adept" on find it my app friends?  This person is a friend for a long time and I could see the details of the place so far.  Want to know what caused the place to change status.   Thanks - K Montgomery

    No doubt your friend chose to stop sharing their location.

    TT2

  • I can't buy the program because it is said that the direction is not the same one that has the credit card

    I really need to buy some Ae but I can't because the page has problems with the direction of the Bill, but I already 2 programs of CC so I don't understand

    Since this is an open forum, not Adobe support... you must contact Adobe personnel to help
    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific time) <===> NOTE DAYS AND TIME
    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)
    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

  • cannot switch logfiles ensure the status = Active

    Salvation of DBA

    I have tried to create some logic Eve on 10.2 on fedora 6 on manual http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/create_ps.htm#g88234
    I can't create good work standby redo logs.

    ALTER DATABASE ADD STANDBY LOGFILE GROUP 4
    ('/ u01/app/oracle/oradata/ORCL/onlinelog/log4a.log',)
    U01/app/Oracle/flash_recovery_area/ORCL/onlinelog/log4b.log') SIZE 50 M;

    then create the rest of the oder standby and switch logfile:
    ALTER SYSTEM SWITCH LOGFILE;

    When:
    SQL > SELECT GROUP #, THREAD #, SEQUENCE #, ARCHIVED, STATUS FROM V$ STANDBY_LOG;
    GROUP # THREAD # SEQUENCE # ARC STATUS
    4 0 0 YES NO ASSIGNED
    5 0 0 YES NO ASSIGNED
    6 0 YES 0 UNASSIGNED
    What should do?

    Published by: val75 on June 21, 2009 23:08

    Log switch try primay

    Please try to run this command, then open the primary database.

    ALTER database base_de_donnees ensures together to improve performance;

    ALTER database open;

  • Cisco has the more granular dBm lookup table.

    Hello

    It is possible to 1310 bridge wireless signal quality monitoring with snmp?

    Thanks and greetings

    Try CISCO-DOT11-ASSOCIATION - MIB:cDot11ClientSigQuality

    http://Tools.Cisco.com/support/SNMP/do/BrowseOID.do?local=en&translate=translate&objectInput=1.3.6.1.4.1.9.9.273.1.3.1.1.4>

    It is indexed by ifIndex/SSID/Mac.

    In the case where you do not have access to the MIB here are the OID to walk:

    1.3.6.1.4.1.9.9.273.1.3.1.1.3 cDot11ClientSignalStrength

    1.3.6.1.4.1.9.9.273.1.3.1.1.4 cDot11ClientSigQuality

    Example of using Net-SNMP:

    cDot11ClientSignalStrength [1] ['SSIDXXXXXXXXX'] [0:11:92:XX:XX:XX] =-59 dBm

    cDot11ClientSigQuality [1] ['SSIDXXXXXXXXX'] [0:11:92:XX:XX:XX] = Gauge32: 38 percent

  • Why Skype keep going back to the status "available"?

    I'm running a Droid 2 Turbo with OS 5.1.1 on Verizon.
    My version of Skype is 6.15.0.1162
    I am also running Skype on my LG3 tablet, with the same questions.
    As a lurker, I always want to be among the invisible ones, but if someone sends me a message, or I restart one of my devices, I'm 'outstanding' status available so that the rest of the goobers on my contact list can see me, not to.mention family members I've been dodging for years.
    I saw where this was a problem for the desktop version and has been resolved with the last update. Y at - it's going to be a resolution for the mobile version as well, or do I have to find another application that allows me to hide the families feared?

    The statutes on Skype for Android are a mess of rush. An important thing to understand, is the status of the notification icon is completely meaningless. If she says 'Active', it means in fact 'Active', it means «the last time we checked, could be Twitter.com Active»

    Anytime the Skype window is not active or the screen is off, it goes 'inactive', but is not updated the icon and it stops, check his status, so he repeats to me 'Active' even if it is not. The only way to know what your status is, really, is to open the app window - which, after a few seconds, automatically turns the status "Active". This is absurd.

    Only the desktop version offers all control or reliability at all. I recommend to uninstall on Android and use it on desktop. Use other apps reliable messaging to the people you want to communicate with Android. Ask contacts for to add you other applications is a nuisance, but it's worth in the long term. Each version of Skype for Android is less reliable and more opaque than the previous.

Maybe you are looking for

  • iPhone 6s more does not accept the password for the first time

    All of a sudden my iphone 6 s more, will not recognize and accept my password. First screen says: "enter code". "Touch ID requires your access code when you restart the Iphone." Question... is equivalent to a 'code' a 'password'? Why she would accept

  • HP 250 G1, no complete package driver HP please don't help.

    Hello I have 25 machines HP250 G1 that I'm trying to build to Windows 7. HP do not have a pack full driver for Windows 7 32-bit or 64-bit. The pilot collection only I see is for 64-bit Windows 8, so I don't see why another operating system is listed.

  • HP Z240: Z240 can't see my SSD M2

    I have a brand new HP Z240. I installed the SSD in the M2 slot on the shelf and updated the BIOS of 1.27. The Board of directors or the BIOS has not yet seen the SSD. It's a Crucial SSD of 500 GB. Any help would be appreciated. Thank you.

  • Advpack.dll error when you try to install the software

    When you try to install new software I get the following error: "error creating process . "Reason: C:\WINDOWS\system32\advpack.dll ' any idea how to deal with this problem?  XP Pro SP3.

  • How can I contact Acer for a replacement for my new office keyboard?

    I bought my computer on January 1.  The keyboard was defective from the beginning - the hyphen / sign less keypad has a life of its own. It fills my password window when that I start, and yesterday a document open text had pages of hyphens.  I got it