How to handle Duplication in records using PL/SQL Code

Hi,
I have table
Table name: PM
and with fields wo_no, wo_descr, pm_no, current_date
wo_no is a Primary key.
I am enter data in this table through loop (Many records at a time), when I press a Button. Data is as under in table.
wo_no          wo_descr          pm_no          current_date
1          cleaning the relays     2          12-DEC-04
2          calibration           3      12-DEC-04
Now the problem is that when I again press the button at second time on same time, the following data will be entered as
wo_no          wo_descr          pm_no          current_date
3          cleaning the relays     2          12-DEC-04
4          calibration           3      12-DEC-04
So this is not required, instead of this when I press the button second time a message will appear like “duplication of wo_descr, pm_no in same date”
I am using form 6i, please send me the code on urgently basis.
Best Regard,
Shahzad

Unique key (wo_descr + pm_no + current_date) on PM
and then control the exception WHEN_DUP_VAL_ON_INDEX

Similar Messages

  • How to retrieve the current User using PL_/SQL code?

    Hi,
    How can find the current logged user within a Dynamic Page using PL/SQL code?
    Thanks.

    Hi,
    There is a function wwctx_api.get_user which returns the logged in user. You can use this in your plsql code.
    Thanks,
    Sharmila

  • How to create dynamic HTML page using PL/SQL code in APEX.

    hello,
    I am woking on one APEX application in which i want to create one dynamic HTML page on button press using PL/SQL code.
    Thanks

    It is possible to create HTML page with dynamic content. One way would be creating hidden field (e.g. P1_HTML on page 1) with dynamic HTML and on button click you redirect to page 2 and pass P1_HTML item value to item P2_HTML on page 2. On page you must have PL/SQL region. You can then render your dynamic HTML with code:
    htp.p(:P2_HTML);
    Don use APEX URL for passing HTML value. Problem and solution is described here: http://blog.trent-schafer.com/2011/04/03/dont-pass-string-parameters-in-the-url-in-apex-its-a-bad-idea/
    Edited by: MiroMas on 3.2.2012 3:20

  • How to to display entire records using PL/SQL(anoyomous block)

    Hi All,
    I have created a region of type PL/SQL by using rownum, and it wil display few records due to rownum.
    But the end user is asking to display the rest of records also using some pagination concept or any other way.
    How can we achieve this?
    In mean time i have tried to execute the by removing the rownum, then it is throwing the below Query
    Error- ORA-06502: PL/SQL: numeric or value error: character string buffer too small.
    Thanks,
    Ano.
    Edited by: Anoo on Mar 19, 2012 12:18 AM

    Hi,
    Here is the query we are using to dsipaly the records, but the limit we are dsiplaying is only 300.
    So the concern is how we can display all records.
    DECLARE
    list_arr2 htmldb_application_global.vc_arr2;
    p VARCHAR2(4000);
    v_default_start_date DATE;
    j NUMBER :=0;
    occurrencies NUMBER(10);
    CODESELECT VARCHAR2(7);
    BEGIN
    IF :P2_SYMBOL_CODE_HIDDEN IS NOT NULL THEN
    CODESELECT:=:P2_SYMBOL_CODE_HIDDEN;
    ELSE
    CODESELECT:='';
    END IF;
    Select TO_char(SYSDATE-1,'MM/DD/YYYY') into v_default_start_date from Dual;
    :P2_START_DATE := v_default_start_date; */
    list_arr2 := htmldb_util.string_to_table (:P2_SYMBOL_NAME, ',');
    p := 'SELECT SYMB_SARUS_DESCRIPTION,SYMB_CODE FROM ( '
    || 'SELECT '''' SYMB_SARUS_DESCRIPTION,''NA'' SYMB_CODE FROM DUAL ';
    p := p
    || ' UNION all SELECT sym.SYMB_SARUS_DESCRIPTION || ''- '' '
    || ' || sym.SYMB_CODE SYMB_SARUS_DESCRIPTION , sym.SYMB_CODE '
    || ' from T_SYM sym ';
    IF :P2_ACTIVESYMBOL='ACTIVE ONLY' THEN
    p := p || ', ( SELECT distinct DSPS_SYMB_CODE FROM t_dispatch_symbol ' ||
    ' WHERE dsps_dsp_code IN ( SELECT adsp_dsp_code ' ||
    ' FROM t_aut ' ||
    ' WHERE adsp_vend_code=''FTP'' ' ||
    ')) act_symb ' ||
    ' WHERE sym.SYMB_CODE=act_symb.DSPS_SYMB_CODE AND ';
    ELSIF :P2_ACTIVESYMBOL='INACTIVE' THEN
    p := p || ', ( SELECT distinct DSPS_SYMB_CODE FROM t_dis ' ||
    ' WHERE dsps_dsp_code NOT IN ( SELECT adsp_dsp_code ' ||
    ' FROM t_aut ' ||
    ' WHERE adsp_vend_code=''FTP'' ' ||
    ')) act_symb ' ||
    ' WHERE sym.SYMB_CODE=act_symb.DSPS_SYMB_CODE AND ';
    ELSE
    p := p || ' WHERE ';
    END IF;
    p := p || 'UPPER(sym.SYMB_SARUS_DESCRIPTION) LIKE ';
    FOR i IN 1 .. list_arr2.COUNT
    LOOP
    IF i = 1
    THEN
    p := p || ' UPPER(''%' || TRIM(list_arr2 (i)) || '%'') ';
    ELSE
    p :=
    p
    || ' AND UPPER(SYMB_SARUS_DESCRIPTION) LIKE '
    || ' UPPER(''%'
    || TRIM(list_arr2 (i))
    || '%'') ';
    END IF;
    END LOOP;
    p := p || ' order by 1 ) where rownum < 310 ';
    p := REPLACE(p, '''||''', '||');
    IF LENGTH(:P2_SYMBOL_NAME) > 2 AND :P2_HIDD = 'cdf' THEN
    htp.p('<table>');
    htp.p('<tr bgcolor=white><td width=20% align="left">');
    htp.p('<font color="#094991" size="1">     Search By Name</font>');
    htp.p('</td>');
    htp.p('<td align="left">');
    htp.p(APEX_ITEM.SELECT_LIST_FROM_QUERY(3,CODESELECT,p,'onChange="setSymbolCode(this.value);" size=10','NO','','','P2_SEARCHNAME','','Select'));
    htp.p('</td>');
    htp.p('</tr>');
    htp.p('</table>');
    END IF;
    IF LENGTH(p)<=0 THEN
    :P2_SYMBOL_CODE_HIDDEN:='';
    END IF;
    END;
    Thanks,
    Anoo.
    Edited by: Anoo on Mar 19, 2012 1:10 AM

  • How to handle Duplication in records

    Hi,
    I have table
    Table name: PM
    and with fields wo_no, wo_descr, pm_no, current_date
    wo_no is a Primary key.
    I am enter data in this table through loop (Many records at a time), when I press a Button. Data is as under in table.
    wo_no          wo_descr          pm_no          current_date
    1          cleaning the relays     2          12-DEC-04
    2          calibration           3      12-DEC-04
    Now the problem is that when I again press the button at second time on same time, the following data will be entered as
    wo_no          wo_descr          pm_no          current_date
    3          cleaning the relays     2          12-DEC-04
    4          calibration           3      12-DEC-04
    So this is not required, instead of this when I press the button second time a message will appear like “duplication of wo_descr, pm_no in same date”
    I am using form 6i, please send me the code on urgently basis.
    Best Regard,
    Shahzad

    Hi Pragati,
    I am trying to run a form from areport which I am successfull in.But when I run another report through this form the earlier report remains open resulting the report background engine showing the status of the current report as waiting.When I close all the earlier reports run then only the current report is run.I don't want the user to close the earlier reports but happen it automatically.
    How do I?
    Tanx in adv.
    Manoj

  • How to handle the bad record while using bulk collect with limit.

    Hi
    How to handle the Bad record as part of the insertion/updation to avoid the transaction.
    Example:
    I am inserting into table with LIMIT of 1000 records and i've got error at 588th record.
    i want to commit the transaction with 588 inserted record in table and log the error into
    error logging table then i've to continue with transaction with 560th record.
    Can anyone suggest me in this case.
    Regards,
    yuva

    >
    How to handle the Bad record as part of the insertion/updation to avoid the transaction.
    >
    Use the SAVE EXCEPTIONS clause of the FORALL if you are doing bulk inserts.
    See SAVE EXCEPTIONS in the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm
    And then see Example 12-9 Bulk Operation that continues despite exceptions
    >
    Example 12-9 Bulk Operation that Continues Despite Exceptions
    -- Temporary table for this example:
    CREATE TABLE emp_temp AS SELECT * FROM employees;
    DECLARE
    TYPE empid_tab IS TABLE OF employees.employee_id%TYPE;
    emp_sr empid_tab;
    -- Exception handler for ORA-24381:
    errors NUMBER;
    dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(dml_errors, -24381);
    BEGIN
    SELECT employee_id
    BULK COLLECT INTO emp_sr FROM emp_temp
    WHERE hire_date < '30-DEC-94';
    -- Add '_SR' to job_id of most senior employees:
    FORALL i IN emp_sr.FIRST..emp_sr.LAST SAVE EXCEPTIONS
    UPDATE emp_temp SET job_id = job_id || '_SR'
    WHERE emp_sr(i) = emp_temp.employee_id;
    -- If errors occurred during FORALL SAVE EXCEPTIONS,
    -- a single exception is raised when the statement completes.
    EXCEPTION
    -- Figure out what failed and why
    WHEN dml_errors THEN
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    DBMS_OUTPUT.PUT_LINE
    ('Number of statements that failed: ' || errors);
    FOR i IN 1..errors LOOP
    DBMS_OUTPUT.PUT_LINE('Error #' || i || ' occurred during '||
    'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
    DBMS_OUTPUT.PUT_LINE('Error message is ' ||
    SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    END LOOP;
    END;
    DROP TABLE emp_temp;

  • How to handle the selected record

    how to handle the selected record when using alv classes

    Hi,
    use method : get_current_cell                    
      CALL METHOD grid1->get_current_cell                    
                          IMPORTING es_row_id = ls_row_id     
                                    es_col_id = ls_col_id     
                                     e_value  = l_value.     

  • How to handle the control records in case of file to idoc scenario.

    Hi All,
    can you please clarify me how to handle the control records in case of file to idoc scenario.

    Hi,
    In File to Idoc scenario even though you selected apply control record values from payload and you are not getting those correct values which you have provided in the mapping.
    Also check the checkboxes Take sender from payload and Take receiver from payload along with the Apply control record values from payload checkbox
    Regards
    Seshagiri

  • How to handle  user exits while using BAPI

    HI experts can any one help me on how to handle user exits while using BAPI. Do we need to handle it explicitly or standard  BAPI will take care of it??.
    Regards,
    Hari Krishna

    If you have added some fields using append structures for screen enhancements, then you have to use appropriate user exits to fill these data while calling BAPI.  Some BAPIs have EXTENSION structures to fill the custom data which can be processed using user exists or enhancements.
    Regards
    Vinod

  • How to handle large result set of a SQL query

    Hi,
    I have a question about how to handle large result set of a SQL query.
    My query returns more than a million records. However, the Query Template has a "row count" parameter. If I don't specify it, it by default returns only 100 lines of records in the query result. If I specify it, then it's limited to a specific number.
    Is there any way to get around of this row count issue? I don't want any restriction on the number of records returned by a query.
    Thanks a lot!

    No human can manage that much data...in a grid, a chart, or a direct-connected link to the brain. 
    What you want to implement (much like other customers with similar requirements) is a drill-in and filtering model that helps the user identify and zoom in on data of relevance, not forcing them to scroll through thousands or millions of records.
    You can also use a time-based paging model so that you only deal with a time "slice" at one request (e.g. an hour, day, etc...) and provide a scrolling window.  This is commonly how large datasets are also dealt with in applications.
    I would suggest describing your application in more detail, and we can offer design recommendations and ideas.
    - Rick

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • How to Print to a paper using PL SQL

    Hi All,
    I have some advice generated in the database. These are well formatted and to be printed on a pre-defined background template.
    Could you please tell me the best way to print them using PL/SQL code?
    I tried using some other technology but the formatting of the message gets lots in this.
    regards
    Suhel

    >
    I dont have to format the same.It is already formatted using some other code. I have to print As-it-is.
    >
    I sincerely doubt that.
    As-it-is means a simple read-a-line, print-a-line. Already formatted for what font? what font-size?
    What is it that controls how many lines are on a page? If the formatted data is set for 66 lines per page then you can just copy lines to the printer if the custom paper has 66 lines per page.
    What happens when you print?

  • Can I create a file using pl/sql code in application server ?

    Hi
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?
    Please help me with an example...in this regard
    Regards
    Sa

    864334 wrote:
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?And how is this "file" to be delivered?
    Files can be created by PL/SQL code and stored in the Oracle database as CLOBs. This a fairly easy and robust process. It runs entirely in the database. It conforms to transaction processing. The "file" (as a CLOB) resides in the database and can thus be secured via database security, is part of database backups and so on.
    The basic issue is how to deliver the contents of the CLOB to the user. If via FTP, then the database can directly FTP the contents of the CLOB to the FTP server as a file. If via HTTP, the database can deliver the CLOB as a HTTP download directly to the web browser.
    If the client is Java or .Net, then the CLOB contents can be delivered via SQL or DBMS_LOB or a custom PL/SQL interface.
    In such cases, there is no need to step outside the secure and flexible database environment and create a physical o/s file in the wild (outside the controls of database security, data integrity and transaction processing). This is thus recommended and is the preference.

  • How to handle the failed records from the table when using DB Adapter

    Hi,
    I am reading some records from table using DB Adapter inside my synchronous BPEL process. Say like reading 100 records from table in between after successful reading of 90 records an error occured in 91st record due some various reasons(like DB down, Connection interrupted etc.). Then how to handle this situation, whether i have to read all the records from the begining and is there any option to continue from where it stopped reading.
    Can please anybody help me out in the regard?
    Thanks in advance
    Regards,
    Aejaz

    we had the same requirement some time ago and had two option:
    1. ask the R/3 development team add a deletion indicator in the table (and thus not actually deleting the record). this deletion indicator could then be used like for any other standard datasource
    this option was however refused, due to huge data volume after a while
    2. at the end of the load we copied the ZTABLE1 to ZTABLE2. then in the begin of the load (day after) we compare the data of table1 to table2. entries available in table2 but not in table1 are deleted, and we put a 'D'. in deletion indicator; as we only keep the deleted entries for one day, the volume of the new table is acceptable.
    M.

  • How to handle table type record in OAF

    Hi ,
    Req:
    There is a search page that can be accessed from different locations .
    The result set should be different when accessed from each location .
    Approach to be used :
    Call a PL/SQL api which returns a table type input parameter for different search conditions . Each record that is returned by the table type input needs to be iterated and a new row should be created in a transtient VO to show results on the UI
    Problem :
    How to handle to table type input returned from pl/sql in java and show the results?
    Thanks in advance.

    There is a requirement to fetch records from cursor into a collection .Following is the code snippet that I have used.
    /** creating an object **/
    CREATE OR REPLACE TYPE XXCRM_GBL_DSW_AUDIT_RSTLS_O_TP AS OBJECT (
    CUSTOMER_NAME VARCHAR2(360),
    PROJECT_NAME VARCHAR2(40),
    BOARD_NAME VARCHAR2(40),
    ARROW_UNIQUE_NO NUMBER,
    FIELD_NAME VARCHAR2(2000),
    OLD_VALUE VARCHAR2(2000),
    NEW_VALUE VARCHAR2(2000),
    USER_ID NUMBER,
    USER_NAME VARCHAR2(100),
    AUDIT_DATE DATE,
    AUDIT_TYPE VARCHAR2(1),
    SUPP_SYS_LAST_UPDATE_ON DATE,
    SUPP_TRACKING_NUM VARCHAR2(50),
    CONSTRUCTOR FUNCTION XXCRM_GBL_DSW_AUDIT_RSTLS_O_TP
    RETURN SELF AS RESULT
    /** initializing the object **/
    CREATE OR REPLACE TYPE BODY XXCRM_GBL_DSW_AUDIT_RSTLS_O_TP IS
    CONSTRUCTOR FUNCTION XXCRM_GBL_DSW_AUDIT_RSTLS_O_TP
    RETURN SELF AS RESULT IS
    BEGIN
    self.customer_name := fnd_api.g_miss_char;
    self.project_name := fnd_api.g_miss_char;
    self.board_name := fnd_api.g_miss_char;
    self.arrow_unique_no := fnd_api.g_miss_num;
    self.field_name := fnd_api.g_miss_char;
    self.old_value := fnd_api.g_miss_char;
    self.new_value := fnd_api.g_miss_char;
    self.user_id := fnd_api.g_miss_num;
    self.user_name := fnd_api.g_miss_char;
    self.audit_date := fnd_api.g_miss_date;
    self.audit_type := fnd_api.g_miss_char;
    self.supp_sys_last_update_on := fnd_api.g_miss_date;
    self.supp_tracking_num := fnd_api.g_miss_char;
    return;
    END;
    END;
    /** creating a collection of object**/
    CREATE TYPE XXCRM_GBL_DSW_AUDIT_RSTLS_C_TP AS TABLE OF XXCRM_GBL_DSW_AUDIT_RSTLS_O_TP;
    /**Inside the package body **/
    CURSOR c_proj_cur is
    SELECT NULL CUSTOMER_NAME,
    (SELECT project_name
    FROM xxcrm_gbl_dsw_projects_all
    WHERE project_id = xgda.project_id) PROJECT_NAME,
    DECODE(xgda.board_id,NULL,'test',
    (SELECT board_name
    FROM xxcrm_gbl_dsw_boards_all
    WHERE board_id = xgda.board_id)) BOARD_NAME,
    DECODE(xgda.internal_dwr_id,
    NULL,NULL,
    (SELECT internal_dwr_id
    FROM xxcrm_gbl_dsw_regstrations_all
    WHERE internal_dwr_id = xgda.internal_dwr_id)) ARROW_UNIQUE_NO,
    fielslu.meaning FIELD_NAME,
    xgda.old_value OLD_VALUE,
    xgda.new_value NEW_VALUE,
    xgda.created_by USER_ID,
    'kuldeep' USER_NAME,
    xgda.Creation_Date AUDIT_DATE,
    xgda.audit_Level AUDIT_TYPE,
    SYSDATE SUPP_SYS_LAST_UPDATE_ON,
    't001' SUPP_TRACKING_NUM
    FROM XXCRM_GBL_DSW_AUDIT_ALL xgda ,
    FND_LOOKUP_VALUES_VL fielslu
    WHERE xgda.project_id =174
    AND fielslu.lookup_type = 'XXCRM_DSW_REV_FIELD_NAMES'
    AND fielslu.lookup_code = xgda.FIELD_NAME
    AND enabled_flag = 'Y'
    AND TRUNC(SYSDATE) BETWEEN TRUNC(NVL(fielslu.start_date_active,sysdate))
    AND TRUNC(NVL(fielslu.end_date_active,sysdate))
    ORDER BY xgda.creation_date;
    Tab XXCRM_GBL_DSW_AUDIT_RSTLS_C_TP ;
    BEGIN
    OPEN c_proj_cur;
    LOOP
    FETCH c_proj_cur BULK COLLECT INTO tab; --ERROR type mismatch found at 'TAB' between FETCH cursor and INTO variables
    END LOOP;
    END;
    /**Error */
    When the above script is executed it gives an error “type mismatch found at 'TAB' between FETCH cursor and INTO variables” (at line highlighted above).
    I have validated the data type of cursor and object too. But still the error is not resolved .
    Did anyone of you come across a similar requirement, fetching the values from cursor into a collection? Please help.

Maybe you are looking for

  • Goods receipt not ticked in production order converted from sales order req

    Hi all, In MTO scenario, where requirement trigger from Inquiry -> Quotatation -> Sales Order -> Plan Order -> Production Order, goods receipt indicator in production order was not checked if requirement is triggering from sales order, however it is

  • Can't remove music from Flash file

    I decided not to use a music (wav) file and want to delete it from my file. I deleted it from the library and also the layer it was on. I publish the file and the sound still plays! I have no idea how to get rid of it!

  • Modify layer in a document made up with model

    I made a site without tables (all tag DIV), I have saved the page in a model, I selected one layer in a model and mark the layer (not his contained) in a modifiable area. I saved a page. After I create a new document from model.. when I try to modify

  • Is there a video noise reduction facility on final cut pro x?

    İs there a video noise reduction facility or plugin on final cut pro x?

  • ITunes Small window at opening

    Hello. (Sorry, for my English, I'm French). When I open iTunes, it open in a small window (reduced). So I need to click for extend the window. I know, it's not a important problem, but I find it enervating... Do you have an idea for have iTunes exten