Unable to understand the syntax index

Hello
I can't understand the meaning of the following syntax to index... and how it works
CREATE UNIQUE INDEX X_GRS_DMSC_U02 ON Ta_GR_MSC
(DECODE("GR_TP",'U',NULL,"ON_ID"), DECODE("GR_TP",'U',NULL,"GRS_MSC"))
Why the syntax above is used... And how does it work?

Could you please update me as soon as possible...

It looks like a basic index function. It is designed to ensure that there is a unique combination of the columns 'ON_ID' AND 'GRS_MSC', if the value in the "GR_TP" column is not equal to "U".

I will try to create the 'TA_GRS_MSC' table and apply the index to illustrate the above as follows:

SQL> create table ta_gr_msc (gr_tp varchar2(10),on_id varchar2(10), grs_msc varchar2(10));

Table created.

SQL> CREATE UNIQUE INDEX X_GRS_DMSC_U02 ON Ta_GR_MSC
  2  (DECODE("GR_TP",'U',NULL,"ON_ID"), DECODE("GR_TP",'U',NULL,"GRS_MSC"));

Index created.

SQL> insert into ta_gr_msc values ('U','1', '1');

1 row created.

SQL> insert into ta_gr_msc values ('U','1', '1');

1 row created.

SQL> insert into ta_gr_msc values ('X','1','1');

1 row created.

SQL> INSERT INTO TA_GR_MSC VALUES ('X','1','1');
INSERT INTO TA_GR_MSC VALUES ('X','1','1')
*
ERROR at line 1:
ORA-00001: unique constraint (USER01.X_GRS_DMSC_U02) violated 

SQL> INSERT INTO TA_GR_MSC VALUES ('X','1','2');

1 row created.

As noted above, when the value in the column 'GR_TP' is equivalent to 'U', you can insert any combination of the values in double columns 'ON_ID' and 'GRS_MSC '. However, if the value in the "GR_TP" column is not equal to 'U', you get a unique constraint exception when you try to insert values in double columns 'ON_ID' and 'GRS_MSC '.

I hope this helps.

Tags: Database

Similar Questions

  • Can someone help me how to understand the syntax of a calculation in a form Acrobat?

    For the first time I have created a PDF form for the child summer camp brochure. After countless hours I was able to figure out how to make some simple calculations (number of sessions of camp price subtotal = x). But I can't understand how to create a script that will take partial total revenue and generate a number which corresponds to 10% of the subtotal. All I want to do is have a separate field (reduction), which can reference the subtotal, and if it's over $ 170.00, calculates and displays a number which corresponds to 10% of this amount. From there, I can understand how to subtract 10% of the subtotal, but I can't understand the syntax for the calculation of the 10%. Also I don't know if that should be entered in the Notation of Simple box field or calculation Script custom area to calculate in the text field properties box. Any help would be greatly appreciated!

    You must use JavaScript. It would be something like:

    Personalized to discount field calculation script

    (function () {}

    Get the subtotal value, as a number

    var = subtotal + getField("Subtotal").value;

    Set the value of this field

    If it is greater than 170, calculate 10%, otherwise it is zero

    Event.Value = subtotal > 170? 1 * subtotal: 0;

    })();

    This last line is equivalent to:

    If {(subtotal > 170)

    Event.Value =.1 * subtotal;

    } else {}

    Event.Value = 0;

    }

    It's just more compact.

    Replace "Subtotal" in the line of getField above with the actual name of the subtotal field. Also, set all the fields calculated read-only. And make sure the field calculation order is correct.

  • Unable to understand the code output

    Hi all

    I was reading one of the codes and unable to understand its outcome, I'm really grateful if someone guide me to understand. Thanks in advance.

    Code example

    create or replace package Mp_pkg

    IS

    P_nn TYPE TABLE IS NUMBER

    INDEX BY VARCHAR2 (10);

    END;

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

    DECLARE

    l_numbers Mp_pkg.p_nn;

    Start

    FOR indx IN 1... 50

    loop

    (indx) l_numbers: = indx;

    END loop;

    dbms_output.put_line (l_numbers. (Last);

    END;

    ----------

    Result

    9

    -----------

    According to my understanding, result should be 50 because the last value of l_number is 50...

    Please guide...


    Hello

    As John said, the VARCHAR2 '9 ' (or any string '9') is longer than the string of 50', for the same reason that the string 'Z' is longer than the string "THE".

    What do we mean when we say this string x is greater than string y?  We mean that

    1. The 1 x chraracter comes after the 1st character of y (in sort order), or, if these characters are equal
    2. x has a 2nd character, but is not, or, if both are more than 1 character
    3. The substring SUBSTR (x, 2) > SUBSTR (y, 2)

    What (if any) strings mean is not serious, so

    • '9' is greater than '50',
    • 'zero' is greater than 'a '.
    • 'small' is greater than 'big '.
    • 'MIN' is greater than 'MAX '.
    • 'yesterday' is greater than 'tomorrow', and
    • "1 January 1900' is superior to" December 31, 2015 ".

    According to rule 1 Correction: rule 3 is the reason why 'MIN' is greater than 'MAX '; the others are all due to rule 1

  • Unable to understand the output...

    Hi gurus

    I was reading a little code and unable to understand a single line, can someone guide me to understand this line.

    Code example

    Set serveroutput on

    DECLARE

    n number;

    BEGIN

    n: = 2 * 33.

    dbms_output.put_line (n);

    end;

    Result

    8589934592


    Now, I would like to know how the calculation performed for n: = 2 * 33 in the background so it become 8589934592 result. Thanks in advance.

    One of these curiosities PL/SQL in SQL vs. In PL/SQL * is same as it is built based on POWER. 2 * 33 is identical to POWER (2.33). It is documented in the Precedence of the operators:

    Table 2-3. precedence of operators

    Operator Operation

    **

    Exponentiation

    SY.

  • Unable to understand the result of the loop


    Hi all

    I got the tracking code:

    Code

    Set serveroutput ON

    DECLARE
    TYPE IS VARRAY months_array (12) STRING (3 CHAR);
    MONTHS months_array: = months_array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
    BEGIN
    < < list_month > >
    FOR month number IN REVERSE 6.12
    LOOP
    dbms_output.put_line (' number month = ' | number month |) "Items =' | MONTH (MONTHNO));
    CONTINUE list_month
    WHEN number month < 9;
    END LOOP;
    END;

    Code output

    number months = 12 = Dec

    number month = 11 = Nov

    number months = 10 items = Oct

    number month = 9 elements = Sep

    number month = 8 = August

    number month = 7 cells = Jul

    number months = 6 items = Jun

    My question is if you notice the code condition which is CONTINUE list_month number months WHEN < 9 means loop must be output if number month < 9 and according to code loop starting with number months = 12 so system should display the 1st line of output that is number months = 12 elements = Dec , then exit because the loop exit condition is true that is list_month MORE WHEN number month < 9. Please, help me to understand the output.

    Hi Muzz,

    try something like this

    BEGIN
      FOR monthno IN REVERSE 6..12
      LOOP
        exit when monthno < 9;
        dbms_output.put_line('monthno= '||monthno||' Elements='||MONTH(monthno));
      END LOOP;
    END;
    

    concerning

    Kay

  • Unable to understand the Plan to explain

    Hi gurus

    I'm trying to understand some basics of explain plan and get a hard time, I was reading the book tuning performance and incapable of understanding explain plan for the following query:

    Example query

    EXPLAIN PLAN FOR

    SELECT *.

    WCP

    WHERE THERE IS NOT (SELECT 0

    OF THE Department

    WHERE dept.dname = 'SALES' AND dept.deptno = emp.deptno)

    AND NOT EXISTS (SELECT 0

    Bonus OF

    WHERE bonus.ename = emp.ename);

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

    Select * from table (dbms_xplan.display);

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

    Output

    Hash value of plan: 734347697

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    |   0 | SELECT STATEMENT |       |     5.   290.     7 (15) | 00:00:01 |

    |*  1 |  HASH ANTI JOIN |       |     5.   290.     7 (15) | 00:00:01 |

    |*  2 |   HASH ANTI JOIN |       |     5.   255.     5 (20) | 00:00:01 |

    |   3.    TABLE ACCESS FULL | EMP |    14.   532.     2 (0) | 00:00:01 |

    |*  4 |    TABLE ACCESS FULL | DEPT |     1.    13.     2 (0) | 00:00:01 |

    |   5.   TABLE ACCESS FULL | BONUS |     1.     7.     2 (0) | 00:00:01 |

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

    Information of predicates (identified by the operation identity card):

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

    1 - access("BONUS".") ENAME "=" EMP ". ("' ENAME ')

    2 - access("DEPT".") DEPTNO "=" EMP ". ("' DEPTNO ')

    4 - filter("DEPT".") DNAME "= 'SALES')

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

    Grateful if someone help out me. Thank you

    In addition, I really appreciate if someone proposes a simple tutorial to explain plan. Thanks again

    Concerning

    Shu

    Hi Shuumail,

    Here is the tutorial http://allthingsoracle.com/execution-plans-part-1-finding-plans/

  • Unable to understand the original clause


    Hi gurus

    I tried to understand what follows where the clause, but still facing problem to understand that and I really appreciate if someone explain it to me step by step and in detail. Thanks in advance:

    Where Clause

    NOT the CASE (min_age = min_min_age

    OR (min_age - 1, rule_id, status_code)

    IN (SELECT max_age, rule_id, status_code

    OF got_analytics

    )

    )

    Concerning

    Shu

    not ( -- simple
      min_age = min_min_age  -- simple
      or -- simple
      (min_age-1, rule_id, status_cod) in (select max_age,rule_id,status_cod from analytics) -- complex
    )
    

    Description for COMPLEX line

    The triplicate (min_age-1, rule_id, status_code)

    must match one of the Geometry produced by:

      (select
          max_age,rule_id,status_code -- your triplicate
        from analytics)
    

    You'll have to check that my logic, but I think that the 'complex' line can be re-written as a clause EXISTS

    EXISTS ( select null
             from analytics A
             where A.max_age = X.min_age - 1
               and A.rule_id = X.rule_id
               and A.status_code = X.status_code )
    

    MK

  • explanation of the syntax of reminder

    Forgive my beginner questions.

    I am trying to understand the syntax of the callback functions that are auto-insérée in my source of CVI.  I'm not entirely understand what's the point of "CVICALLBACK" in front of my name of callback function.

    int CVICALLBACK ControlCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
    

    I dive into cvidef.h, I see that it is defined as CVICDECL, which in turn is defined as __cdecl, which is apparently a "calling convention".  So CVICALLBACK is just a secondary typedef for the callback function?

    You were right from CVICALLBACK to the convention corresponding appeal. The calling convention is a very technical beast to explain, unless you are particularly interested in him (for example because you want to / have to build DLLs to be used ion other compilers or symmetrically, you can use the DLL created in other languages) you can simply ignore it and happily live and work with CVI

    However, information about the calling convention can be easily found on the internet: here and here two wikipedia pages on the subject, so that here , you will find a page of knowledge base specifically oriented CVI

  • Spreadsheet Excel add after the syntax

    I have a large application that creates a report following a test.  The report is about 250 pages, each page represented as a group in the data portal.  When we deliver him customer report also wants an excel file with pairs of X - Y data for each of the graphs in the report.  I know how to make the selection of the data and copy/paste it to Excel.  Where I encountered problems, that's when I add worksheets in Excel, I can't figure out how to run the new worksheet to add at the end.

    According to the news on Excel VBA, there are parameters before and after that should allow you to do.  I can't quite understand the syntax to include these parameters.  The line of code in question is red.

    If you have nothing but the. Add the statement that the code works but the worksheets appear in reverse order.  I tried a number of different ways, and the script just dies without even showing an error.  I know one around which we work to scroll the list of the groups back, but that's not fair to sit well with me.  I prefer to do things in a logical manner, being from the first to the last.

    If there are questions please let me know.

    Thanks in advance.

    Wayne

    FilePath = autoactpath & "\dataoutputtemplate.xls".

    ExOpen = True
    Nomclasseur = NameSplit (FilePath, "N") & ".". XLS '.
    On Error Resume Next
    Set Excel = GetObject (, "Excel.Application") ' get Excel via OLE if it is already open
    If Err.Number <> 0 Then
    Err.Clear
    Set Excel = New ' start Excel via OLE
    If Err.Number <> 0 Then
    ' Exit Sub
    End If
    ExOpen = False
    End If
    Excel.Visible = true
    IsWorkbookOpen = Excel.Workbooks (WorkBookName) there's nothing = False
    If ExOpen then
    If not IsWorkbookOpen then
    Set ExcelWkb = Excel.Workbooks.Open (FilePath) ' open the Excel file if it isn't already
    End If
    on the other
    Set ExcelWkb = Excel.Workbooks.Open (FilePath) ' open an Excel file from excel is not already open
    End If
    Err.Clear
    On Error Goto 0

    GrpStart = GroupIndexGet ("Globals")
    NumGrp = GroupCount - GrpStart
    ReDim PageList (NumGrp)
    ReDim SectList (NumGrp)
    b = 1
    c = 1
    for a = GrpStart to GroupCount
    CurGrpName = GroupPropValGet (a, "name")
    If InStr(CurGrpName,"List") then
    SectList (b) = Mid(CurGrpName,5) ' remove 'List' in the name of the group to be used in the Table of contents
    b = b + 1
    End If
    If InStr(CurGrpName,"_") then
    PageList (c) = CurGrpName ' Gets a list of groups that should be exported
    c = c + 1
    End If
    Next "(a cycle through groups can gather names)
    ' Add the Table of contents: sheet in workbook
    Set ExTOC = Excel.Workbooks (WorkBookName). WorkSheets.Add
    ExTOC.name = "Table of contents".
     
    For d = 1 to c - 1 ' c is the number of valid sheets in the report which will be exported
    Set ExcelSht = Excel.Workbooks (WorkBookName). WorkSheets.Add (after: = last sheet in the workbook)
    ExcelSht.Name = PageList (d)
    Next would then report to export page

    Hello Wayne!

    What you need to know, is that you can leave empty parameters. The solution to your problem is:

    Set ExcelSht = Excel.ActiveWorkbook.WorkSheets.Add (, Excel.ActiveWorkbook.WorkSheets (Excel.ActiveWorkbook.WorkSheets.Count))

    Matthias

  • How to understand the format of hyperic shell command line?

    I logged on the hyperic shell and I just wanted to check on the orders and their
    output.  Im having trouble understanding the syntax I do a list alert and get:

    alert list
    org.hyperic.util.shell.ShellCommandExecException: error getting alerts
    In undeclared throwable was: java.lang.ClassNotFoundException: org.hibernate
    .collection. PersistentBag (no security manager: RMI class loader disabled)

    When I use the "list alertdef" command it comes back with: ""
    list of alertdef <-group | -plate-forme | -Server | -service > < resource > [-activated |-disabled]

    Replace - platform with linux - say? or a particular computer Devils name
    what they are referring to with resource? is the agent HQ a resource?

    What is necessary and what is not. . Cant seen to get anything to work.
    An example of this command is all I need.

    You will see many orders with a syntax similar to the alertdef list.  You
    do not replace the '-' keywords with anything, it has the 
    that you would replace it.  The can be the ID of the
    resource (if you know it) or the name (use quotes if there is)
    (spaces).  For example, I can do:

    alertdef list - server 10001

    or

    list of alertdef - HQ Agent server 'hq.hyperic.com '.

    In addition, as shown in my example, the central administration Agent is indeed a resource.
    It is a server.

    Charles

  • Siebel Database Configuration Assistant unable to identify the indexes tablespace

    Hello

    I install Siebel CRM 8.1.1 on AIX platform. We have a RAC database has allowed the backend and that two tablespace is created, other data and another for the index. Now in the wizrd of configuration database to the name of these two storage spaces; provide us with the name of tablespae of data in the Tablespace filed Table and index tablespace in the tablespace index rating of the Setup Wizard. Now when we click on the next button. The wizrd of configuration gives error of unable to identify the indexes tablespace.

    Why is - what happens as index tablespace is correctly created in the database. Please help me in this. Quick Respance you will be appreciated.

    Kind regards

    Abgrall

    If you ran:

    change the quota unlimited on user SIEBEL

    ?

  • Error during indexing account administrator-"the user profile Service has no logon. Unable to load the user profile.

    Original title: I can't connect to my admin account
    Windows 7 - whenever I try to login on my admin acc it appears ("service user profile Service does not have the logon - user profile cannot be loaded") and do not know what that could have been and how to solve this problem, I have not tried anything yet if someone can please help me. I also connect to a standard ACC and cannot do anything because when he asks me my admin pass I put it in and nothing happens.

    Hello

    This error can occur if the group policy setting "do not connect to users with temporary profiles" is configured.

    Run the diagnostic tool for Fixit for the article mentioned below and if it solves the problem.

    Error message when you log a computer Windows Vista-based or Windows 7 by using a temporary profile: "the user profile Service has no logon.
    Unable to load the user profile.

    http://support.Microsoft.com/kb/947215

    Let me know if you need more assistance.

    Kind regards
    Afzal Taher-Microsoft Support.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • updated Mac and now I am unable to answer the phone calls of the Mac

    Yesterday I updated my Mac to the new operating system.  Since then, I could not pick up calls from the Mac as I used to.

    Can someone tell me how to solve this problem?

    Hi jlfrisella!

    I see that you are unable to use the calls feature cell phones iPhone on your Mac since the update to Mac OS Sierra.  I can understand wanting this function runs on the right, and I'm happy to help you.  Please see requirements and instructions in the following articles.

    Continuity of use to connect your Mac, iPhone, iPad, iPod touch and Apple Watch

    Thank you for using communities of Apple Support.

    See you soon!

  • Warning about bad connections contains no option "I understand the risks", I can't move on

    I install Thunderbird on Windows 8.1. I am trying to add 3 accounts. When adding the second account that Thunderbird has warned by transmitting unsecured password. I clicked on "I understand the risks". No problem. When I tried to add my third account, I received the warning again, but this time there was no other choice, "I understand the risks". I can't click on 'Done', if I change the parameter that TB can not find servers. I'm stuck and unable to add my last story.

    I installed on my laptop that runs Windows 7 TB and had no problems. I use the same settings as in my version of TB on my laptop. The version of TB is 24.4 on both machines. Of course, the version of TB was younger, when I installed on the laptop.

    Thank you, in advance, for any advice.

    Bill Halteman

    If I wanted to get the certificate warning when connecting to my email provider's e-mail server, I would like to seriously check the offered certificate. There should be no exceptions to this need in the first place.

    Certificates are there for a purpose, and is not simply to add an exception when it does not work.

  • "I understand the risks" missing option - page is read from cache

    trying to access the Web site, I am facing a security warning because the certificate is self-signed.
    This is an internal site, which is currently the subject of tests - so it's ok to add an exception.
    the question is, the option to select "I understand the risks" is totally absent, the only available action is "get me out of here"

    Since it is an internal site under our control, I did a few tests more:
    It seems that firefox redirects the initial http request to https
    This does not happen on other browsers (chrome and IE), also tested in a clean install of firefox running without the extensions.

    even after completely cleaning the cache and temporary files, question remains.
    This site (over http) does not load on firefox, always redirected to https

    even after deleting the server mod_ssl apache and by eliminating completely any mention of the ssl on that server, connection with firefox always redirects http to https (now results in the error "Unable to connect to Server" - but still not to load the basic site http version)

    Amir.

    I forgot the screenshot of SQLite Manager.

Maybe you are looking for