transactions table
In the concepts of Oracle 11 g R2 is indicated that "the database uses an operating table, also called a list of self-dealing (ITL), to determine if a transaction is not validated when the database has begun to change the block. The block of each block of the segment header contains an operating table. «by http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/consist.htm#i13945 but the link provided for the transactions table that points of sentence in the box of glossary and he says: "transactions table: the data structure in a rollback segment that contains the identifiers of the transaction of operations using the rollback segment.» »In the same folder to another chapter (here http://download.oracle.com/docs/cd/E14072_01/server.112/e10713/transact.htm) says "A transaction ID is unallocated until a slot table undo segment and transaction are allocated, which occurs in the course of the first statement DML."
In order to present the transaction is located in the rollback segment (in the header I guess)? This transaction table provides information such as: the financial statements included in a transaction, pointers to undo blocks for a transaction, commit State, commit YVERT?
If in the first sentence, they talk abot LAUGHS, LAUGHS as blocks of information on the State of validation of the transaction?
A1: No, it is in the fixed area of the SGA. (There are more components to the LMS than just different pools).
A2: It is there no Q2.
A3: A slot is allocated in the rollback segment header. This identifies the transaction via the XID. Space to write the actual cancellation records, enter the body of the undo segment, and this piece of spaced is indicated by information in the header undo slot.
A4: Yes, all these scriptures initially arrive only in the redo log buffer. Before that any block can be updated, no matter if it is a block cancellation or a block of data, the change must be protected by redo.
A5: Yes, the ITL slot has the XID, so it literally means the transaction. This is how keep us track of the operation 'show interest' in this data block.
A6: Don't know what you're asking here. Yes, only the updated data is written to cancel, and any changes made by a specific transaction are written to the same rollback segment.
Hope that answers all your questions,
-Mark
Tags: Database
Similar Questions
-
transaction tables consistent reads - undo records applied
Hello
on 11.2.0.4 on Linux
In the documentation, it is said:
The report of the following
V$SYSSTAT
statistics should be close to a:ratio = transaction tables consistent reads - undo records applied / transaction tables consistent read rollbacks
And the recommendation is that the recommended solution is to use automatic undo management...
We are in automatic cancellation, but the ratio is 38:
SQL > show Cancel parameter
VALUE OF TYPE NAME
------------------------------------ ----------- --------
UNDO_MANAGEMENT string AUTO
SELECT name, value of V$ SYSSTAT whose name in ("transaction tables consistent reads - undo records applied",
("tables of compatible transactions read restorations")
NAME VALUE ---------------------------------------------------------------- ---------------------------------------
transaction tables consistent reads - undo records applied 38 operating tables consistent read recommitments 1 2 selected lines
So, what would be the reasons and the solution?
Thank you.
This is a good demonstration of why it's a bad idea to blindly follow the ratios.
Once since your instance starts, you had to use 38 undo records to discover the time of validation of a specific transaction. The performance impact of that verification is virtually invisible - worst case, it is you read 38 undo disk blocks to get the necessary information. All you have is an example where a query ran long enough so that a few hundred to a few thousands of transactions were hiding at the time of a transaction that committed at the same time that the query started - try to 'solve the problem' is a waste of time.
Concerning
Jonathan Lewis
-
Cancellation and the transactions Table segment
Hello
I'm confused.
As a rollback segment can have about 34 locations of transaction in his operating table in 11g, and we will have 10 segments to cancel first, that must surely mean that we cannot have 340 concurrent transactions at a time, Yes? But we can have more, and it's confusing me.
I read the core Oracle JL at the moment, I'm sure he explained it this way and that the weakness is in my opinion and I did not understand something, but if someone can help me here it would be appreciated.
Thank you.>
Does this mean that Oracle will have to create a new rollback segment
>
You already know the answer to that.Through the book, slowly and carefully and imagine examples like this one you read. Then try to confirm the finding the sections that talk about this issue. The one complaint I have about the book is that the index is not very useful. I would like to see more references, especially for key words.
But two pages more than where we were before you can find it in ' beginning and end of the Transaction "on Page 28
>
When a session starts a transaction, it chooses a rollback segment, selects an entry from the operating table, increment the film #...
>
So if the ITL, if it is FULL (each slot used by a current transaction) there are only two choices: wait until a slot opens, or create a new rollback segment. -
SNA committed to header Undo (Transaction table) slot
Hello
When ever a transaction was committed committed RCS is saved with the vector of change in recovery and newspapers to the space reserved for this transaction in the rollback segment header.
At some point later in time another session can read one of these blocks and discover that the ITL includes a transaction that has committed but not cleaned. (He
can work that cross the ITL entry with the location for the transaction concerned in the segment undo header block).
My Question is: at the next session visit this block, what happens if the slot of the cancellation was written more (this can happens to the lack of space to cancel and or the time after validation reached cancel retention).
Please clarify my doubts?
-Thank you
VijayIf the Undo tablespace is full and no Cancel slots are available (i.e., all are uncomitted all active transactions, operations), you get an error. New transactions cannot continue without undo space.
Hemant K Collette
-
Sequence table large transaction
Hi team,
Could you please give me some suggestions on below!
For large transaction table where millions of records have been loaded to present on a daily basis, and if the sequence has also reached the maximum value. How to manage the situation
Thank you
SQL > select spell_number (999999999999999999999999999) double;
SPELL_NUMBER (999999999999999999999999999)
--------------------------------------------------------------------------------
9.223372036854775807 trillion nine hundred ninety nine sextillion Hun
Dred 9.223372036854775807 trillion nine hundred ninety - nine quadrillion Nine Hundred N
inety - trillion-nine 9.99900000099 mi
Ninety nine thousand nine hundred ninety - nine hundred billionSQL >
If you have reached this number of records? In this case, you need to have your primary key a Composite key and add another column and reset this sequence.
-
transactions in rollback segments table
Hi guys,.
I read the following, but I'm still having a bit of difficulty to conceptualize. Someone would be so kind to give me a very brief example?
Thank you
For each rollback segment, Oracle maintains a table of transaction - a list of all transactions that use the associated rollback segment and entries of restoration for each change made by these operations.Whenever the transaction happens, there is an entry that is maintained by oracle to control that in which the segment, in which block cancellation of the transaction is maintained. The table which is now it is called Transaction table. The transaction entry is maintained for giving this information of cancellation for queries that seek when you need for coherent picture playback. Location of corresponding cancellation information are also maintained in the header of the block also Transaction as cancel Byte Address (UBA).
The operating table is for us, V$ transaction. If you look at the XIDUSN, XIDSLOT, XIDSQN columns in this table, you would be able to see the segment where the cancellation of the transaction is maintained. Fixed to cancel arrays are x$ ktuxe and x$ ktcxb (hopefully, I did not error in names).
I'll see if I can find good paper describing this.
Update:Here are two links that I hope will be useful.
http://www.evdbt.com/AutomaticUndoInternals.PDF
http://www.juliandyke.com/presentations/RedoInternals.ppDo a lot of block of dumping, a very good way to know this stuff.
HTH
Aman...Published by: Aman... on March 10, 2009 01:10
-
expand the category drop-down list table in the model of checkbook
Using version 2.3 of numbers 09. Try to understand the model section for checkbook and to expand the available categories in the menu drop-down allows to assign a category to an entry in the checkbook. Where would we go to learn this procedure.
Hi Robert,.
This is as good one place as any.
If you have started using the model and have defined categories for all operations, make changes to the cells in these rows. Fill the pop-up menu edited cells wil also reset the value of each cell filled to the currently selected value in the source cell to this filling.
Add new categories to a cell in the context menu
In the Transactions table, click any cell to the row and column reference tabs appear.
Line control grip (red arrow in the image below) and drag to the bottom to add a new line. The new line will contain a new copy of the cell from the popup menu in the category column. Click this cell to select it.
In the bar of buttons above the workspace, click the Inspector button to open the Inspector, and then click the format cell [42] button to go to the cell format Inspector.
You will see the list of the menu items for the selected cell. The list below are a pair of buttons marked + and - (blue arrow). To add a new item to the menu, click on the button +.
The new item appears at the bottom it has the list, with its highlighted text as shown. Type the new category name.
Repeat for as many new features that you need.
You can also edit the items already in the list.
Double-click an existing item to select the text. Type the new name for the item.
When you are finished, close the Inspector.
The menu changes are applied immediately and affect only the menu in the modified cell, and cells, this version of the menu is filled in. If you add a new line to the bottom of the table, for example, the edition menu of line 15 will be filled in the new line.
Add a new category to the account categories table
The new category is not automatically added to the category table account. When you add it, ensure that there is an exact match between the label of the table and the category in the menu.
Click any cell in the account categories table to select it.
Enter the line control handle and drag down to add as many lines as necessary.
Note that the totals in a footer line moves down and the new lines are added above it.
Fill in the new lines of the new category (or categories). *
If you have completed transactions for these categories, these will be totaled in the B column and adds the total in the footer line, but not yet appear on the pie chart.
Add the new categories on the pie chart
Click the pie chart to select it and show its data source.
Data for the graph comes from the cells defined by the selection (in blue) rectangle. The cells shown in white on a background come from the chart legend labels black in column A of the table in the colors of the wedge can be seen in the box beside the category name (and can be changed by clicking on the box, and then choosing a new color in the fill color in the toolbar).
To add the new category to the table, place the mouse pointer on the small handful (circle in the lower right corner of the selection rectangle. When the pointer changes into a Black plus sign, click and drag down to lock the new categories, which will be instantly assigned a color and added to the graph.
Click anywhere outside the objects onscreen to deselect all objects, and then save your work.
* To ensure matched spelling between the menus and the list of categories, select one of the new cells of menu and copy. Select one (or all) cells new category on the table of the types of accounts and paste. Specify each menu to the new categories, and then select all the cells in the new category. In the format of cell Inspector, use the context menu to change the format of these cells to the text. This removes the attribute from popup menu of the cells, leave the text as it was when the last value.
Kind regards
Barry
-
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.
- 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).
- 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'.
-
Oracle 11g with too many years of data in tables
I have a facility with transactional tables that has records for many years. Queries on these tables are slow and I need to solve this problem in order to improve the speed of my application.
I think deleting all records of the past five years, but it's going to be a very complex task. I heard an order to mark some records in a table like inmmutables so applications will treat them in a different way and then I won't need to delete anything.
Anyone heard of this solution? What are the commands and steps to do?
Thank you
With the archiving of data, or any deletion of data, you can get a performance improvement, or you can't get any improvement.
I heard an order to mark some records in a table like inmmutables so applications will treat them in a different way and then I won't need to delete anything.
Where have you heard of such a device? Are you sure that this is a feature of Oracle?
-
Sorry for the wrongly posted Question.
I have a table of Bank Transaction table. I want to display the account number Date wise sages deposits and withdrawals and closing balance.
CREATE TABLE bank_transaction
(acc_no VARCHAR2 (20 BYTE),
trn_dt DATE,
trn_type CHAR (1 BYTE),
trn_amt NUMBER (10.2)
);
/ * D - deposits and withdrawals-W * /.
INSERT INTO bank_transaction
VALUES (TO_DATE '100', ('2015-03-17 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS), HAS ', 6000);
INSERT INTO bank_transaction
VALUES (TO_DATE '100', ('2015-03-24 00:00:00 ',' YYYY-MM-DD HH24:MI:SS'), 'W', 5000);
INSERT INTO bank_transaction
VALUES (TO_DATE '100', ('2015-03-25 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS), HAS ', 10000);
INSERT INTO bank_transaction
VALUES (TO_DATE '100', ('2015-03-25 00:00:00 ',' YYYY-MM-DD HH24:MI:SS'), 'W', 5000);
INSERT INTO bank_transaction
VALUES (TO_DATE '101', ('2015-03-17 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS), HAS ', 10000);
INSERT INTO bank_transaction
VALUES (TO_DATE '101', ('2015-03-24 00:00:00 ',' YYYY-MM-DD HH24:MI:SS'), 'W', 5000);
INSERT INTO bank_transaction
VALUES (TO_DATE '101', ('2015-03-25 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS), HAS ', 5000);
INSERT INTO bank_transaction
VALUES (TO_DATE '101', ('2015-03-25 00:00:00 ',' YYYY-MM-DD HH24:MI:SS'), 'W', 1500);
I want to display data like that.
Account no.: 100
Trn_dt withdrawal deposit closing ball
17-mar-2015 6000 6000
24-mar-2015 5000-1000
25-mar-2015 10000 5000-6000
Account no.: 101
17-mar-2015 10000 10000
24-mar-2015 5000 5000
25-mar-2015 5000 1500 8500
Another way: (check if it really works for all cases of your example)
----
WITH dataset
AS (SELECT acc_no,
trn_dt,
trn_type,
CASE WHEN trn_type = ' THEN trn_amt END deposit.
CASE WHEN trn_type = 'W' THEN trn_amt END withdrawl
OF bank_transaction).
penultimate_set
AS (SELECT ACC_NO,
TRN_DT,
MAX (TRN_TYPE) OVER (PARTITION BY acc_no, trn_dt) trn_type,.
MAX (DEPOSIT) OVER (PARTITION BY acc_no, trn_dt) deposit.
MAX (withdrawal) OVER (PARTITION BY acc_no, trn_dt) WITHDRAWAL.
SUM (NVL (deposit, 0) - NVL (withdrawal, 0))
COURSES (PARTITION BY acc_no ORDER BY acc_no, trn_dt)
final_sum
Of THE dataset)
SELECT DISTINCT ACC_NO, TRN_DT, DEPOSIT, WITHDRAWAL, FINAL_SUM
OF penultimate_set
ORDER BY 1, 2
Output:
ACC_NO TRN_DT DEPOSIT WITHDRAWL FINAL_SUM 100 17/03/2015 6000 6000 100 24/03/2015 5000 1000 100 25/03/2015 10000 5000 6000 101 17/03/2015 10000 10000 101 24/03/2015 5000 5000 101 25/03/2015 5000 1500 8500 See you soon,.
Manik.
-
May complete transaction undo tablespace of long duration.
Hello
Let's say we're on 9.2.0.8 and long duration of the transaction, I mean, we started some update (1 row only but no commit / rollback) and do nothing for a few days.
If the amount of the cancellation is minimal, but we wanted to cancel used slot and 1 cancellation transaction table entry.
Is this some sort of dangerous? AFAIK undo is circular buffer type so set us an upper end and prevent the new transaction to use "low".
Please provide details. I noticed that a few GUI related situation cancel 100% full, don't know if that's ok.
Concerning
GregGGregG says:
And you think more, could you tell how to solve this problem, I mean, how do you know that we are getting near disaster (ora-1555 or cancel saturated), the long-running transaction is taken only 1 unregister
so doesn't sound dangerous.I think that you could read the following blog post: http://jonathanlewis.wordpress.com/2009/10/07/undone/
Concerning
Jonathan Lewis -
Hello
I have a table (not partitioned) transactions, in an OLTP which is always get a lot of inserts (lines 600 million per day)
1. I need to archive this table each month to the historical database (oldest months exist in the transactions table)
2 - this table is usually strongly questioned by using CONNOTE_NUMBER and sometimes EVENT_DATE
3 - queries are performing well by using the current design
What is the best partitioning can I do in this scenario that I move to GR 11, 2? It's worth (I think that it is only good for archiving)?
Here is the current design
CREATE TABLE MOVEMENTS
(
CONNOTE_NUMBER VARCHAR2 (30) NOT NULL,
PARCEL_NUMBER VARCHAR2 (30) NOT NULL,
EVENT_DATE DATE NOT NULL,
RECORD_TYPE NUMBER (2) NOT NULL,
BRANCH_ID VARCHAR2 (3) NOT NULL,
ROUTE_ID VARCHAR2 (4) NOT NULL,
EVENT_SPECIFICS VARCHAR2 (80).
LAST_TOUCH_USER VARCHAR2 (9) NOT NULL,
LAST_TOUCH_DATE DATE DEFAULT SYSDATE NOT NULL,.
UPLOADED_TO_AS400 VARCHAR2 (1) DEFAULT 'N',.
REASON_CODE VARCHAR2 (2),
ACTION_CODE VARCHAR2 (2),
TRANSACTIONS_REFERENCE VARCHAR2 (7).
RECEIVING_BRANCH_ID VARCHAR2 (4).
PRE_NINE_SERVICE CHAR (1),
THIRD_PARTY_ID VARCHAR2 (8).
DG_IND VARCHAR2 (1).
WEB_DISPLAY VARCHAR2 (1).
RELINK CHAR (1)
)
CREATE INDEX TRACK_IDX_EVENT_DATE_BRANCH ON TRANSACTIONS
(EVENT_DATE, BRANCH_ID)
CREATE INDEX TRACK_UPLOADED_TO_AS400 ON TRANSACTIONS
(UPLOADED_TO_AS400)
CREATE INDEX TRACK_IDX_2 ON TRANSACTIONS
(RECORD_TYPE, EVENT_DATE)
CREATE A UNIQUE TRACK_PK ON TRANSACTIONS INDEX
(CONNOTE_NUMBER, PARCEL_NUMBER, EVENT_DATE, RECORD_TYPE)
CREATE INDEX TRACK_IDX_3 ON TRANSACTIONS
(CONNOTE_NUMBER, WEB_DISPLAY)
ALTER TABLE TRANSACTIONS ADD)
CONSTRAINT TRACK_PK
_ Of the PRIMARY KEY
(CONNOTE_NUMBER, PARCEL_NUMBER, EVENT_DATE, RECORD_TYPE)
Thanks in advancerp0428 wrote:
Billy - the OP has
>
1. I need to archive this table each month to the historical database (oldest months exist in the transactions table)
>A finer grain partition window can make a big difference in query performance. A need not only to look at data management (archiving).
Do you see a monthly rolloff being a problem?
Originally, my table more busy was range partitioned. As the insertion of the increased rate, so too the problem to get partition the DLL of enforcement against her instructions. Go to a State where I had a second window of zero for DOF on this table. This table was then divided into 100's as individual hash tables is no longer, the statements of the partition could be supported.
Now if there is a guaranteed window where maintenance type DDL is possible - maybe we can get away with using partitioning on a busy OLTP table. But when OLTP means inserts and transactions every second, 24 x 7, 7 days a week - maintenance DOF on this table will probably be a serious problem.
Could your other concerns be mitigated by annual creation of partitions following years? Thus, in December of 2012 create 12 partitions that will be needed for 2013. This would mean that only a necessary annual window for the maintenance operation.
With smaller amounts of data and coarse partitions, it is an option. With finer grain partitions, and tons of data, not really. Yes, you can create new partitions that are sufficient for the next year, or even two. But what you do with the old partitions that must be archived and consume space necessary for new data?
In order to maintain consumption of space efficient sliding window ito, you age and Archives old partitions (drop/truncate/drop). And cela you can't do once a year during the annual maintenance window.
Don't tell not the OLTP tables and partitioning are mutually exclusive. Simply say that he should be careful in the choice of your Oracle storage structures when it comes to paintings which gets 1000 times per second. And 600 million row inserts/day (my table more busy doing 3 x only), IMO falling into the category of the think-carefully-and-practise-safe-hex.
-
Deletion of rows in a table while the filter condition is in another table
Hi all
I am facing a problem of deletion of a row in a table where the condition is in the other table. To ealaborate the scenario further Let's say I have two tables T1 (the transactions table) and T2 (Master Table). I want to delete a record in the table T1 by checking conditions lies in table T2.
I tried with the query below, but this request deletion of records in the table two.
DELETE FROM (SELECT * high INNER JOIN T2 on T1 page TP)
THE top. TID = TP. TID
WHERE at the top. DEAL_SITE_ID = inputparameter1
AND (TP. SEGMENT <>inputparameter2 OR tp.segment is not null));
Here the record is deleted in the two tables, but I don't want to delete the data in my table master i.e table T2.
Any help would be much appreciated. Thanks in advance.
Kind regards
DelphineSQL> select * 2 from the_table; X Y ---------- ---------- AA a BB a CC a AA b DD b SQL> select * 2 from the_table_2; X Y ---------- ---------- AA a BB a CC a SQL> delete from 2 ( 3 select * 4 from the_table t1 inner join the_table_2 t2 5 on t1.x = t2.x 6 and t1.y = t2.y); 3 rows deleted. SQL> select * 2 from the_table; X Y ---------- ---------- AA b DD b SQL> select * 2 from the_table_2; X Y ---------- ---------- AA a BB a CC a
-
Questioning Transacation writing table
Please help me in writing a query.
I have a transaction table that has columns as transtype, ONC, kno, sno and has data as follows
SNO kno ONC transtype
________________________________
Add 1 1 1
Add 2 1 4
Add 3 1 2
4 1 4 remove
Add 5 2 1
6 2 3 remove
7 2 4 News
SNO represents the serial number
I need to retrieve data for the last transtype (transaction type) for example
When I want to the result set with transtype 'Add' the query should not return
line for kno ONC '4' and '1' because he later "delete" transaction.
Help, please.Ahh, maybe then this?
select tt.* from trans_table tt ,(select kno,cno,max(sno) as m_sno from trans_table group by kno,cno) x where x.m_sno = tt.sno and x.kno = tt.kno -- Probably redundant, since sno is a key in this table? and x.cno = tt.cno -- Ditto. and tt.trans_type='the_one_you_want';
And I'm sure it can be done 'better' with an analytic function.
-
How to fill out a sparse table with zero
Hi all
I have a sparse table, most of the cells is null, but few of the cells is '1 '.
I would like to fill the null with zero.
This table is to rotate a transactional table into a table that describes the attributes and later for data mining
I think so
(1) make a user_tab_columns and copy / paste to make a script using NVL
for example
Select ' NVL('|| column_name ||) «, 0, » || column_name |'),' of user_tab_columns
where lower (table_name) = "claims_t1".
but I have a problem
for example
create or replace view claims_t2x
as
Select
NVL ("Diagnostic Imaging' _SPEC_SUM, 0," Diagnostic Imaging' _SPEC_SUM) 'Diagnostic Imaging' _SPEC_SUM
Of
claims_t1
I get the error ORA-00911: invalid character
as the name of the column got ' ' ' in there.
or
Use 2) PL/SQL
I just do a select and loop through all
For 2), I don't know how I can get all the column attribute.
As the attribute in the table operation is not fix so the number of column after swivelling isn't fix
any idea?
-Thank you very much for your comments.
Published by: xwo0owx on April 27, 2011 11:08You can use nvl pivot by naming the values in quotes like that.
CREATE OR REPLACE VIEW emp_v1 AS WITH pivot_data AS (SELECT deptno, JOB, sal FROM emp) SELECT JOB, NVL ("10", 0) AS "10", NVL ("20", 0) AS "20", NVL ("30", 0) AS "30", NVL ("40", 0) AS "40" FROM pivot_data PIVOT (SUM (sal) --<-- pivot_clause FOR deptno --<-- pivot_for_clause IN (10, 20, 30, 40) --<-- pivot_in_clause );
G.
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
-
Since the FF13 update news FEED stopped loading/updating!
Had heard a report on it and I had the same problem immediately after updating to the latest version. I have about 50 live bookmarks on my bookmarks bar and they all stopped working. They charge not even manually - they don't show all the titles: emp
-
Boot failure: System Halted_ on Windows XP
Boot failure: System Halted_Not sure of the service pack installedNo recent changesXp home edition installation discI think that the os came preinstalledCannot start in safe mode
-
Hello! I have HP Split 13-m101er x 2 PC and I want to improve memory SSD 128 GB and 8 GB of RAM. Are there ways to do it with this PC. Thank you!
-
The characters in Windows Explorer are incorrect, but are correct in Word Pad, Jarte and other products. fake poster in the form eitoneous (of other similar problems) how ever when it is cut and pasted here it's correct! Windows 7 64 bit Pro.
-
I have copy of CS5 on the old laptop and really need to do on my newer computer operating system windows, but the purchased disk was originally lost. Help please I have improved my cameras and they are not supported in CS3 and I don't want to bother