Multi-Record (NON-DB) block - duplicate records

I have a non-db block called 'EDITOR_INFO' that captures all the editor's information. The block has the following fields in it: editor_name,editor_type,address_lines1 thru4, city, state, zip, taxid_ssn_type,taxid_ssn.
I need to check to make sure that the user is not entering the duplicate editors. How can I adapt the infamous Kevin Clarke's solution to this (if at all)? What would be my datablock, control block etc?
Can any one pls. provide any guidance.
Thanks,
Chiru
Edited by: Megastar_Chiru on Nov 8, 2010 3:55 PM
Edited by: Megastar_Chiru on Nov 8, 2010 3:56 PM

Chiru, if all you need is to add/query records in a block, you should consider making a data-block instead of control-block. And use POST to post the data into table which will let you check against the table if a record exists or not.
But if you want to have it done using a control-block then follow below sample steps.
In WHEN-VALIDATE-RECORD of your control block, you can check if entered record is already in the table or not.
If it exists, then raise error message and stop until user corrects the data... if it does not exist, then INSERT into the table.
For this scenario, I created a small table with two columns.
CREATE TABLE TABLE_A (Col1 NUMBER, Col2 VARCHAR2(30));Now I created a form with a control block (BLOCK2). It has 10 records with vertical layout and two control-items on it (TEXT_ITEM4 and TEXT_ITEM5). And below is code used on WHEN-VALIDATE-RECORD.
-- WHEN-VALIDATE-RECORD
DECLARE
  temp VARCHAR2(1);
  CURSOR c_check_existance IS
  SELECT 'X'
    FROM table_a
   WHERE col1 = :BLOCK2.text_item4;
BEGIN
    :GLOBAL.Valid_Records := 'N';
     IF :block2.text_item4 IS NOT NULL THEN          
          OPEN c_check_existance;
          FETCH c_check_existance INTO temp;
          IF c_check_existance%FOUND THEN
               CLOSE c_check_existance;
                                                :GLOBAL.Valid_Records := 'N';
               MESSAGE('Record already exists in table');
               RAISE FORM_TRIGGER_FAILURE;
          ELSE
               INSERT INTO table_a (col1, col2)
                            VALUES (:block2.text_item4, :block2.text_item5);
                                                :GLOBAL.Valid_Records := 'Y';
          END IF;
          CLOSE c_check_existance;
     END IF;
END;Remember, when making a control block like a data block, you have to code everything yourself.

Similar Messages

  • Check duplicate data entry in multi record block,which is a mandatory field

    Dear all,
    I have a situation where i have to check duplicate data entry(on a particular field,which is a mandatory field,i.e. it cannot be skipped by user without entering value) while data key-in in a Multi Record block.
    As for reference I have used a logic,such as
    1>In a When-Validate-Record trigger of that block I am assigning the value of that current item in Table type variable(collection type)
    as this trigger fire every time as soon as i leave that record,so its assigning the value of that current time.And this process continues
    then
    2>In a When-Validate-Item trigger of that corresponding item(i.e. the trigger is at item level) has been written,where it compares the value of that current item and the value stored in Table type variable(collection type) of When-Validate-Record trigger.If the current item value is matched with any value stored in Table type variable I am showing a message of ('Duplicate Record') following by raise_form_trigger failure
    This code is working fine for checking duplicate value of that multi record field
    The problem is that,if user enter the value in that field,and then goes to next field,enter value to that field and then press 'Enter Query 'icon,the bolth Validate trigger fires.As result first when-validate record fires,which stores that value,and then when-validate-item fires,as a result it shows duplicate record message
    Please give me a meaningful logic or code for solving this problem
    Any other logic to solve this problem is also welcome

    @Ammad Ahmed
    first of all thanks .your logic worked,but still i have some little bit of problem,
    now the requirement is a master detail form where both master and detail is multirecord ,where detail cannot have duplicate record,
    such as..........
    MASTER:--
    A code
    A1
    A2
    DETAIL:--
    D code
    d1
    d2 <-valid as for master A1 , detail d1 ,d2 are not duplicate
    d2 <--invalid as as for master A1 , detail d2 ,d2 are duplicate
    validation rule:  A Code –D Code combination is unique. The system will stop users from entering duplicate D Code for a A Code. Appropriate error message will be displayed.*
    actually i am facing a typical problem,the same logic i have been applied in detail section ,its working fine when i am inserting new records.problem starts when i query,after query in ' a ' field say 2 records (i.e. which has been earlier saved) has been pasted,now if i insert a new record with the value exactly same with the already present value in the screen(i.e. value populated after query) its not showing duplicate.................could u tell me the reason?and help me out...............its urgent plzzzzzzzzz
    Edited by: sushovan on Nov 22, 2010 4:34 AM
    Edited by: sushovan on Nov 22, 2010 4:36 AM
    Edited by: sushovan on Nov 22, 2010 8:58 AM

  • Check Duplicate data during data key-in Multi Record Block

    Dear all,
    I have a situation where i have to check duplicate data entry(on a particular field,which is a mandatory field,i.e. it cannot be skipped by user without entering value) while data key-in in a Multi Record block.
    As for reference I have used a logic,such as
    1>In a When-Validate-Record trigger of that block I am assigning the value of that current item in Table type variable(collection type)
    as this trigger fire every time as soon as i leave that record,so its assigning the value of that current time.And this process continues
    then
    2>In a When-Validate-Item trigger of that corresponding item(i.e. the trigger is at item level) has been written,where it compares the value of that current item and the value stored in Table type variable(collection type) of When-Validate-Record trigger.If the current item value is matched with any value stored in Table type variable I am showing a message of ('Duplicate Record') following by raise_form_trigger failure
    This code is working fine for checking duplicate value of that multi record field
    The problem here is that suppose if usee gets a message of ('Duplicate Record') and after that without saving the values if user try to query of that block then also when validate item fired where as I am expecting ORACLE default alert message('Do You want to save?'),I want to restrict this When-Validate Item fire during query time..........................while user try to query.
    Please give me a meaningful logic or code for solving this problem
    Any other logic to solve this problem is also welcome

    When-Validate-Record trigger
    When-Validate-Item triggerThat smells like Oracle Forms...
    And the Oracle Forms forum is over here: Forms

  • About populating a non-database item in a multi-records block

    Hi, all
    I have a problem about populating a non-database item in a
    multi-records block. This block is set to database block with a
    controlled item which needs to be populated after query. so I
    create a post-query trigger, but my problem is when the records
    listed in this block are less than 10 ( the record number is set
    to 10), the trigger fires no problem. but when the retrieved
    records are greater than 10, the error message is 'post query
    trigger raised unhandled exception ora 01403'. anyone can help me
    fix this problem?
    Thanks in advance
    Diana

    Diana,
    When you have an unbound item in a block and want to fetch
    some data into it you need to write a post-query trigger.What
    you have done is right.But it seems that u are getting a No data
    found error.I am sure about how u r populating data into that
    field.If u have written a select statement to fetch the data in
    post-query trigger, kindly handle an exception and find out the
    problem.Having a look at ur code(pos-query) would be much more
    helpful for giving a better solution.Try this a let me know.
    Thanks
    Vinod.

  • Duplicate item value in a Multi-Record Block

    Is there a way to chek duplicate value entered in multi record block?
    I have seen some solutions in this forum however nothing has worked for me till now. (using the formula, creating hidden items & creating group etc)
    Thanks in advance,

    To see if there are any other records in the block with the same value, use Kevin Clark's famous function to trap duplicates. You can find Kevin's function write up here:
    Re: checking for same rows in a tabular
    From Kevin's post:
    Create a field PK_COPY in a control block.
    Create program unit function COMPARE to compare two input params returning 1 if they match else 0.
    Create a field in the datablock PK_MATCH, calculation property formula, formula COMPARE(:DATA_PK, :PK_COPY)
    Create a field in the control block NO_OF_MATCHES, calculation property summary, summary type SUM, summarised
    item PK_MATCH.
    Also, your control block requires the Single Record property set to yes, and the base table block requires the Query All Records property set to yes.
    WHEN-VALIDATE-ITEM on DATA_PK
    :CONTROL.PK_COPY := :DATA_PK;
    if :NO_OF_MATCHES > 1 then
      message('You have already used that one');
      Raise form_trigger_failure;
    end if;

  • How to do validation on multi record block at run time...

    Dear Friends,
    I have to do validation at run time on multi record block.
    If user tries to enter and save two or more records in same multi record block with same data at run time, it should not allow it and display a message like, " error : Records are having same(duplicate) values. "
    I already did validation with the data coming from database table using cursor. But confused about how to do at run time(on one screen only) ??
    Please, give details about how to check duplicate records on form block before saving it to the table ????
    Regarding details would be greatly helpful.
    thanks,

    Hi...Pankaj
    thanx for your reply..
    I already did validation for the data coming from table....
    but I need to do it on form only...at run time...
    exa...
    In one multi record block
    record no : column 1 : column 2 : column 3
    1 abc 123 hi
    2 abc 123 hi
    so it should check on the form itself, here I m not getting data from table...I am just
    navigating from first record to second using down arrow.
    so, may be 2 possibilities.
    1) when user navigates using tab to third record, it should say like two duplicate records.(may be like when validate record or item)
    2) or when user tries to save, it should say two duplicate records.
    so, everyting should take place on form screen only.....
    waiting for your reply,
    thanx...

  • Saving the record in multi-record block while updating

    Hi gurus
    I have a table name PT . Its is master table where PT_TYPE IS unique
    desc PT
    PT_TYPE VARCHAR2(2) unique,
    PT_CODE VARCHAR2(4),This is the detail table on which the form is being designed is meant for insert/update/delete.Insert and delete are working fine.
    desc PST
    PST_PT_type varchar2(2) unique,
    PST_A_code Varchar2(3) unique,
    PST_A_desc varchar2(10) The form layout is a multi-record form as below and based on PST table with PT_CODE as non-base table item & PST_PT_TYPE
    not displayed but its there in the block.
    FORM_LAYOUT
    PT_CODE PST_A_CODE PST_A_DESC
    ASD          AS          TESTAS
    ASD          AD TESTAD
    ASD DS TESTDS.
    Now the problem is when I am querying record through enter-query mode (say by entering PT_CODE 'ASD') and
    change one of the base table items(PST_A_CODE or PST_A_DESC) values and commit it. its says '1 records applied and save'
    but when I change ONE OF THE PT_CODE(non-base table item) values it says 3 records applied and saved. as the 3 records
    are currently displayed when querying

    Hi Craig,
    Both below program unit is in the WHEN-VALIDATE-ITEM of NBT item PT_CODE
    --this is to check that valid pt_code is entered
    PROCEDURE val_pt_code IS
         cursor val_cur is
         select pt_code
         from pt
         where pt_code =:pst.pt_code;
    v_dummy varchar2(12);
    BEGIN
    open val_cur;
    fetch val_cur into v_dummy;
    if val_cur%notfound then
    close val_cur;     
         warn_alert('Error:The Product Code entered does not exists');
         raise form_trigger_failure;
    end if;
    close val_cur;
    END;
    --this is to check that particular pt_type value is for the pt_code is selected
    PROCEDURE get_pt_type IS
         v_pt_type varchar2(2);
    begin
         select pt_type into v_pt_type
         from      pt
         where pt_code = :pst.pt_code;
         :pst.pt_type := v_pt_type;
    exception
         when no_data_found then
              warn_alert('Error:The Syllabus Type does not exists');
         raise form_trigger_failure;
    end;
    --

  • FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.

    Hi,
    I have one multi record block in which i want to fetch values
    (more then one record) from another table using select statement
    IN KEY NEXT ITEM.I am getting following error.
    ORA-01422: exact fetch returns more than requested number of rows
    Thanks in advance.

    In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
    Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
    However, you can replace the explicit cursor with implicit one like
    go_block('non_db_block_name');
    first_record();
    FOR v_tab IN (SELECT *
    FROM tab
    WHERE col_name = :variable)
    LOOP
    :non_db_block_name.field1 := v_tab.col1;
    :non_db_block_name.field2 := v_tab.col2;
    next_record();
    END LOOP;

  • Another multi-record block question

    I have always struggled with this. I have a muti-record block(10 records displayed). Eventhough my block is a db block, I have not assigned it a table. Hence, it is a non-db block. If I set enabled on a txt box, it
    is enabling the entire column. I need to enable only the text box on which the cursor is/user navigated to.
    How to do it?
    Thanks,
    Chiru
    Edited by: Megastar_Chiru on Sep 21, 2010 2:03 PM

    ok..here is the explanation of the issue
    in my multi-record block, there is a drop down list column with 2 values "Monthly %" and "Half-Rent". So, for example, in record 1, the drop-down could be chosen as "Monthly %" while in rec2, it could be "Half-rent". Right next to this list column, I have a text box. When the user chooses "Monthly %", the text box need to be enabled to allow keying a % value (say 5%). While in rec2, since the user chooses "Half-rent", the text box needs to be disabled for this record. How to accomplish this?
    Thanks,
    Chiru

  • ToolTip_Text not working in multi - record block - Please Help!!

    Dear Friends & Gurus,
    I'm using Forms Version 6.0.8.21.3 (due to many reasons) in C/S mode. Now I have a multi record block in which I am showing the Employee No. My customer's requirement is when I place the mouse on this Emp no., the emp. name must be displayed. I thought of achieving this by ToolTip_text. For this I'm having a Database function which returns the name (as I use this functionality in many forms), in the When-New-Item-Instance block level trigger I'm calling that function with passing the emp code as below
    SET_ITEM_PROPERTY(:SYSTEM.CURSOR_ITEM, TOOLTIP_TEXT, FUNC_DIS_EMP_NAME(:SYSTEM.CURSOR_VALUE));But it is working only when I point the mouse in the first record. When I click on 3 or 4 record and then point to the first record, I'm getting the 3 record's name but in the first record.
    Please help me - I searched through the forum and I find no accurate answer. It is urgent - please help.
    Thank you.
    With Kind Regards,
    Perumal Senthil Alagu.

    Dear Safwan Bhai,
    As salaamo alaikum Rahamatulla hi burakathu!!
    Actually I'm having a multi record block in which all the emp no., days of attendance, etc will be displayed when I click on the search button. My requirement is when point the mouse over the emp no, the emp name must be displayed as a Tool tip text. My fields are non-editable, so Post-Change is not working. I placed the coding in the When-new-item-instance - in this case the emp name is displayed, but only for the first field, when I move the mouse to second and third fields, the empname of that particulart field is displayed as a tool tip but in the first field only.
    Any other suggestions?
    Anyway I would appreciate your help.
    Thank you.
    With Kind Regards,
    Perumal Senthil Alagu.

  • Disabling radio buttons in multi record block

    Need to be able to disable/enable one or more radio buttons in a group dynamically in multiple record block. Tried setting enabled properties but it sets for all records in the block. At the very least, I need to reset an item using radio to previous value if setting is invalid but when-radio-changed has already set value. Thank you.

    Your one row record has 5 items, then I assume empno, ename, ssn, phone, deptno 5 items on your multi-record block.
    you entered first row record as,
    empno, ename, ssn, phone, deptno
    100 John Smith 123-45-9999 234-333-9999 2
    101 Al Brown 222-34-1111 123-456-7890 2(duplicated)
    You want your code to duplicate the second deptno record as 2 instead of typing in, right?
    If so, then you add KEY-NEXT-ITEM trigger on item :phone, inside put,
    go_item('deptno');
    duplicate_item;
    It will copy the first deptno record 2 for the second record as showed above.

  • Re-sequencing records in a multi record block

    I have a multirecord block with sequence No field which is unique no and other fiels which is showing from the values which I have stored in a table say sequence No from 1 to 10 along with other fields.If I change the record which has the sequence No say 6 to become seq no 2 ,then the record with seq no 2 should become seq no 3 and the rec with seq no 3 should become seq no 4 and rec with seq no 4 should become seq no 5 and rec ord with seq no 5 should become seq no 6.This should automatically happen when the user changes say
    seq no 6 to seq no 2 .User may change any seqq no like this.
    We will provide 2 text box serialNo from and Serial No 2 and a button click should swap the records in between this two seq no and show it on the screen in the multi record block.Please help me to code this.
    Regards
    Jayshree Suresh

    User455091,
    1- You can add a non based checkbox item to your block. To resequence a record, you may have to check the record you want to change and then, check the position you want to change it for. Example: if you want to change the 6th to seq 2, you check the record 6 and check the record 2 right after (you can choose any logic to implement your sequence change. this is only an example).
    2- When you check the first record, set a global variable "seq_from" with the value of the sequence field (or :system.cursor_record if the block is ordered by this sequence)
    3- When you check the 2nd record, set a global variable "seq_to" and proceed to the resequence.
    4- Manage the change down and change up (if "seq_from">"seq_to" or "seq_from"<"seq_to")
    5- You have to change the values of all the record fields for all the records between seq_from and seq_to. by doing a loop between seq_from and seq_to. You may have to use previous_record or next_record depending on if it is a change_qown or a change_up.
    6- When the resequence is done, reset all the variables to blank, and don't forget your checkbox!
    This seems difficult, but only think about it. It is easier than what you expect. This method is more user-freindly but, just think about it....

  • Editing record items in a multi-record block - 1 record at a time.

    Hello,
    I have the following scenario: Currently in my multi-record block, to edit an item of a record, the user has to double click on the record to enable the 'save changes' button. However, I want to turn the navigation to all other records turned off. The only way the user should be able to edit other records is save changes first, then again double click on the desired record to re-enable the 'save changes' button (at this time navigation to all other records should be turned off). ie., the user should be able to edit 1 record at a time (At any given time, I won't be having many records in the block which the user may have to modify).
    How can this be achieved?
    Thanks,
    Chiru

    That is pretty odd requirement, but this might work:
    When the user double-clicks the record, enable the Save button, and set a value in any column of the record to its current value. This will cause Forms to set the record status to CHANGED, and will not permit navigation away from the record until the When-validate-record trigger runs successfully.
    In the Save button, start a non-repeating timer to run maybe 20 milliseconds, then issue a Validate(Record_Scope); command. Check form_success then commit_form.
    In the when-validate-record trigger: Do any record validation that may be necessary, and Raise Form_Trigger_Failure if anything is wrong. Then check for the existence of your Save button's timer. If it does NOT exist, issue a message like: "You must Save the changes first" and Raise Form_Trigger_Failure; If the timer exists, do not raise the error.

  • Record level commit in a multi record block

    Dear all,
    i have a multi record block in my form (only one block)
    after entring record the save buttons commites the form
    if any error is raised then total commit processs stop for example if DUP_VAL_ON_INDEX is raised
    what i want is that the form shoud act record level,i.e; it should commit record wise so that though a excepton is raised atleast record above that are commited.
    thank U
    Raj
    mail : [email protected]

    you can have non-database block and write "insert into <table>" statements for each row of block at when-button-pressed of 'commit' button. Commit after each row insertion. This will serve your purpose.

  • Fill a multi record block with a for-loop

    Hi
    I've got a simple question but I couldn't find a solution yet.
    I have a multi record block and behind this i wrote a post-query-trigger with a cursor and a for-loop. Now I try to show each record of the for-loop in the multi record block. The loop works correctly, but the problem is that I only see the last found record of the loop in the first multi record and I'm not able to go to the next multi record when the loop finds more then one record.
    I tried to use NEXT_RECORD but then I got the error message "100500: non-ORACLE exception".
    May someone help me? Thanks a lot!

    What exactly are you trying to do? If you are simply trying to display the result of a query in a Multi-Record Block (MRB), I would recommend basing your block on the query (From Clause Query) or if you are simply displaying the contents of a table or a view in the block, base your MRB on the table or view and let Forms handle displaying the records.
    The Post-Query (PQ) trigger will execute for each record displayed in the MRB, which I'm sure is not what you intended. Since the trigger fires for each record, your loop is essentially assigning the value of each row in the cursor to the same row in the MRB.
    Hope this helps.
    Craig...

Maybe you are looking for

  • Background Job is not creating the List ID

    Hello Experts, I am scheduling a program as a Background Job. When I go and check the tables TBTCP & TBTCO, I see the List ID field (TBTCP-LISTIDENT or TBTCO-LISTIDENT) value as 0 . Hence I am not able to get the Spool ID for this List. Can anybody p

  • Import CSV into Oracle?

    Is there a simple script or series of SQL statements to import a CSV into either a new table or an existing table rather than using a utility? There must be some way to do it in SQL or PL/SQL.

  • Adobe CS3 online help?

    i cannot find this product featured on Adobes website. can anybody help me with this? i need the tutorial page for this. thanks.

  • Cover art disappearing

    Hello I am having issues with my cover art disappearing after Sync.. any ideas?

  • Flash 8 Basic is very annoying

    Hi All this is my first post here, hope you can help. I have to produce an animation project that will be marked on a machine in the University that is running Flash 8 Education BASIC Version, the machine for which I have access to produce this work