How to avoid duplicates on a column with condition

Hi all

I need some advice here. At work, we have an Oracle APEX application that allow the user to add new records with the decision of the increment automatic number based on the year and the group name.

Said that if they add the first record, group name AA, for 2012, they get the decision number AA 1 2013 as their record casein displayed page of the report.

The second record of AA in 2013 will be AA 2 2013.

If we add about 20 records, it will be AA 20 2013.

The first record for 2014 will be AA 1 2014.

However, recently, we get a claim of the user on two files of the same name of group have the same number of the decision.

When I looked in the history table and find that the time gap between 2 record is about 0.1 seconds.

In addition, we have the correspondence table which allows the user admin update the sequence number start with the restraint that it must be greater than the maximum number of the current name of the current year.

This boot sequence number and the name of the group is stored together in a table.

And in some other case, the user can add a decision duplicate for related record number. (this is a new feature)

The current logic of the procedure to add the new record on the application are

_Get max record table with selected group name (decision_number) and the current year.

_INSERT in the folder table the new record came with the decision to number + 1

_ update sequence number of the number of the decision just added.

So instead of utitlising the process of editing the built-in automatic table of the APEX, I write a procedure that combine all three processes.

I have run some loop for continually perform this procedure, and it seems that it can generate autotically new decision unique number with time about 0.1 second difference.

However, when I increase the number of entry to 200 and let two users run 100 each.

If the time gap is about 0.01 second, double decision numbers are displayed.

What can I do to prevent duplicate?

I can't just apply a unique constraint here for three columns with condition because it can be duplicated in some special conditions. I don't know much about the use of lock and its impact.

This is the content of my procedure

create or replace

PROCEDURE add_new_case)

-ID just use the trigger

p_case_title IN varchar2,

p_year IN varchar2,

p_group_name IN VARCHAR2,

-decisionnumber here

p_case_file_number IN VARCHAR2,

-active

p_user in VARCHAR2

)

AS

NUMBER default_value;

caseCount NUMBER;

seqNumber NUMBER;

previousDecisionNumber NUMBER;

BEGIN

-execution immediate q '[alter session set nls_date_format = "dd/mm/yyyy"]';

SELECT count (*)

IN caseCount

OF CASE_RECORD

WHERE GROUP_ABBR = p_group_name

AND to_number (to_char (create_date, "yyyy")) = to_number (to_char (date_utils.get_current_date, "yyyy"));

SELECT max (decision_number)

IN previousDecisionNumber

OF CASE_RECORD

WHERE GROUP_ABBR = p_group_name

AND to_number (to_char (create_date, "yyyy")) = to_number (to_char (date_utils.get_current_date, "yyyy"));

IF p_group_name IS NULL

THEN seqNumber: = 0;

ON THE OTHER

SELECT Seq_number INTO seqNumber FROM GROUP_LOOKUP WHERE ABBREVIATION = p_group_name;

END IF;

IF caseCount > 0 THEN

default_value: largest = (seqNumber, previousdecisionnumber) + 1;

ON THE OTHER

default_value: = 1;

END IF;

INSERT INTO CASE_RECORD (case_title, decision_year, GROUP_ABBR, decision_number, case_file_number, active_yn, created_by, create_date)

VALUES (p_case_title, p_year, p_group_name, default_value, p_case_file_number, 'Y', p_user, sysdate);

-Need to update the sequence here also

UPDATE GROUP_LOOKUP

SET SEQ_NUMBER = default_value

WHERE the ABBREVIATION = p_group_name;

COMMIT;

EXCEPTION

WHILE OTHERS THEN

Logger.Error (p_message_text = > SQLERRM)

, p_message_code = > SQLCODE

, p_stack_trace = > dbms_utility.format_error_backtrace

);

LIFT;

END;

Many thanks in advance,

Ann

It's easier to solve for the case, while p_group_name is not null. In this case, you update a GROUP_LOOKUP line, so that you can select to update this line at the beginning, to prevent cases of two for the same group added at the same time. To do this, change the selection of GROUP_LOOKUP to:

SELECT Seq_number INTO seqNumber FROM GROUP_LOOKUP WHERE ABBREVIATION = p_group_name for an updated VERSION OF the SEQ_NUMBER;

and move this to be the first thing that did the procedure - before it has CASE_RECORD lines.

In the case when p_group_name is set to null, you have some object to be locked. I think the best you can do is to lock the entire table GROUP_LOOKUP:

the table lock in exclusive mode GROUP_LOOKUP wait 100;

The '100 expectation' means that he will wait until 100 seconds before giving up and trigger an error. in practice, that is expected to only wait a moment.

Exclusive mode allows others to read, but not to update the table.

UPDATES and the LOCK of the TABLE will be updates of other sessions wait for this transaction to validate. Queries from other sessions are not affected.

The locks are released when you commit or roll back.

Tags: Database

Similar Questions

  • Please let me know how I can add a new column with a constraint not null, table already has data, without falling off the table... Please help me on this issue...

    Hello

    I have an emp_job_det with a, b, c columns table. Note that this TABLE ALREADY has DATA OF THESE COLUMNS

    IAM now add a new column "D" with forced not null

    Fistly I alter the table by adding the single column "D", if I do, the entire column would be created with alll of nulls for the column DEFAULT D

    ALTER table emp_job_det Add number D; -do note not null CONSTRAINT is not added

    Second... If I try to add the constraint not null, get an eoor as already conatained null values...

    (GOLD)

    In other words, if I put the query

    ALTER table emp_job_det Add number D NOT NULL; -THROWS ERROR AS TABLE ALREADY CONTAINS DATA

    So my question is how how can I add a new column with a constraint not null, table already has the data, without falling off the table

    Please help me on this issue...

    Add the column without constraint, then fill the column. Once all the rows in the table are given in the new column, and then add the constraint not null.

  • How to remove duplicates in a column

    Hello

    Please find attached the sample output and I would like to delete duplicates in the column J, K, L.

    I don't see only once.

    If someone could help, how this can be achieved in BI Publisher,

    Thanks in advance a ton.

    Concerning

    Nanan

    Please let us know your model xml and rtf to this email id [email protected]

  • XMLTable to extract columns with conditional path does not

    Hello

    I am on 11.2.0.3 and I need to extract columns on a section of XML with conditions on, but I get "ORA-00907: lack the right parenthesis", so I think that the way I go about it is not supported or that I have somehow the wrong syntax or something.

    This is a very simplified what I'm trying to do (there could be several different entries in the < sets1 > and < sets2 > sections and they might be in different orders, is not as if I can always choose the first or the last):

    with sample_data as (select 1 id,
                                xmltype('<root>
                                           <sets1>
                                             <set1><set_name>name1</set_name><set_val>val1</set_val></set1>
                                             <set1><set_name>name2</set_name><set_val>val2</set_val></set1>
                                           </sets1>
                                           <sets2>
                                             <set2><set_name>name3</set_name><set_val>val3</set_val></set2>
                                             <set2><set_name>name4</set_name><set_val>val4</set_val></set2>
                                           </sets2>
                                         </root>') xml_doc from dual)
    select *
    from   sample_data sd,
           xmltable('<root>' passing sd.xml_doc
                    columns col1 varchar2(10) path 'sets1/set1[set_name=''name1'']/set_val',
                            col2 varchar2(10) path 'sets1/set1[set_name=''name2'']/set_val',
                            col3 varchar2(10) path 'sets2/set2[set_name=''name4'']/set_val') x;
    

    What I'm trying to get:

    COL1  COL2  COL3
    ----  ----  ----
    val1  val2  val4
    

    I know that I could separate the < set1 > and < set2 > nodes in their own xmltypes xmltable on it and then join them and make the necessary pivoting, etc., but when I try to start that against only 1000 lines, db do not love and ended my session! Therefore, I'm looking for a more elegant way to do it.

    Is there a way to do this in a XMLTABLE? Pointers are very welcome!

    It solves your problem of sample request and you get the output that show you.

     with sample_data as (select 1 id,
                                 xmltype('
                                            
                                              name1val1
                                              name2val2
                                            
                                            
                                              name3val3
                                              name4val4
                                            
                                          ') xml_doc from dual)
     select x.*  -- change
     from   sample_data sd,
            xmltable('/root' passing sd.xml_doc  -- change
                     columns col1 varchar2(10) path 'sets1/set1[set_name="name1"]/set_val',  -- change
                             col2 varchar2(10) path 'sets1/set1[set_name="name2"]/set_val',  -- change
                             col3 varchar2(10) path 'sets2/set2[set_name="name4"]/set_val') x;  -- change
    

    As you can see, I've marked the lines that I've changed.  The error you saw came to use two single quotes in the COLUMN XPath instead to use double quotes.  Then I changed the XPath expression in the XMLTable brackets as well.

    I'm confused on what the columns you really want overall, in terms of how you know which values you want, or did you mean that you want something random sets1 and sets2.

    You store the XML file in a column of XMLType SECUREFILE BINARY, right?  It seems that you made previous visits, but just double check.

  • How can I initialize the counter_ column with 1 every 5 rows

    How can I initialize with 1 again once the 'counter_' column every 5 rows on the following query?

    SELECT L.LETTER

    COUNTER_ ROWNUM

    FROM (SELECT "A" LETTER FROM DUAL UNION ALL

    SELECT THE LETTER 'B' FROM DUAL UNION ALL

    SELECT THE LETTER 'C' FROM DUAL UNION ALL

    SELECT WOULD BE ' LETTER FROM DUAL UNION ALL

    SELECT THE LETTER 'E' FROM DUAL UNION ALL

    SELECT THE LETTER 'F' FROM DUAL UNION ALL

    SELECT THE LETTER 'G' FROM DUAL UNION ALL

    SELECT THE LETTER 'H' FROM DUAL UNION ALL

    SELECT "I" LETTER FROM DUAL UNION ALL

    SELECT THE LETTER 'J' IN UNION DOUBLE ALL THE

    SELECT THE LETTER 'K' FROM DUAL UNION ALL

    SELECT THE LETTER 'L' FROM DUAL UNION ALL

    SELECT'M ' LETTER FROM DUAL UNION ALL

    CHOOSE "N" LETTER OF THE DUAL UNION ALL

    SELECT 'O' THE DOUBLE LETTER) L

    I need reach the result below:

    LETTERROWNUM
    1A1
    2B2
    3C3
    4D4
    5E5
    6F1
    7G2
    8H3
    9I have4
    10J5
    11K1
    12L2
    13M3
    14N4
    15O5

    You can just use the MOD to do.

    with w_data like)

    SELECT L.LETTER

    COUNTER_ ROWNUM

    FROM (SELECT "A" LETTER FROM DUAL UNION ALL

    SELECT THE LETTER 'B' FROM DUAL UNION ALL

    SELECT THE LETTER 'C' FROM DUAL UNION ALL

    SELECT WOULD BE ' LETTER FROM DUAL UNION ALL

    SELECT THE LETTER 'E' FROM DUAL UNION ALL

    SELECT THE LETTER 'F' FROM DUAL UNION ALL

    SELECT THE LETTER 'G' FROM DUAL UNION ALL

    SELECT THE LETTER 'H' FROM DUAL UNION ALL

    SELECT "I" LETTER FROM DUAL UNION ALL

    SELECT THE LETTER 'J' IN UNION DOUBLE ALL THE

    SELECT THE LETTER 'K' FROM DUAL UNION ALL

    SELECT THE LETTER 'L' FROM DUAL UNION ALL

    SELECT'M ' LETTER FROM DUAL UNION ALL

    CHOOSE "N" LETTER OF THE DUAL UNION ALL

    SELECT 'O' THE DOUBLE LETTER) L

    )

    Select the letter, COUNTER_,

    MOD (counter_-1, 5) + 1 ngrp

    of w_data

    /

    L COUNTER_ NGRP

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

    A          1          1

    B          2          2

    C          3          3

    D          4          4

    E          5          5

    F          6          1

    G          7          2

    H          8          3

    I          9          4

    J         10          5

    K         11          1

    L         12          2

    M         13          3

    N         14          4

    O         15          5

    15 selected lines.

  • How can I read a BLOB column with images and write a directory

    Hello

    I have a few paintings with a Blob column, in the columns there are documents (word, excel, images... etc), I have read the column of table and save a directory



    How can I do


    Version 9.2.08

    LS - ltr/bdados3/repser
    ls - ld /bdados3/

    view the results of above OS commands

  • How to avoid duplicates

    When I copy the contents of a folder on a USB key, I sometimes gave options to maintain two copies or ignore that (and others like him) in the folder I'm in that copy. I keep the video files in a video folder on a USB key and I try to copy C/disc/videos as often as possible. But sometimes, I don't know where I stopped the last time that the copy and select the files already in the destination folder. Why didn't we the possibility to jump if a duplicate constantly? Is there a way to prevent duplicate files when you do this?

    What type of USB key that you use? I use a 500 GB USB external hard drive and can't reproduce your problem, but mine is (well) permanently connected.

    I always manage the items I copy on records, so when I add new files they copied to a folder on the external drive. If I do double job inadvertently with something the only place where it is likely to be found in the previously copied folder, and it's a simple matter to check.

    Another point, when you copied elements on the external hard drive you by keeping the files on the drive or are you allow to delete?  -Thanks - r.

  • How to avoid the stalemate between count with all and several calls from an EP getBackingMapEntry...

    We have a processor input, which initiates a transaction lite by calling getBackingMapEntry on several similar entries.  The same cache distributed these similar entries of accommodation also simultaneously services count with all call and we often a blocking scenario comes from the fact that the count with all call trying to access/key in the same cache block - but in a different sequence - date entry processor accessed (for example, the European Parliament access to similar input 1 then similar input 2 while the count with all attempts to block the same but entries in sequence 2) then the entry 1).  The obvious solution is to change the sequence entry processor accesses these entries to match the sequence used by the count with all operation, but we do not know what sequence consistency applies to operations NamedCache.getAll.  Anyone know?  We believe that we excluded (e.g., consistency does not consider wrt the count with all access sequence) the following:

    • The sequence in an ordered collection of keys such as a list that is passed as an argument to count with all operation
    • The hash code of the key value
    • Any use of Comparable on the keys

    We use 3.7.1 consistency where it varies between 3.7.1 and 12 c.

    Thanks in advance.

    We've thought of it (always happens shortly after the publication on a support site).  If anyone is curious, it seems that the binary class implements Comparable and that consistency sorts instance converted by binary key and access the Scriptures based on this order sorted.  If the entry processor converts the keys to binary instances, sorts and accessed in sorted order, there is no potential blocking (of our observations, at least).  It would be nice if Oracle should document this that people better understand how to write safe concurrent code.

  • How to avoid cutting two identical letters with Grep?

    letters rr cannot not be cut at the end of a line

    not allowed

    Captain Achab strongly recriminated the Spanish slave - Cimar
    Ron

    permit

    Captain Achab strongly recriminated the Spanish slave - Ci

    Brown

    Captain Achab recriminated strongly the gue - Spanish

    rrilla

    If I insert a character style not to break the Word won't cut the words and will be probably poorly composed as words with these letters have legal partitions in other places: Ba ~ rran ~ that ~ lla

    I would say that the word in the screenshot has not added correctly and you must remove the ~ between the KR

    But more important, it's Spanish actually assigned to the text? You do this in the drop-down list in the character, the control panel Panel, or in the Formats of Caracter Advanced section of the paragraph style definition.

  • How to avoid the example of scheme with DBCA silent.

    Hello

    We have generated with dbca script files to create the database with the General_purpose models, where, as it uses Seed_database for the model of database resotoring.

    our concern is the data schema example also get restored, is there a way we can update the scripts is not to restore the sample schemas.

    Whizard DBCA hangs if I tried to create the database and to generate scripts as well.

    DBCA-silent - createDatabase - templateName General_Purpose.dbc-sid orcl - gdbName orcl - LOCAL emConfiguration - storageType ASM - diskGroupName DATA datafileJarLocation - /u01/app/oracle/product/11.2.0/db/assistants/dbca/templates - responsefile NO_VALUE - characterset WE8MSWIN1252 obfuscatedPasswords - false - true sampleSchema - oratabLocation /u01/app/oracle/product/11.2.0/db/install/oratab - automaticMemoryManagement true totalMemory - 6552 - maskPasswords false - oui_internal - generateScripts - gdbName orcl - scriptDest/u01/app/oracle/admin/orcl/scripts

    Operating system: Solaris 10
    Oracle 11 g 2

    concerning
    Sachin

    Sachin B says:
    Hello

    We have generated with dbca script files to create the database with the General_purpose models, where, as it uses Seed_database for the model of database resotoring.

    our concern is the data schema example also get restored, is there a way we can update the scripts is not to restore the sample schemas.

    Whizard DBCA hangs if I tried to create the database and to generate scripts as well.

    DBCA-silent - createDatabase - templateName General_Purpose.dbc-sid orcl - gdbName orcl - LOCAL emConfiguration - storageType ASM - diskGroupName DATA datafileJarLocation - /u01/app/oracle/product/11.2.0/db/assistants/dbca/templates - responsefile NO_VALUE - characterset WE8MSWIN1252 obfuscatedPasswords - false - true sampleSchema - oratabLocation /u01/app/oracle/product/11.2.0/db/install/oratab - automaticMemoryManagement true totalMemory - 6552 - maskPasswords false - oui_internal - generateScripts - gdbName orcl - scriptDest/u01/app/oracle/admin/orcl/scripts

    Operating system: Solaris 10
    Oracle 11 g 2

    concerning
    Sachin

    I notice that you have "-true sampleSchema" in your order. What happens when you use "false - sampleSchema"?

  • How do the sum of several columns with grouping different criteria

    Currently I am doing a project where I needed to generate the report which retrieved from the table. the table as shown below

    CURRENCY_A AMOUNT_A CURRENCY_B AMOUNT_B CURRENCY_C AMOUNT_C

    USD 100 EURO 100 POUNDS 100

    EURO 200 BOOKS 200 200 USD

    BOOKS USD EURO 300 300 300

    My expectations is the grand total of the Group (AMOUNT_A + AMOUNT_B + AMOUNT_C) currency

    USD:

    EURO:

    BOOKS:

    Is it possible to do this output in oracle alone?

    Hello

    UNPIVOT before consolidation / summary:

    SELECT currency, flat

    DE)

    SELECT CASE WHEN 1 THEN currency_a n

    WHEN 2 THEN currency_b

    WHEN 3 currency currency_c end THEN

    CASE WHEN 1 THEN amount_a

    WHEN 2 THEN amount_b

    WHEN 3 amount of end of amount_c THEN

    From your_table

    CROSS JOIN (select column_value table n (sys.odcinumberlist (1,2,3))) t

    )

    GROUP BY currency

  • How to avoid duplicate on form OPS

    Hello

    I have developed a search page in the OPS and after search, he questions a few lines in the region of the Table. a point is a textinputItem called "sequence".
    In this field user write values such as (1, 2, 3, 4, 5... etc). My requirement is to stop the user enter a value of sequence again... Means that if he (1,2,3,3,3,4,5), then he must raise the error.

    Let me know if you people could not understand my requirement...

    I developed something like this:

    Public Sub checkseq()
    {
    Sequence of string = "";
    OAViewObject vo = (OAViewObject) findViewObject ("XXBCR12ToolkitVO1");
    vo.executeQuery ();
    System.out.println ("line are" + vo.getAllRowsInRange () .length);
    Rank [r] = vo.getAllRowsInRange ();
    int n = vo.getAllRowsInRange () .length;
    for (int i = 0; i < n; i ++)
    {

    }

    }


    Kind regards
    Parag

    Hello
    WHT mistake you get paste it here.

    Nani :)

  • UPDATE multiple columns with conditional parameters

    I have a procedure that updates several columns of a table using the parameter of the procedure. Is it possible to have a update unique with the parameter SET conditional statement?
    CREATE TABLE TEMP
    (POL_NUM NUMBER,
    OED DATE,
    TERM NUMBER,
    TRANS_CD CHAR(2));
    
    INSERT INTO TEMP VALUES (1, '1 AUG 2009', 12, 'NB');
    INSERT INTO TEMP VALUES (2, '4 AUG 2009', 12, 'XL');
    INSERT INTO TEMP VALUES (3, '2 AUG 2009', 12, 'RN');
    COMMIT;
    
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM NUMBER,
      pOED IN DATE,
      pTERM IN NUMBER,
      pTRANS_CD CHAR2)
    AS
    BEGIN
      IF pOED IS NOT NULL THEN
        UPDATE TEMP SET OED = pOED WHERE POL_NUM = pPOL_NUM;
      END IF;
    
      IF pTERM IS NOT NULL THEN
        UPDATE TEMP SET TERM = pTERM WHERE POL_NUM = pPOL_NUM;
      END IF;
    
      IF pTRAN_CD IS NOT NULL THEN
        UPDATE TEMP SET TRANS_CD = pTRANS_CD WHERE POL_NUM = pPOL_NUM;
      END IF;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
         NULL;
    END;
    Is it possible to replace several IFs code to have only one UPDATE statement with the condition that update the column only if the parameter passed is not null? In the real world scenario, I have more than 3 columns and I do not want to write lots of IF blocks.

    Please help gurus!

    Published by: Kuul13 on September 18, 2009 13:26

    Hello

    Maybe this,.

    Create OR Replace Procedure TMP_PROC( pPOL_NUM  IN Number
                                        , pOED      IN Date
                                        , pTERM     IN Number
                                        , pTRANS_CD IN Varchar2 ) As
    Begin
       UPDATE TEMP
          SET OED      = NVL(POED     , OED )
            , TERM     = NVL(PTERM    , TERM )
            , TRANS_CD = NVL(PTRANS_CD, TRANS_CD )
        WHERE POL_NUM = PPOL_NUM;
       Commit;
    Exception
       When Others Then
          Null;
    End;
    

    Kind regards
    Christian Balz

  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • How to eliminate duplicates in this table

    SELECT sti.item,
    MI: ITEM_DESC,
    Count (STI. Item) item_count,.
    d.dept_name,
    d.group_no,
    d.BUD_INT,
    STI.standard_unit_retail,
    ISC.unit_cost,
    margin (sti.standard_unit_retail - isc.unit_cost).
    Count (STI. Item) *(STI.standard_unit_retail-ISC.unit_cost) total_amount,.
    County (sti.item) * isc.unit_cost Tot_Sales,.
    STH. TRAN_DATETIME
    Of
    sa_tran_item sti,
    item_supp_country Sai,
    IM item_master,
    STARTING d,
    sth sa_tran_head
    WHERE
    STI. Item = isc.item
    and sti.item = im.item
    and d.DEPT = sti. DEPT
    and sth. TRAN_SEQ_NO = sti. TRAN_SEQ_NO
    and sth. TRAN_DATETIME between: p1 and: p2
    Group of sti.item, im. ITEM_DESC, d.dept_name, d.group_no, d.BUD_INT, sti.standard_unit_retail, isc.unit_cost)
    STI.standard_unit_retail - isc.unit_cost), STH. TRAN_DATETIME

    When I combine this STH. TRAN_DATETIME I have some duplicate values in STH. TRAN_DATETIME repeated dates... How to avoid duplicates and at the same time the group the STH. TRAN_DATETIME...
    Please help... urgent

    Hello

    If you mean that you must get rid of time, then you can put TRUNC around STH. TRAN_DATETIME:

     SELECT sti.item,
    im.ITEM_DESC,
    COUNT(sti.item) item_count,
    d.dept_name,
    d.group_no,
    d.BUD_INT,
    sti.standard_unit_retail,
    isc.unit_cost,
    ( sti.standard_unit_retail-isc.unit_cost ) margin,
    count(sti.item)*(sti.standard_unit_retail-isc.unit_cost) total_amount,
    count(sti.item)*isc.unit_cost Tot_Sales,
    trunc(sth.tran_datetime) TRAN_DATETIME
    FROM
    sa_tran_item sti,
    item_supp_country isc,
    item_master im,
    deps d,
    sa_tran_head sth
    WHERE
    sti.item = isc.item
    and sti.item=im.item
    and d.DEPT=sti.DEPT
    and sth.TRAN_SEQ_NO = sti.TRAN_SEQ_NO
    and sth.TRAN_DATETIME between :p1 and :p2
    group by sti.item, im.ITEM_DESC, d.dept_name, d.group_no, d.BUD_INT, sti.standard_unit_retail, isc.unit_cost, (
    sti.standard_unit_retail-isc.unit_cost ), trunc(STH.TRAN_DATETIME)
    

    Herald tiomela
    http://htendam.WordPress.com

Maybe you are looking for