Automatic item code

Hello

I want to generate an automatic code (created by adding two or more columns).

for example PO_no ID Po_type company point

LPO001 001 LPO ABC XYZ
IPO002 002 IPO ABC XYZ

po_no = (PO_type + ID)

Please help, thanks

Depending on your version of the database unknown/mentioned, you can opt for a virtual column:

SQL> create table t as
  2  select '001' id, 'LPO' po_type, 'ABC' company, 'XYZ' item from dual union
  3  select '002', 'IPO', 'ABC', 'XYZ' from dual;

Table created.

SQL> select * from t;

ID  PO_ COM ITE
--- --- --- ---
001 LPO ABC XYZ
002 IPO ABC XYZ

2 rows selected.

SQL> alter table t add po_no varchar2(10) generated always as (po_type||id) virtual;

Table altered.

SQL> select * from t;

ID  PO_ COM ITE PO_NO
--- --- --- --- ----------
001 LPO ABC XYZ LPO001
002 IPO ABC XYZ IPO002

2 rows selected.

http://www.Oracle-base.com/articles/11g/virtual-columns-11gr1.php
If you are not on the version 11.1 of the database, or to leave, you can use a trigger that would insert the po_no insert.

See the SQL and PL/SQL FAQ if you don't know the version of your database or how do I get.
The FAQ can be found here: https://forums.oracle.com/forums/ann.jspa?annID=1535
More precisely:
{message: id = 9360002}

Tags: Database

Similar Questions

  • Cc of Dreamweaver; (to integrate youtube) audio plays automatically in code view.  How do you keep from who?

    Dreamweaver cc

    Windows 7

    I have a youtube embed

    " < iframe width ="560"height ="315"src =" https://www.YouTube.com/embed/HKWjYV_OvvI?rel=0 & AutoPlay = 1 "frameborder ="5"allowfullscreen > < / iframe > "

    When the sound play automatically mode code.

    How this can be avoided.

    Try to disable Live View.

    Either way, autoplay is bad news.  Nobody likes to have the media play the loading of the page.  Mobile devices don't recognize autoplay.  This is not to protect unwanted user of bandwidth data plans. Media is something that should be offered, but used with great consideration for the end user. YouTube doesn't autoplay is usually not their media. Shouldn't you. Please let your site visitors start the download.

    Nancy O.

  • Sequence number to generate an item Code

    Dear friend

    I want to change my existing master finished painting and want to give a fresh article number in the following way.

    ITEM_TYPE ID
    ----------- --------------------

    RAW 100000001
    CYLINDER 200000001
    300000001 ENGINEERING
    VARIOUS 400000001
    500000001 PRODUCTS FINISHES

    Can you suggest me which application I should give. While in short time I can update my itemmaster with new item code table.

    Sandy

    First Exchange with the item_type, then a numeric sequence number?

    declare
    cursor types is
      select distinct item_type, rownum n
        from items ;
    begin
      for r in c loop
         update items
           set id = r.n||to_char(rownum,'FM00000000')
         where item_type=r.item_type;
      end loop;
    end;
    /
    

    Max
    [My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

  • Toshiba laptop drive automatic error Code 10

    Im getting a code 10 on my laptop drive automatic backup of toshiba. Ive tried uninstalling and reinstalling just says cannot start the device. I think im missing a hardware device driver, but I can't find this driver anywhere online. Can someone please help:)

    Hello Chan,

    I found your posts on the Toshiba site, I take it no luck with the new replica? Also, have you tried to contact Toshiba technical support? It seems that they have heard of this problem before (based on many previous occasions this problem came) .f you don't have, I would say that you communicate with them.

    That said, two possible solutions from another thread which may apply to your situation:

    1. Sometimes if a USB port not properly initialize on startup Windows installs a "unknown device" driver by default. Of course nothing plugged port at this time won't work. Sometimes it can continue to attribute this driver on the same port on subsequent reboots. Search for all entries 'unknown device' under Controllers USB in Device Manager then uninstall them. Right click on "Find the hardware changes" or reset must be reinstalled the correct USB device driver.
    2. The problem with the hard drive occurs if you turn on the USB drive after that the computer was started? Some interfaces of USB drive can interfere with Windows to detect the USB controller that they are connected correctly. Only seems to happen if the player is powered on while Windows starts.

    I guess that Technical Support Toshiba offers these strategies you anyway, so you can as well try now them. Let me know if this helps you.

    Kind regards

    BearPup

  • Automatic update code 8024400

    I have just re-installed windows xp and now I am unable to run automatic updates to message 0x8024400A.

    Whenever I try to view the answers on the forum they were all empty.

    I am at a loss total here someone can help.

    Hi neil_499

    Try this.

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-windows_update/error-number-0x8024400a/c9601a08-1745-401e-baa8-5e7dc90d2333

    Let us know if this is the answer by marking.

  • Buy new activation for first 13 items code?

    I have the first 13 (bought on Amazon 1-2 years) elements. I have the box it came, and it is installed on my computer. It seems that I need another activation code because we have maximum number of computers, on which it may be. First of all, how computers can be on? Secondly, how can I simply buy another activation code? Still once, I don't need the software, just another code to get this to work on my new PC.

    • Serial numbers (what you call activation codes) are necessary to enable the software to use.
    • You can install the software on as many computers you like, but you can enable it only for use on up to two computers at the same time, and you cannot use a version on both
    • You can install it on your new PC, but you can not activate it with your existing serial number until that deactivate you it on one of your other computers
    • Adobe sells only the current version of their software. Premiere Elements is currently in version 14. Thus, you can not buy a serial number for version 13 of Adobe. However it is perhaps not necessary if all you need to do is toggle between computers activations.
  • How to select the library item (Code)

    I want to play a part of the scene - and when it's done, add another symbol from the library (on stage and play / delete the one that was on the scene)

    Problem is that I don't know how to select items in the library. I tried

    all the var = sym. $('*');

    Console.log (SYM, All);

    but he selects only the elements of the scene.

    Thank you!

    You must use

    sym.createChildSymbol ('libraryitemname', 'Stage');

    Then, you have to use css to place them on the stage.

    example:

    redBox var = sym.createChildSymbol ('redBox', 'Stage');

    redBox.element.css ({"top": 50, 'left': 350});

    or in a container:

    redBox var = sym.createChildSymbol ('redBox', 'container');

    example: https://app.box.com/s/wawh6efg25b701htahjj

    Check out my blog here: http://www.edgehero.com/tutorials/scope

  • Something is damaged: automatic formatting Code, Flash CS3


    Not sure if this is the forum to post, but someone here would know where the thought and kindly me directly if I am in the wrong place!

    I got Flash CS3 Pro installed for a while, but am only now use it regularly as AS 3.0 projects were rare...

    However, now that I am, I am driven insane by the AutoFormat code that removes parentheses and break all my code by changing the meaning of the code. As far I can do, it is specific to my machine - which implies something is damaged. So, I uninstalled all versions of Flash and reinstalled CS3 specifically.

    The problem, it is formatting of the code is still dangerously buggy and now (because I uninstalled Flash 8) I have more code formatting even for AS 2.0!

    Has anyone encountered this before?

    Any ideas how to get past?

    G

    PS: as an additional room of questionnaires that can be linked, Flash player is not correctly now reported while I get 'Install the plugins flash' warnings of a few sites even though I have it and it works fine.

    I would like to contact adobe directly

  • Item code appears in a numeric data type in essbase

    Hello guys!

    I'm having a problem with the code element whenever I try to create a data loading rules file using ms excel as a data source. I have this GTIN codes as 8000001, 8000002, etc. on excel, but when I open it in essbase, dataprep editor the article code looks something like 8000001.00000, 8000002.00000, etc. It now bears the decimals and once I have perform a data load, essbase throws an error something like "Member not found 8000001.00000 in the database.

    This problem does not exist when I transfer data from excel to text format.

    Can you please tell me what causes this problem?

    Thanks in advance.

    The issue is that you have the colukmn in excel as a numeric column. The column should be text. You may need to format in adda apostrophe in front of the member names

  • RAXTRX: Question Auto invoice - invoice without item Code line

    Hello

    I am importing invoices from a flat file.  I filled INVENTORY_ITEM_ID in the RA_INTERFACE_LINES_ALL table. 


    Invoice is created successfully.  But, the invoice lines created without ITEM_CODE.

    Can let me know what Miss me.

    Best regards / Prasanth

    Have you install autoinvoice rules don't mention that you will pass id and no value.

    Thank you

    Avinash Zodpe

  • Modify the html code in the page you are viewing automatically

    How to change automatically certain code of html on certain web pages in firefox

    As on the Web pages, I can right click inspect element and it will allow me to remove things off the page.

    I want that to happen automatically for certain Web pages when it contains some html code

    I tend to write scripts customized for this sort of thing, but for a couple of goal solvents more general, you might investigate:

  • Adding menu items to Contacts

    I have an application that I want to add to the Contacts Menu using MENUITEM_ADDRESSBOOK_LIST. In the Simulator, I run the application and it adds to the menu (using the example code for the function t.test with). Whenever I run it, it adds another instance of the menu item. Now the questions:

    (1) the user should click on this app to add it to the menu?

    (2) what happens when the device is restarted? They will have to run the application again to add it to the menu yet?

    (3) how can I determine that menuitem has already been added and not keep adding every time that the application runs?

    Thanks for the help

    You must configure your application as an application 'auto start' (see the project properties in the JDE).

    You have two entry points - the "automatic" Startup entry point and the GUI entry point.

    You will add your menu item in the "automatic" startup code

    See this link:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Confi...

    There is also an example of this in the developer's guide.

  • Adding code to each line at the same time?

    Is it possible to do this? Instead of having to select 400 separate lines and put the list around them item code, is it possible to make it to each line individual all at once? I really hope that nothing. I'm sitting here thinking, "there must be an easier way." Please, tell me there!

    Thank you!
    -Alyse

    Is the problem that you have plain text of 400 lines, and you are wanting
    to wrap

  • Tags around each line automatically? If so, try to stick a
    copy all the text in a separate empty file, then go in Edition > search
    and replace.

    Just a heads-up - I'm on a Mac, so if you're on a Windows computer, the
    keyboard shortcuts may vary a little.

    For the search field, enter the character of CR - on my Mac, I have to
    Hold down the command (probably the control in Windows) key while hitting
    Check back for it leaves the input field. That should put a line break
    in the search field.

    For the replacement field, enter this:

  • ... and then, place the cursor between 2 tags and it shift-return (or
    -have to insert a line break).

    If you run find/replace, should replace all line breaks, so
    you will need too just add the opening:



    • .. .and closing...

    There may be a better GUI or regex how to do in DW, but how is it
    I know what to do (if it is still what you ask).

    CuteAlyse wrote:
    > Is it possible to do this? Instead of having to select 400 separate lines and
    > put around them, list item code is possible to do in each
    > single-line at the same time? I really hope that nothing. I'm sitting here to make
    > this, thinking, "there must be an easier way." Please, tell me there!
    >
    > Thank you!
    > - Alyse
    >

  • error code 80080005

    Windows cannot check the date automatically, error code 80080005. I have windows starter edition, windows update is also on the start window. do I need to get a different Windows program?

    Hello

    refer to these similar topics for your answer:

    1st link:

    2nd link:
    3rd link:
    Hope you find your answer here! and please specify your version of Windows.
  • Single SQL query for the analysis of the date of customs declaration under the table of Stock codes

    Dear all,


    Please tell us a single SQL query for the below,

    We have a Table of Stock as shown below,

    STOCK_TABLE

     

    ITEM_CODE

    (item code)

    BAT_NO

    (lot no.)

    TXN_CODE

    (transaction code)

    DOC_NO

    (number)

    BOE_DT

    (date of the customs declaration)

    I1

    B1

    I1

    I2

    I3

    B70

    I4

    B80

    I5

    B90

    T102

    1234

    JULY 2, 2015

    I6

    B100

    We have to find the date of customs declaration (i.e. the date when the items have come under this particular table) for items that are not attached to any document (that is, who have TXN_CODE, DOC_NO and BOE_DT fields with a NULL value).

    For each item in the table of actions, which is not attached to any document, the customs declaration date is calculated as follows.

    1. If (code section, lot number) combination is present under HISTORY_TABLE, the date of customs declaration will receive the UPDT_DT, the transaction code (TXN_CODE) is an IN or transactions (which can be analyzed from the TRANSACTIONS table).

    2. If (code section, lot number) combination is NOT currently at the HISTORY_TABLE (or) the transaction code respective to item - batch number combination code is an operation then customs declaration date will be the date of the document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD that contains the element of that particular lot.

  • If the case 1 and case 2 fails, our customs declaration date will be the last date of document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD containing that particular item and the BAT_NO in expected results will be that corresponding to this document, as appropriate, to another NULL.

  • If the case 1 or case 2 is successful, the value of the last field (in the output expected, shown further below) BATCH_YN will be 'Y', because it fits the lot. Otherwise it will be 'n'.
  • HISTORY_TABLE

     

    ITEM_CODE

    BAT_NO

    TXN_CODE

    DOC_NO

    UPDT_DT

    I1

    B1

    T1

    1234

    JANUARY 3, 2015

    I1

    B20

    T20

    4567

    MARCH 3, 2015

    I1

    B30

    T30

    7890

    FEBRUARY 5, 2015

    I2

    B40

    T20

    1234

    JANUARY 1, 2015

    TRANSACTION

     

    TXN_CODE

    TXN_TYPE

    T1

    IN

    T20

    OFF

    T30

    ALL THE

    T50

    IN

    T80

    IN

    T90

    IN

    T60

    ALL THE

    T70

    ALL THE

    T40

    ALL THE

    IN_TABLE_HEAD_1

     

    H1_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H1ID1

    T1

    1234

    JANUARY 1, 2015

    H1ID2

    T70

    1234

    FEBRUARY 1, 2015

    IN_TABLE_ITEM_1

     

    I1_SYS_ID

    H1_SYS_ID

    (foreign key referencing H1_SYS_ID in IN_TABLE_HEAD_1)

    ITEM_CODE

    I1ID1

    H1ID1

    I1

    I1ID2

    H1ID1

    I100

    I1ID3

    H1ID2

    I3

    IN_TABLE_BATCH_1

     

    B1_SYS_ID

    TXN_CODE                DOC_NO

    (now in IN_TABLE_HEAD_1)

    BAT_NO

    B1ID1

    T1

    1234

    B1 / can be empty

    B1ID2

    T70

    1234

    B70

    IN_TABLE_HEAD_2

     

    H2_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H2ID1

    T30

    4567

    FEBRUARY 3, 2015

    H2ID2

    T60

    1234

    JANUARY 3, 2015

    IN_TABLE_ITEM_2

     

    I2_SYS_ID

    H2_SYS_ID

    (foreign key referencing H2_SYS_ID in IN_TABLE_HEAD_2)

    ITEM_CODE

    I2ID1

    H2ID1

    I1

    I2ID2

    H2ID1

    I200

    I2ID3

    H2ID2

    I2

    IN_TABLE_BATCH_2

     

    B2_SYS_ID

    I2_SYS_ID

    (foreign key referencing I2_SYS_ID in IN_TABLE_ITEM_2)

    BAT_NO

    B2ID1

    I2ID1

    B30 / null

    B2ID2

    I2ID2

    B90

    B2ID2

    I2ID3

    B60

    IN_TABLE_HEAD_3

     

    H3_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H3ID1

    T50

    1234

    JANUARY 2, 2015

    H3ID2

    T80

    1234

    JANUARY 3, 2015

    H3ID3

    T90

    1234

    JANUARY 4, 2015

    H3ID4

    T40

    1234

    AUGUST 5, 2015

    IN_TABLE_ITEM_3

     

    I3_SYS_ID

    H3_SYS_ID

    (foreign key referencing H3_SYS_ID in IN_TABLE_HEAD_3)

    ITEM_CODE

    BAT_NO

    I3ID1

    H31D1

    I2

    B50

    I3ID2

    H3ID2

    I4

    B40

    I3ID3

    H3ID3

    I4

    I3ID4

    H3ID4

    I6

    There is no IN_TABLE_BATCH_3

    Please find below the expected results.

    OUTPUT

     

    ITEM_CODE

    BAT_NO

    TXN_CODE

    DOC_NO

    BOE_DT

    BATCH_YN

    I1

    B1

    T1

    1234

    JANUARY 3, 2015

    THERE

    I1

    B30

    T30

    7890

    FEBRUARY 5, 2015

    N

    I2

    B60

    T60

    1234

    JANUARY 3, 2015

    N

    I3

    B70

    T70

    1234

    FEBRUARY 1, 2015

    THERE

    I4

    T90

    1234

    JANUARY 4, 2015

    N

    I6

    T40

    1234

    AUGUST 5, 2015

    N

    Controls database to create the tables above and insert the records.

    CREATE TABLE stock_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), boe_dt DATE );

    INSERT EN stock_table

       VALUES ('I1', 'B1', '', '', '');

    INSERT EN stock_table

       VALUES ('I1', '', '', '', '');

    INSERT IN stock_table

       VALUES ('I2', '', '', '', '');

    INSERT EN stock_table

       VALUES ('I3', 'B70', '', '', '');

    INSERT EN stock_table

       VALUES ('I4', 'B80', '', '', '');

    INSERT EN stock_table

       VALUES ('I5', 'B90', 'T102', '1234', '02-JUL-2015');

    INSERT EN stock_table

       VALUES ('I6', 'B100', '', '', '');

    SELECT *

    FROM stock_table




     

    CREATE TABLE history_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), updt_dt DATE );

    INSERT IN history_table

       VALUES ('I1', 'B1', 'T1', '1234', '03-JAN-2015');

    INSERT IN history_table

       VALUES ('I1', 'B20', 'T20', '4567', '03-MAR-2015');

    INSERT IN history_table

       VALUES ('I1', 'B30', 'T30', '7890', '05-FEB-2015');

    INSERT IN history_table

       VALUES ('I2', 'B40', 'T20', '1234', '01-JAN-2015');

    SELECT *

    FROM history_table




     

    CREATE TABLE transaction1()txn_code VARCHAR()80),txn_type VARCHAR()80));


    INSERT INTO transaction1

       VALUES ('T1', 'IN');


    INSERT INTO transaction1

       VALUES ('T20', 'OUT');

    INSERT INTO transaction1

       VALUES ('T30', 'ALL');

    INSERT INTO transaction1

       VALUES ('T40', 'ALL');

    INSERT INTO transaction1

       VALUES ('T50', 'IN');

    INSERT INTO transaction1

       VALUES ('T60', 'ALL');

    INSERT INTO transaction1

       VALUES ('T70', 'ALL');

    INSERT INTO transaction1

       VALUES ('T80', 'IN');

    INSERT INTO transaction1

       VALUES ('T90', 'IN');

    SELECT *

    FROM transaction1




     

    CREATE TABLE in_table_head_1()h1_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

    CREATE TABLE in_table_head_2()h2_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

    CREATE TABLE in_table_head_3()h3_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

     

    INSERT IN in_table_head_1

       VALUES ('H1ID1', 'T1', '1234', '01-JAN-2015');

    INSERT IN in_table_head_1

       VALUES ('H1ID2', 'T70', '1234', '01-FEB-2015');

    INSERT IN in_table_head_2

       VALUES ('H2ID1', 'T30', '4567', '03-FEB-2015');

    INSERT IN in_table_head_2

       VALUES ('H2ID2', 'T60', '1234', '03-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID1', 'T50', '1234', '02-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID2', 'T80', '1234', '03-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID3', 'T90', '1234', '05-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID4', 'T40', '1234', '05-AUG-2015');




     

    CREATE TABLE in_table_item_1()i1_sys_id VARCHAR2()80) PRIMARY KEY,

    h1_sys_id VARCHAR2 (80) REFERENCES in_table_head_1()h1_sys_id),item_code VARCHAR2()80));

    CREATE TABLE in_table_item_2()i2_sys_id VARCHAR2()80) PRIMARY KEY,

    h2_sys_id VARCHAR2 (80) REFERENCES in_table_head_2()h2_sys_id),item_code VARCHAR2()80));

    CREATE TABLE in_table_item_3(i3_sys_id VARCHAR2(80) PRIMARY KEY,

    h3_sys_id VARCHAR2 (80) REFERENCES in_table_head_3()h3_sys_id),item_code VARCHAR2()80),

    bat_no VARCHAR2 (80));

     

    INSERT IN in_table_item_1

       VALUES ('I1ID1', 'H1ID1', 'I1');

    INSERT IN in_table_item_1

       VALUES ('I1ID2', 'H1ID1', 'I100');

    INSERT IN in_table_item_1

       VALUES ('I1ID3', 'H1ID2', 'I3');

    INSERT IN in_table_item_2

       VALUES ('I2ID1', 'H2ID1', 'I1');

    INSERT IN in_table_item_2

       VALUES ('I2ID2', 'H2ID1', 'I200');

    INSERT IN in_table_item_2

       VALUES ('I2ID3', 'H2ID2', 'I2');

    INSERT IN in_table_item_3

       VALUES ('I3ID1', 'H3ID1', 'I2','B50');

    INSERT IN in_table_item_3

       VALUES ('I3ID2', 'H3ID2', 'I4','B40');

    INSERT IN in_table_item_3

       VALUES ('I3ID3', 'H3ID3', 'I4','');

    INSERT IN in_table_item_3

       VALUES ('I3ID4', 'H3ID4', 'I6','');

    SELECT *

    FROM in_table_item_1

    SELECT *

    FROM in_table_item_2

    SELECT *

    FROM in_table_item_3




     

    CREATE TABLE in_table_batch_1()b1_sys_id VARCHAR2()80) PRIMARY KEY,

    txn_code VARCHAR2 (80), doc_no VARCHAR2 (80), bat_no VARCHAR2 (80));

    CREATE TABLE in_table_batch_2()b2_sys_id VARCHAR2()80) PRIMARY KEY,

    i2_sys_id VARCHAR2 (80) REFERENCES in_table_item_2()i2_sys_id),bat_no VARCHAR2()80));

     

    INSERT IN in_table_batch_1

       VALUES ('B1ID1', 'T1', '1234', 'B1');

    INSERT IN in_table_batch_1

       VALUES ('B1ID2', 'T70', '1234', 'B70');

    INSERT IN in_table_batch_2

       VALUES ('B2ID1', 'I2ID1', 'B30');

    INSERT IN in_table_batch_2

       VALUES ('B2ID2', 'I2ID2', 'B90');

    INSERT IN in_table_batch_2

       VALUES ('B2ID3', 'I2ID3', 'B60');

    Please advise a solution for the same.

    Thank you and best regards,

    Séverine Suresh

    very forced (question subfactoring used to allow easy testing/verification - could work with these test data only)

    with

    case_1 as

    (select s.item_code,

    s.bat_no,

    h.txn_code,

    h.doc_no,

    h.updt_dt boe_dt,

    cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.

    cases where h.txn_code is not null

    and h.doc_no is not null

    and h.updt_dt is not null

    then 'case 1' '.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, boe_dt

    of w_stock_table

    where bat_no is null

    or txn_code is null

    or doc_no is null

    or boe_dt is null

    ) s

    left outer join

    w_history_table h

    On s.item_code = h.item_code

    and s.bat_no = h.bat_no

    and exists (select null

    of w_transaction1

    where txn_code = nvl (s.txn_code, h.txn_code)

    and txn_type in ('IN', 'ALL')

    )

    ),

    case_2 as

    (select s.item_code,

    NVL (s.bat_no, h.bat_no) bat_no.

    NVL (s.txn_code, h.txn_code) txn_code.

    NVL (s.doc_no, h.doc_no) doc_no.

    NVL (s.boe_dt, h.updt_dt) updt_dt.

    cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.

    cases where h.txn_code is not null

    and h.doc_no is not null

    and h.updt_dt is not null

    then 'case 2'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, boe_dt

    of case_1

    where refers_to is null

    ) s

    left outer join

    w_history_table h

    On s.item_code = h.item_code

    and exists (select null

    of w_transaction1

    where txn_code = nvl (s.txn_code, h.txn_code)

    and txn_type in ('IN', 'ALL')

    )

    and not exists (select null

    of case_1

    where item_code = h.item_code

    and bat_no = h.bat_no

    and txn_code = h.txn_code

    and doc_no = h.doc_no

    and updt_dt = h.updt_dt

    )

    ),

    case_31 as

    (select s1.item_code,

    NVL (S1.bat_no, W1.bat_no) bat_no.

    NVL (S1.txn_code, W1.txn_code) txn_code.

    NVL (S1.doc_no, W1.doc_no) doc_no.

    NVL (S1.updt_dt, W1.doc_dt) updt_dt.

    cases where s1.bat_no = w1.bat_no then 'Y' else ' n end batch_yn.

    cases where w1.txn_code is not null

    and w1.doc_no is not null

    and w1.doc_dt is not null

    then "case 31'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s1

    left outer join

    (select i1.item_code, h1.txn_code, h1.doc_no, h1.doc_dt, b1.bat_no

    of w_in_table_item_1 i1

    inner join

    w_in_table_head_1 h1

    On i1.h1_sys_id = h1.h1_sys_id

    inner join

    w_in_table_batch_1 b1

    On h1.txn_code = b1.txn_code

    and h1.doc_no = b1.doc_no

    ) w1

    On s1.item_code = w1.item_code

    ),

    case_32 as

    (select s2.item_code,

    NVL (S2.bat_no, W2.bat_no) bat_no.

    NVL (S2.txn_code, W2.txn_code) txn_code.

    NVL (S2.doc_no, W2.doc_no) doc_no.

    NVL (S2.updt_dt, W2.doc_dt) updt_dt.

    cases where s2.bat_no = w2.bat_no then 'Y' else ' n end batch_yn.

    cases where w2.txn_code is not null

    and w2.doc_no is not null

    and w2.doc_dt is not null

    then "case 32'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s2

    left outer join

    (select i2.item_code, h2.txn_code, h2.doc_no, h2.doc_dt, b2.bat_no

    of w_in_table_item_2 i2

    inner join

    w_in_table_head_2 h2

    On i2.h2_sys_id = h2.h2_sys_id

    inner join

    w_in_table_batch_2 b2

    On i2.i2_sys_id = b2.i2_sys_id

    ) w2

    On s2.item_code = w2.item_code

    ),

    case_33 as

    (select s3.item_code,

    w3.bat_no,

    NVL (S3.txn_code, w3.txn_code) txn_code.

    NVL (S3.doc_no, w3.doc_no) doc_no.

    NVL (S3.updt_dt, w3.doc_dt) updt_dt.

    cases where s3.bat_no = w3.bat_no then 'Y' else ' n end batch_yn.

    cases where w3.txn_code is not null

    and w3.doc_no is not null

    and w3.doc_dt is not null

    then "case 33'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s3

    left outer join

    (select i3.item_code, h3.txn_code, h3.doc_no, h3.doc_dt, i3.bat_no

    of w_in_table_item_3 i3

    inner join

    w_in_table_head_3 h3

    On i3.h3_sys_id = h3.h3_sys_id

    ) w3

    On s3.item_code = w3.item_code

    )

    Select item_code, bat_no, txn_code, doc_no, boe_dt, batch_yn

    of case_1

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_2

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn,

    ROW_NUMBER() over (partition by item_code of updt_dt desc order) rn

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_31

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_32

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_33

    where refers_to is not null

    )

    )

    where rn = 1

    ITEM_CODE BAT_NO TXN_CODE DOC_NO BOE_DT BATCH_YN
    I1 B1 T1 1234 JANUARY 3, 2015 THERE
    I1 B30 T30 7890 FEBRUARY 5, 2015 N
    I2 B60 T60 1234 JANUARY 3, 2015 N
    I3 B70 T70 1234 FEBRUARY 1, 2015 THERE
    I4 - T90 1234 JANUARY 5, 2015 N
    I6 - T40 1234 AUGUST 5, 2015 N

    Concerning

    Etbin

Maybe you are looking for