How to create unique index on a View

Hi All,
11.2.0.1
How do I create an index on a view or any workaround that my view wont get duplicates?
SQL> create unique index indx01 on db_backup_details_vw(id);
create unique index indx01 on db_backup_details_vw(id)
ERROR at line 1:
ORA-01702: a view is not appropriate here
Thanks a lot,
Kinz

I'm thinking of using a distinct clause here.
if i get 5 duplicate rows in my selection set because of the join condition, can't i discard the remaining 4 using a distinct clause.
Observe this
SQL> select * from a;
T1 T2
1 4
2 4
3 4
SQL> select * from b;
T1 T2
1 4
2 5
in both a,b t1 is the primary key. so we'll write a join on t2 (non PK).
SQL> select b.t1,b.t2 from a,b where a.t2=b.t2;
T1 T2
1 4
1 4 -- duplicates
1 4
Now create view with distinct clause
create view ab as select distinct b.t1,b.t2 from a,b where a.t2=b.t2;
SQL> select * from ab;
T1 T2
---------- ---------- -- no duplicates
1 4
CSM

Similar Messages

  • How to create an indexed field (Duplicates OK) using VBA

    I used the following code to check to see if a field exist and if it does not exist one created. How can I expand this to not only create the field but also create an index (Duplicates OK).
    Regards, Jim
    Sub AddFldSect4_4()
    Call FieldExists("DisplayOrder", "Section4_4")
    End Sub
    Function FieldExists(ByVal fieldName As String, ByVal tableName As String) As Boolean
    Const gcfHandleErrors As Boolean = True
    If gcfHandleErrors Then On Error GoTo Error_Handler
    Dim db As Database
    Dim tbl As TableDef
    Dim fld As Field
    Dim strName As String
    Set db = CurrentDb
    Set tbl = db.TableDefs(tableName)
    For Each fld In tbl.Fields
    If fld.Name = fieldName Then
    FieldExists = True
    Exit For
    End If
    Next
    If FieldExists = False Then
    Call addColumn(tableName, fieldName)
    End If
    Error_Handler_Exit:
    On Error Resume Next
    Exit Function
    Error_Handler:
    MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
    "Error Number: " & err.Number & vbCrLf & _
    "Error Source: Field Exist" & vbCrLf & _
    "Error Description: " & err.Description, _
    vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
    End Function
    Public Sub addColumn(tableName As String, fieldName As String)
    Const gcfHandleErrors As Boolean = True
    If gcfHandleErrors Then On Error GoTo Error_Handler
    Dim strField As String
    Dim curDatabase As Object
    Dim tblTest As Object
    Dim fldNew As Object
    Set curDatabase = CurrentDb
    Set tblTest = curDatabase.TableDefs(tableName)
    strField = fieldName
    Set fldNew = tblTest.CreateField(strField, dbInteger)
    tblTest.Fields.Append fldNew
    Error_Handler_Exit:
    On Error Resume Next
    Exit Sub
    Error_Handler:
    MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
    "Error Number: " & err.Number & vbCrLf & _
    "Error Source: Add Col" & vbCrLf & _
    "Error Description: " & err.Description, _
    vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
    End Sub
    jim neal

    I used the following code to check to see if a field exist and if it does not exist one created. How can I expand this to not only create the field but also create an index (Duplicates OK).
    Hi Jim,
    I give you a couple of examples that I use to create or delete indexes. They are "heavily parametrized", so they can be used for every table using any fields. Study your Help for further information on "Create Index", and others.
    tmp_db.Execute "CREATE INDEX " & cur_veldnaam & " ON " & cur_item & "_tbl (" & cur_type & ")" & " WITH PRIMARY" tmp_db.Execute "CREATE UNIQUE INDEX " & cur_veldnaam & " ON " & cur_item & "_tbl (" & cur_velden & ")" '& " WITH PRIMARY" tmp_db.Execute "DROP INDEX " & cur_keynaam & " ON " & cur_item & "_tbl"
    tmp_db stands for the BE-database; cur_item & "_tbl" represents the table name.
    Imb.

  • Create unique index from duplicate rows

    Dear
    I created an index like
    create index tablename_idx on tablename (FIELD1,FIELD2);
    It should be
    create unique index tablename_idx on tablename (FIELD1,FIELD2,filed3);
    How can I delete those duplicate records and create the UNIQUE index ?
    Thanks and regards
    Fahmed

    > How can I delete those duplicate records
    [url http://forums.oracle.com/forums/search.jspa?threadID=&q=delete+duplicate+records&objID=f75&dateRange=all&userID=&numResults=15]http://forums.oracle.com/forums/search.jspa?threadID=&q=delete+duplicate+records&objID=f75&dateRange=all&userID=&numResults=15
    Regards,
    Rob.

  • ERROR ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found

    Hi,
    SAPSSRC.log
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: START OF LOG: 20071018195059
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: sccsid @(#) $Id: //bas/640_REL/src/R3ld/R3load/R3ldmain.c#12 $ SAP
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: version R6.40/V1.4
    Compiled Nov 30 2005 20:41:21
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe -ctf I C:/temp/51030721/EXP2/DATA/SAPSSRC.STR C:\Program Files\sapinst_instdir\NW04\SYSTEM\ABAP\ORA\NUC\DB/DDLORA.TPL C:\Program Files\sapinst_instdir\NW04\SYSTEM\ABAP\ORA\NUC\DB/SAPSSRC.TSK ORA -l C:\Program Files\sapinst_instdir\NW04\SYSTEM\ABAP\ORA\NUC\DB/SAPSSRC.log
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: job completed
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: END OF LOG: 20071018195059
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: START OF LOG: 20071018195133
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: sccsid @(#) $Id: //bas/640_REL/src/R3ld/R3load/R3ldmain.c#12 $ SAP
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: version R6.40/V1.4
    Compiled Nov 30 2005 20:41:21
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe -dbcodepage 4103 -i C:\Program Files\sapinst_instdir\NW04\SYSTEM\ABAP\ORA\NUC\DB/SAPSSRC.cmd -l C:\Program Files\sapinst_instdir\NW04\SYSTEM\ABAP\ORA\NUC\DB/SAPSSRC.log -stop_on_error
    DbSl Trace: ORA-1403 when accessing table SAPUSER
    (DB) INFO: connected to DB
    (DB) INFO: DbSlControl(DBSL_CMD_NLS_CHARACTERSET_GET): WE8DEC
    (DB) INFO: ABTREE created #20071018195134
    (IMP) INFO: import of ABTREE completed (39 rows) #20071018195134
    (DB) INFO: ABTREE~0 created #20071018195134
    (DB) INFO: AKB_CHKCONF created #20071018195134
    (IMP) INFO: import of AKB_CHKCONF completed (0 rows) #20071018195134
    (DB) INFO: AKB_CHKCONF~0 created #20071018195134
    (DB) INFO: AKB_INDX created #20071018195134
    (IMP) INFO: import of AKB_INDX completed (0 rows) #20071018195134
    (DB) INFO: AKB_INDX~0 created #20071018195134
    (DB) INFO: AKB_USAGE_INFO created #20071018195134
    (IMP) INFO: import of AKB_USAGE_INFO completed (0 rows) #20071018195134
    (DB) INFO: AKB_USAGE_INFO~0 created #20071018195134
    (DB) INFO: AKB_USAGE_INFO2 created #20071018195134
    (IMP) INFO: import of AKB_USAGE_INFO2 completed (0 rows) #20071018195134
    (DB) INFO: AKB_USAGE_INFO2~0 created #20071018195134
    (DB) INFO: APTREE created #20071018195134
    (IMP) INFO: import of APTREE completed (388 rows) #20071018195134
    (DB) INFO: APTREE~0 created #20071018195134
    (DB) INFO: APTREE~001 created #20071018195134
    (DB) INFO: APTREET created #20071018195134
    (IMP) INFO: import of APTREET completed (272 rows) #20071018195134
    DbSl Trace: Error in exec_immediate()
    DbSl Trace: ORA-1452 occurred when executing SQL statement (parse error offset=35)
    (DB) ERROR: DDL statement failed
    (CREATE UNIQUE INDEX "APTREET~0" ON "APTREET" ( "SPRAS", "ID", "NAME" ) TABLESPACE PSAPBW1 STORAGE (INITIAL 44981 NEXT 0000000040K MINEXTENTS 0000000001 MAXEXTENTS 2147483645 PCTINCREASE 0 ) )
    DbSlExecute: rc = 99
    (SQL error 1452)
    error message returned by DbSl:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    (DB) INFO: disconnected from DB
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: job finished with 1 error(s)
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: END OF LOG: 20071018195134
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: START OF LOG: 20071018195314
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: sccsid @(#) $Id: //bas/640_REL/src/R3ld/R3load/R3ldmain.c#12 $ SAP
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: version R6.40/V1.4
    Compiled Nov 30 2005 20:41:21
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe -dbcodepage 4103 -i C:\Program Files\sapinst_instdir\NW04\SYSTEM\ABAP\ORA\NUC\DB/SAPSSRC.cmd -l C:\Program Files\sapinst_instdir\NW04\SYSTEM\ABAP\ORA\NUC\DB/SAPSSRC.log -stop_on_error
    DbSl Trace: ORA-1403 when accessing table SAPUSER
    (DB) INFO: connected to DB
    (DB) INFO: DbSlControl(DBSL_CMD_NLS_CHARACTERSET_GET): WE8DEC
    (DB) ERROR: DDL statement failed
    (DROP INDEX "APTREET~0")
    DbSlExecute: rc = 103
    (SQL error 1418)
    error message returned by DbSl:
    ORA-01418: specified index does not exist
    (IMP) INFO: a failed DROP attempt is not necessarily a problem
    DbSl Trace: Error in exec_immediate()
    DbSl Trace: ORA-1452 occurred when executing SQL statement (parse error offset=35)
    (DB) ERROR: DDL statement failed
    (CREATE UNIQUE INDEX "APTREET~0" ON "APTREET" ( "SPRAS", "ID", "NAME" ) TABLESPACE PSAPBW1 STORAGE (INITIAL 44981 NEXT 0000000040K MINEXTENTS 0000000001 MAXEXTENTS 2147483645 PCTINCREASE 0 ) )
    DbSlExecute: rc = 99
    (SQL error 1452)
    error message returned by DbSl:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    (DB) INFO: disconnected from DB
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: job finished with 1 error(s)
    C:\usr\sap\BW1\SYS\exe\run/R3load.exe: END OF LOG: 20071018195315
    I'm getting this error "duplicate keys found". I'm finished installing the central instance and during the database instance, i got this error. I'm installing BW 3.5 on x64 windows server 2003 platform. I'm using NU kernel 6.40.
    Thanks for your suggestions on how to resolve this error.
    Reward points guaranteed.

    Issue solved by deleting central and database instance and started a new build. it finished without an error.
    Thank you.

  • How to create transaction for a maintenance view, Thank you.

    How to create transaction for a maintenance view,
    Thank you.
    deniz...

    Hi Deniz,
    Go to se93.
    Then create the new T.code.
    Under that select parameter Transaction.
    Then give the sm30 in the t.code in default values tab.
    check the checkbox skip initial screen.
    in classification tab.
    click checkbox inherit gui attributes..
    Now below..
    In the default values..
    select
    viewname and give ur table name.
    UPDATE= Xsave
    view - table name ( Should be upper case
    update X ( should be upper case).
    http://www.sap-basis-abap.com/sapbs011.htm
    Hope this helps you.
    Regards,
    Viveks

  • How to create transaction code for maintenance view

    hai friends,
    i hope every thing goes good.
    i have doubt, how to create transaction code for maintenance view. I created view for tranperant table and now i want to create transaction code for the view.
    i tried and i donot know the screen number and program name and where can i give the view name.
    if any one know please post in details.
    thanks in advance.

    Hi Elam,
    You need to create a "Parameter Transaction".
    What this means is that you will have a transaction (let's call it "ZMAINT") which calls "SM30" and passes in your table name.
    Go to transaction SE93 and enter your new transaction code. Enter in the Tcode description and choose "Transaction with Parameters" (it shouldbe the last radio button).
    Enter in the default transaction "SM30" and tick the "Skip Initial Screen" check box. Hit Enter.
    Now scroll to the bottom of the screen and you will see a Table Control where you will need to enter in the values to the SM30 selection screen.
    Because you hit ENTER, the program will have loaded in the Selection Screen parameters into it's memory. Hit the drop down for "Name of Screen Field" and select "VIEWNAME" and then enter in your Z Table in the "Value" column.
    Now go to the next line and hit the drop down and select "UPDATE" in the "Name of Screen Field". Enter in a "X" in the value column.
    Now save the transaction and there you have it.
    Hope this helps.
    Cheers,
    Pat.
    PS. Kindly assign Reward Points to the posts you find helpful.

  • How to create dynamic connection in business view manager.

    Hi Sir,
    Can u explain how to create dynamic connection in business view manager.
    Thanks
    Vishali Raghava Raju

    HI Vaishali,
       Can you please elaborate your requirement ?
    -Regards
    B

  • How to create a Index for KM documents

    Hi Experts.......
    I have two queries .
    1,How to create a Index for the KM Server documents so that when ever i am in need of particular document,i can be able to retrive the exact document within short time......
    2,What Is TREX? Need of TREX ?
    If any one have documents for the above said queries kindly send it to [email protected]
    Thanks in Advance,
    Jasmine

    Hi Jasmine,
    1.In the EP 6.0 you can create index System Administration -> System Configuration -> Knowledge Management -> Index Administration
    2.TREX is search engine that will proccess the documents that you have specified in the index Data sources when you have created the index.
    The status of TREX you can see in System Administration -> Monitoring -> Knowledge Management -> TREX Monitor or Index Monitor for indexing monitoring.
    If you don't have connected any TREX engine to J2EE, just start the visual administrator and configure the TREX service.
    To install the TREX you can follow the instguides for TREX service.sap.com/instguides SAP Netweaver->Release 04 or 2004s -> Installation -> Cross-NW
    I hope that it helps.
    Bye
    Dan

  • Create unique index on flow table

    Hi
    I always get this error 'Create unique index on flow table ERROR" while implementing SCD2. Please help me.I have made an Update Key which is a combination of 4 columns that want a new row to be inserted if there is a change in data.One of the above columns is the EMPLOYEE ID,
    My surrogate key is the table's primary key but I have not defined it as a key in mapping and also I have turned off the Primary Key Constraint Option in Controls Panel as NO.
    Where am I wrong? Also please tell me what to take care off while making Natural Key ?

    There are two solutions:
    1. Only use uppercase in the table name
    2. go in Topology>Physical Architecture and edit the technology, then click on
    the "Language" tab and set "Object Delimiter" to empty.
    Thanks,
    Sutirtha

  • Create Unique Index On Flow does not work for table names 23 characters

    I have a "create unique index on flow table" step that is dynamically generated by the IKM.
    The index name that is generated by the IKM is based on the table name except that the created index name is prefixed with "I$_" and ends with "_idx". Obviously, since Oracle table names can not exceed 30 characters in length, the index creation step will fail if the base table name exceeds 23 characters.
    I have tried to substring the index name generation step in the IKM so that it only uses the first 23 characters of the table name, but have not had any luck with using the "substring" command together with snpRef.getTable call.
    This is the section of the IKM that I desire to change:
    - <Field name="Txt" type="java.lang.String">
    - <![CDATA[
    create unique index      <%=snpRef.getTable("L","INT_NAME","W")%>_idx
    on          <%=snpRef.getTable("L","INT_NAME","W")%> (<%=snpRef.getColList("", "[COL_NAME]", ", ", "", "UK")%>)
    <%=snpRef.getUserExit("FLOW_TABLE_OPTIONS")%>
    ]]>
    </Field>
    I would like to change the above to something similar to the following (note the only change is the addition of substring(1,23))
    - <Field name="Txt" type="java.lang.String">
    - <![CDATA[
    create unique index <%=snpRef.getTable("L","INT_NAME","W")*.substring(1,23)*%_idx
    on          <%=snpRef.getTable("L","INT_NAME","W")%> (<%=snpRef.getColList("", "[COL_NAME]", ", ", "", "UK")%>)
    <%=snpRef.getUserExit("FLOW_TABLE_OPTIONS")%>
    ]]>
    </Field>
    Any help greatly appreciated. Thanks.

    As the index is temporary, just like the I$ talbel, the easiest way is to replace the table name with some unique identifier like the session is:
    bq. I$_&lt;%=odiRef.getSession("SESS_NO")%&gt;_idx
    If for some reason that is not unique enough, add the NNO:
    bq. I$_&lt;%=odiRef.getSession("SESS_NO")%&gt;&lt;%=odiRef.getSession("NNO")%&gt; \\ _idx                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to create tab indexing for jtextBox

    Dear Forum
    i am user of jDeveloper.
    And working on JClient/Swing application.
    In "Jframe.java" i add various cotrols such as jTextbox,jCombobox ,jlabel etc.
    So how to create tab indexing for these controls.
    Girdher

    Dear Forum
    i am user of jDeveloper.
    And working on JClient/Swing application.
    In "Jframe.java" i add various cotrols such as jTextbox,jCombobox ,jlabel etc.
    So how to create tab indexing for these controls.
    Girdher

  • HOW TO CREATE A CUSTOMER NO (sales view)THAT STOERS IN KNVV TABLE

    HI ,
      how to create a customer no(sales view) that stores in tabel knvv, i able to create in kna1 table but not storing in knvv table, please provide with tcode

    Hi,
    I believe while creating customer you must be maintaining sales area if you are not maintaing then only customer's genaral data will be created and only KNA1 table will be populating.
    Rgds
    San

  • How to create interface where you can view metadata of several databases

    How to create interface where we can view metadata of several databases:
    Oracle Apex should display metadata of this particular DB (later on we can include multiple DB’s)
              a. Report should first display DB name
              b. When clicked on DB name, should display 3 schemas
              c. When clicked on 1 schema, should display tables – when clicked on each table,
              should display various column names and its corresponding metadata.
              (similarly for other schema’s also)
              d. In short, it should be like a drill down report.
    Help required for craeting like above.
    Appreciate your help.

    I did something similar a while back. I had an application reading from multiple schema's for reporting purposes..IN that case atleast we just would build the selects using a function reurning SQL select, so that we could have an application item with the selected schema they wanted to use to build into the select returned...
    For forms, that would be an interesting idea, don't know how you can dynamically change the table owner name, since it is a drop down control in development..
    Thank you,
    Tony Miller
    Webster, TX
    I cried because I did not have an office with a door until I met a man who had no cubicle.
    -Dilbert
    If this question is answered, please mark the thread as closed and assign points where earned..

  • How to create a index on a column with type clob

    how to create a index on a column with type clob

    You should have a look to Oracle Text to check if Oracle Text indexing features can meet your needs:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/cncptdev.htm#CNCPT1537

  • How to create a  index for solution database - CRM5.0

    Hello Experts,
    We want to have knowledge search in our IC web client
    Trex 7.0 is alreasy installed.
    I have done configuration in SAF.Also have created problem/solution in IS01-tcode
    When I tried to compile SDB, I am getting error " 2007 - Index does not exist.
    Can any one tell me how to create a index and how to assign a problem to SDB.
    Regards,
    Indhra.E

    Hi,
    Please ensure the following are correctly configured.
    At IMG location CRM > Enterprise Intelligence > Software Agent Framework
    1. The knowledge base has been configured - "Name and Configure Search Engine".
    2. The knowledge base has been included in application - "Configure Application". The knowledge base should be in both application "ALL" and "ICWEBClient". (SAP note - 1091759 refers to similar error)
    Then, as you might have executed the BSP application, CRM_EI_CMP_ADMN->default page, and select some language & click on Full index.
    You might want to monitor the indexing process in TREX with the help of TREX admin. If nothing is shown in the index queue after the detail compilation shows status as finished, then the problem is in the CRM side and the documents are not flowing to TREX. So you might want to put breakpoint at CL_CRM_SAF_SE_TREX_ABAP classes' FULL_COMPILE method and analyse.
    Kindly get back with any more details that you find if the problem doesn't gets solved.
    Regards,
    Uma.

Maybe you are looking for

  • WiDi on the W520 and Windows 8

    I have W520 and I am trying to get Intel WiDi working on Windows 8. In the past I was using WiDi on Windows 7 with no problems, but since I upgraded to Windows 8 I am unable to get it working. I installed the latest version of PRO Wifi (Wireless_15.5

  • Please, advise mouse-over instant word by word translation for FF9

    in older version of FF I had INSTANT mouse-over the word Google translation add-on, which is not available at FF9 version. It is a huge inconvenience for me (and sure many others) , please advise which add-on has such option? I searched for one for a

  • CREATE SUBREGION IN REPORT

    All, I am trying to create a subregion in a report like the one here if you click http://actionet.homelinux.net/htmldb/f?p=LSPDEMO:3:1618354013978201::NO then under Products tab check the "PLUS/+" details column to see the subregion this is a good sa

  • Queries with Sun Grid Engine

    Hi, Has anyone worked with the Sun Grid Engine (SGE)? I had some queries regarding SGE 1. Does SGE support some kind of Autoscaling? I know that there are commands to add Nodes to Grid dynamically, but does this require the Grid to restart after addi

  • My account is 99% full and won't let me delete pictures/emails to make room.

    When trying to delete, a box pops up and says we have exceeded our quota. I am trying to delete pictures/emails to make room, but it won't let me. If I am over quota shouldn't it be happy I want to delete things and let me?