How to findby unique key

Hi,
for CMP, we have findByPrimaryKey, I'm wonding how to implement a findByUniqueKey.
Can any idea?
Thanks
John
Toronto

ejb-ql: SELECT object(o) from ejbTable as o WHERE o.a=A AND 0.b=BThanks lots, but can u tell which one
A.WHERE o.a=A AND 0.b=B
B.WHERE o.a=?1 AND 0.b=?2
is more recommanded and their difference?
John
Toronto

Similar Messages

  • How to use Unique key constraint in EJB

    Hi All,
    I am using an entity bean to create my table in MySQL4.1.13
    I have a table called user which has userid,username,password as its columns.
    The userid is a primary key over here.
    But I want the user name to be unique.
    I.e if a user with the name 'Adrian' is present in the database then another user with this user name should not be created.
    I have been told that you can configure a unique key in jbosscmp-jdbc.xml using insert-after-ejb-post-create.
    But i dont know how to use it.
    Can anyone give me a sample code for using this.
    Any help would be appreciated.
    Thanks
    P2

    Please explain your problem better. Really can't figure what you are trying to do.....
    choosing which sql statement to use at runtime
    or creating dynamic sql statement at runtime
    which??
    Regards

  • How to manage unique key ?

    My table has a unique key ... but OWM prevents version enabling
    of a table which has a unique key.
    Before version enabling the unique key means: a same value
    cannot be used twice.
    After version enabling it should mean: a same value cannot be
    used twice at the same time .
    How to manage such a situation ?
    Thank you.

    Workspace Manager currently does not support versioning of tables
    that contain unique constraints. There is some confusion in
    defining what is unique in a multi-version system. Is it unique
    in a branch of versions or does it have to be unique in the
    entire system?
    We plan to address this in the next release. In the meantime, we
    welcome your suggestions. Also, I am interested in knowing the
    application context in which you are using Workspace Manager.
    thanks
    Arun

  • How to control unique key target table mapping!

    Hi all,
    Is there any way to map a source table to target,the source table contains some duplicate rows,and only one of them is needed for the target table,can OWB manage to insert only one of these duplicate rows and ignore other rows according to an unique key and continue to execute the map?
    Thanks in advance!

    If you have duplicates and want to filter them out, try creating a view on the target table and use the rownum() function in the view.
    Than in your mapping use this view as you source and put a filter on it where the rownumber = 1. This will only select the unique records.

  • How to give unique key?

    am working with abap dictionary. i have an independent field in my child table that is supposed to be not null and unique. Instead of making it as a primary key field, is there any other way to set these constrains to that field?

    If unique you can go for primary key.
    How are you going to update this table ?
    if its through maintennace then add a validation in table maintenance events. Or try changing the screen layout property as required ( not sure abot this )

  • How to create unique key column in ROLAP fact table?

    Hi all,
    Is there a way to create a single column primary key (or unique index) on my ROLAP cube (and fact tables) in OWB? if so, what I should do in my mappings?
    Thanks!
    - Andrew

    Have you all conformed dimensions between the two facts?

  • How to Check Unique key for a Column in Many to Many relations ship

    senario
    Master Table
    CODE DESC
    ACT1 DESC1
    ACT2 DESC2
    ACT3 DESC3
    Detail Table
    CODE REFF_CODE DESC PRIORITY
    SACT1 ACT1 SDESC1 1
    SACT2 ACT1 SDESC2 2
    SACT3 ACT1 SDESC3 3
    SACT4 ACT1 SDESC4 4
    SACT5 ACT1 SDESC5 5
    SACT6 ACT2 SDESC6 1
    SACT7 ACT2 SDESC7 2
    SACT8 ACT2 SDESC8 3
    SACT9 ACT2 SDESC9 4
    SACT10 ACT3 SDESC10 1
    SACT11 ACT3 SDESC11 2
    SACT12 ACT3 SDESC12 3
    OUTPUT REQUIRED
    PRIORITY COLUMN MUST BE UNIQUE FOR EACH MASTER RECORD IN DETAIL TABLE...
    PLS HELP ME IN THIS REGARDS,

    I am a little bit slow today ...
    You want achieve this being updated in detail table ?
    Detail Table
    CODE REFF_CODE DESC PRIORITY
    SACT1 ACT1 SDESC1 1
    SACT2 ACT1 SDESC2 1
    SACT3 ACT1 SDESC3 1
    SACT4 ACT1 SDESC4 1
    SACT5 ACT1 SDESC5 1
    SACT6 ACT2 SDESC6 2
    SACT7 ACT2 SDESC7 2
    SACT8 ACT2 SDESC8 2
    SACT9 ACT2 SDESC9 2
    SACT10 ACT3 SDESC10 3
    SACT11 ACT3 SDESC11 3
    SACT12 ACT3 SDESC12 3
    ?

  • How shall we do validation for Unique Key and Multiple Primary Key?

    Hi,
    I have table created From EO in which one column is checked as Unique.
    How to do validation for column checked as Unique.
    I know how to do validation for column checked as primary key.
    Below is sample code for primary key validation
    if (getRvSize() != null)
    throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
    getEntityDef().getFullName(), // EO name
    getPrimaryKey(), // EO PK
    "RvSize", // Attribute Name
    value, // Attribute value
    "AK", // Message product short name
    "FWK_TBX_T_EMP_ID_NO_UPDATE"); // Message name
    if (value != null)
    OADBTransaction transaction = getOADBTransaction();
    Object[] rvKey = {value};
    EntityDefImpl rvDefinition = xxczVAGCSRVSizingEOImpl.getDefinitionObject();
    xxczVAGCSRVSizingEOImpl rv =
    (xxczVAGCSRVSizingEOImpl)rvDefinition.findByPrimaryKey(transaction, new Key(rvKey));
    if (rv != null)
    throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
    getEntityDef().getFullName(), // EO name
    getPrimaryKey(), // EO PK
    "RvSize", // Attribute Name
    value, // Attribute value
    "AK", // Message product short name
    "FWK_TBX_T_EMP_ID_UNIQUE"); // Message name
    What changes need to be done for above code in order to do the validation for Unique Key.
    I have one more Question
    How shall we do the Validation for Multiple Primary Key in a table?
    - Mithun

    1. If you just validate on one attribute like your unique key, then put your logic in the set<Your AttributeName) method
    2. If you want to do the cross validation ( like validating multiple attributes) then put your logic in the validateEntrity Method
    How to do that?
    1. Create a Validation View object.
    2. Associate your VVO to the VAM
    3. Create entity expert.
    4. Have method in entity expert for your validation (you would be calling AM and then VO execute the query and do the validation.
    5. You would be calling the Entity experty method from your EO either setMethods or validateEntity.
    I have given just the high level points.
    Hope this helps.
    Thanks,
    RK

  • How to create a unique key using two or more attributes?

    how to create a unique key using two or more attributes ?

    The following example illustrate how to create a unique key using two or more attributes/fields
    Scenario: Implementing Unique Key on ManagerID & Location ID in DepartmentEO(Department Table)
    Step#1: Open the Desired Entity Object “DepartmentEO”. Go to Overview tab & Click “General” Finger tab.
    Step#2: Expand “Alternate Keys” section & click “+”.
    Step#3: In the Pop-up wizard, Enter a name for alternate Key “Unique_Manager_X_Location”.
    Step#4: Select the desired attributes/fields from available list & Shuffle to right side.
    Step#5: Now go to “Business Rules” finger tab.
    Step#6: Select “Entity Validators” in the list & click “+” to add a new entity level validation rule.
    Step#7: In the Pop-up, Select “Rule Type” as Unique Key
    Step#8: In the “Rule Definition” tab select the key “Unique_Manager_X_Location”created.
    Step#9: Now go to “Failure Handling” tab, and click the Magnifier Icon .
    Step#10: If the key is not already created then in the “Select Text Resource” Popup, Using the functional design document, Enter display value, Key and Description. And click “Save & Select” Button.
    Step#11: Now Click “OK”.

  • How to generate a Unique key based on a some String value

    Hello every one,
    I am sorry , If I post this question in wrong group... I have a requirement to generate a unique key ( what every it may be alpha, numeric or alpha numeric) based on some String..
    For ex : String str = "AbCX" - Gives a unique key based on "AbCX" value..
    Is there any way we can get the unique value using Java ?
    Thanks

    May be not what you are looking for, but here's may idea:
    use a sequence (db sequence) and add it the the string value. This way the value is unique, because the sequence is unique. So you could omit the string theoretically, but your requirement is met.
    It's very easy to get a unique sequence number from the db using java, depending of the technology you use (which you did not say :-( )
    Timo

  • How can I run a check for a record across other records in the same dataset based on unique key constraint?

    Dear community,
    I have a flat data set which I run through a lookup and return. I want to check if at least one of the records matching a unique key constraint had a successful return without merging all the records. Can some one point me in the right direction?
    Thanks!
    Marc

    Hi,
    Sounds like a job for the Lookup Check processor!
    As with all check processors, it adds a flag attribute (with a Y/N value) that denotes if the lookup was successful or not, as well as filtering records based on this at output.
    Lookup Check does the same as Lookup and Return but does not return the record(s) looked up.
    Also note that Lookup and Return does not actually merge records, but it does pull back the return data (which you can then split if you want a record for each).
    Regards,
    Mike

  • How to Get the Unique Key results from OWB Tables after Profile

    Hi,
    We are using OWB 10gR2(Paris) Beta Version.
    In this version the new feature is introduced is Data Profiling.
    We are using this feature to analylize the data in terms of stanadards.
    We have done profiling for our tables and we are able to see the results for each table in OWB Profile Results Canvas. In this window one Unique Key tab is there to see the Unique results.
    Now my question is where these results will be stored in standard tables of OWB. I want to know those exact standard tables to extract thoes Unique results in to my reports.
    After profiling we are generating HTML-DB reports to view all these profile results. But we are not able to find the Uique Key tables where these results are stored.
    So pls can anybody provide help on this to get these tables...
    Thanks in advance...,
    Ramesh P.

    You can use DatabaseMetaData#getPrimaryKeys.

  • How about use partial key to loop at a hashed table?

    Such as I want to loop a Internal table of BSID according to BKPF.
    data itab_bsid type hashed table of BSID with unique key bukrs belnr gjahr buzid.
    Loop at itab_bsid where bukrs = wa_bkpf-bukrs
                              and    belnr  = wa_bkpf-belnr
                              and    gjahr  = wa_bkpf-gjahr.
    endloop.
    I know if you use all key to access this hashed table ,it is certainly quick, and my question is when i use partial key of this internal hashed table to loop it, how about its performance.
    Another question is in this case(BSID have many many record) , Sorted table and Hashed table , Which is better in performance.

    You can't cast b/w data reference which l_tax is and object reference which l_o_tax_code is.
    osref is a generic object type and you store a reference to some object in it, right? So the question is: what kind of object you store there? Please note - this must be an object reference , not data reference .
    i.e
    "here goes some class
    class zcl_spfli definition.
    endclass.
    class zcl_spfli implementation.
    endclass.
    "here is an OBJECT REFERENCE for it, (so I refer to a class) i.e persistent object to table SPFLI
    data oref_spfli type ref to zcl_spfli.
    "but here I have a DATA REFERENCE (so I refer to some data object) i.e DDIC structure SPFLI
    data dref_spfli type ref to spfli.
    So my OSREF can hold only oref_spfli but it not intended for dref_spfli . That's why you get this syntax error. Once you have stored reference to zcl_spfli in osref then you will be able to dereference it and access this object's attributes.
    data: osref type osref.
    create object osref_spfli.
    osref = osref_spfli.
    "now osref holds reference to object, you can deference it
    oref_spfli ?= osref.
    osref_spfli->some_attribute = ....
    OSREFTAB is just a table whose line is of type OSREF (so can hold multiple object references - one in each line).
    Regards
    Marcin

  • Unique Key Violation error while updating table

    Hi All,
    I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called ActivityAttendee. ActivityAttendee has the following columns. The problem to debug is this table has
    over 23 million records. How can I catch where my query is going wrong?
    ActivityAttendeeID INT PRIMARY KEY IDENTITY(1,1)
    ,ActivityID INT NOT NULL (Foreign key to parent table Activity)
    ,AtendeeTypeCodeID INT NOT NULL
    ,ObjectID INT NOT NULL
    ,EmailAddress VARCHAR(255) NULL
    UNIQUE KEY is on ActivityID,AtendeeTypeCodeID,ObjectID,EmailAddress
    We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INT NOT NULL, intNewObjectID INT NULL)
    The problem is ActivityAttendee table might already have the new ObjectID and the unique combination.
    For example: ActivityAttendee Table have the following rows
    1,1,1,1,NULL
    2,1,1,2,NULL
    3,1,1,4,'abc'
    AND the temp table has 2,1
    So essentially when I update in this scenario, It should ignore the second row because, if I try updating that there will be a violation of key as the first record has the exact value. When I ran my query on test data it worked fine. But for 23 million records,
    its going wrong some where and I am unable to debug that. Here is my query
    UPDATE AA
    SET AA.ObjectID = TMP.NewObjectID
    FROM dbo.ActivityAttendee AA
    INNER JOIN #tmpActivityMapping TMP ON AA.ObjectID = TMP.ObjectID
    WHERE TMP.NewObjectID IS NOT NULL
    AND NOT EXISTS(SELECT 1
    FROM dbo.ActivityAttendee AA1
    WHERE AA1.ActivityID = AA.ActivityID
    AND AA1.AttendeeTypeCodeID = AA.AttendeeTypeCodeID
    AND AA1.ObjectID = TMP.NewObjectID
    AND ISNULL(AA1.EmailAddress,'') = ISNULL(AA.EmailAddress,'')

    >> I am having problem with UNIQUE CONSTRAINT. I am trying to update a table and getting the violation error. Here is the over view. We have a table called Activity_Attendee. <<
    Your problem is schema design. Singular table names tell us there is only one of them the set. Activities are one kind of entity; Attendees are a totally different kind of entity; Attendees are a totally different kind of entity. Where are those tables? Then
    they can have a relationship which will be a third table with REFERENCES to the other two. 
    Your table is total garbage. Think about how absurd “attendee_type_code_id” is. You have never read a single thing about data modeling. An attribute can be “attendee_type”, “attendee_code” or “attendee_id”but not that horrible mess. I have used something like
    this in one of my busk to demonstrate the wrong way to do RDBMS as a joke, but you did it for real. The postfix is called an attribute property in ISO-11179 standards. 
    You also do not know that RDBMS is not OO. We have keys and not OIDs; but bad programmers use the IDENTITY table property (NOT a column!), By definition, it cannot be a key; let me say that again, by definition. 
    >> ActivityAttendee has the following columns. The problem to debug is this table has over 23 million records [sic: rows are not records]<<
    Where did you get “UNIQUE KEY” as syntax in SQL?? What math are you doing the attendee_id? That is the only reason to make it INTEGER. I will guess that you meant attendee_type and have not taken the time to create an abbreviation encoding it.
    The term “patent/child” table is wrong! That was network databases, not RDBMS. We have referenced and referencing table. Totally different concept! 
    CREATE TABLE Attendees
    (attendee_id CHAR(10) NOT NULL PRIMARY KEY, 
     attendee_type INTEGER NOT NULL  --- bad design. 
        CHECK (attendee_type BETWEEN ?? AND ??), 
     email_address VARCHAR(255), 
    CREATE TABLE Activities
    (activity_id CHAR(10) NOT NULL PRIMARY KEY, 
    Now the relationship table. I have to make a guess about the cardinally be 1:1, 1:m or n:m. 
    CREATE TABLE Attendance_Roster
    (attendee_id CHAR(10) NOT NULL --- UNIQUE??
       REFERENCES Attendees (attendee_id), 
     activity_id Activities CHAR(10) NOT NULL ---UNIQUE?? 
      REFERENCES Activities (activity_id)
     PRIMARY KEY (attendee_id, activity_id), --- wild guess! 
    >> UNIQUE KEY is on activity_id, attendee_type_code_id_value_category, object_id, email_address <<
    Aside from the incorrect “UNIQUE KEY” syntax, think about having things like an email_address in a key. This is what we SQL people call a non-key attribute. 
    >> We have a requirement where we need to update the ObjectID. There is a new mapping where I dump that into a temp table #tempActivityMapping (intObjectID INTEGER NOT NULL, intNewObjectID INTEGER NULL) <<
    Mapping?? We do not have that concept in RDBMS. Also putting meta data prefixes like “int_” is called a “tibble” and we SQL people laugh (or cry) when we see it. 
    Then you have old proprietary Sybase UODATE .. FROM .. syntax. Google it; it is flawed and will fail. 
    Please stop programming until you have a basic understanding of RDBMS versus OO and traditional file systems. Look at my credits; when I tell you, I think I have some authority. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Null Values in a unique key in a Merge????

    We have OWB 9.2.0.2.8 and Oracle 9i
    I have a Mapping with a Source table (A), a Target table (B) and an Insert/Update Loading Type.
    I make a Match by constraint with a “unique key” in the Target table with two Fields: Field1 and Field2
    The problem is the Field2 could be NULL then If I have In TABLE A (Field1: XXX and Field2: NULL) and in TABLE B (Field1: XXX and Field2: NULL) it don’t match because Field2 has NULL value and the INSERT fails.
    I need to use a NVL function. For example:
    UPDATE
    ….
    ….
    ….
    Where nvl(A.Field2,’*’) = nvl(B.Field2,’*’)
    I could create a NVL to TABLE A (Source) with a “Expression object” but How can I create a NVL to TABLE B.
    I need to generate the nvl(B.Field2,’*’) part of the instruction nvl(A.Field2,’*’) = nvl(B.Field2,’*’).
    How can I do it???
    Thanks very much!

    Hi Claudio,
    well, I have an solution although it is neither nice nor clean...
    * Add a column Field2_notnull to Table B with not null-constraint and same type as Field2
    * Add a check-constraint to Table B like this: "nvl(Field2,'*') = Field2_notnull"
    * Create a UNIQUE KEY on Table B's Field1 and Field2_notnull and use this constraint for the MERGE-Load (INSERT/UPDATE)
    * Coming from Table A, use Field1 and nvl(Field2,'*') for the match
    As I said, neither nice nor clean, but it works, as long as you can manage to fill Field2_notnull in Table B correctly.
    Best regards
    Andreas

Maybe you are looking for

  • Error when applet is trying to connect to WLS server

    Hello everyone, I'm currently having problems with applets and WebLogic. Though I know, applets are not the most appreciated way to do things with weblogic (or even in general), there are no real alternatives for us. We have a larger application cons

  • Issue with calculation script - please help

    There is a script that I am working on that needs to track the changes made by the user on the data form and push the entered value down proportionally to the lower levels. It's a signal dimensional spread. It needs to spread the parent level values

  • Pictures from Folders on one Drive not showing in Organizer

    Because one external drive failed,  I had to transfer two large folder (with sub folders) from a backup drive to a new drive.  Organizer sees the folders but does not show that there are any images in the folder.  The images do show up when you get t

  • Using icloud on os 10.6.8

    Can I run icloud - at least for email - on my macbook pro with os 10.6.8?  My laptop is not capable of upgrading to lion.  I had a mobile me account and have upgraded to icloud on my ipad and iphone.  But now my me account is disabled on the laptop. 

  • Re-importing a lost book from pdf

    Hello. About 2 years ago the mover dropped my iMac and pooched my drive. After a new drive was installed I was able to recover all my photo's but never any of the projects (Calendars, Books etc.) Now I wish to reprint a book I made, but no longer hav