Inventory table
hi,
how to find out 'INVENTORY' tables...i used select * from tab where TNAME like '%INV%';
but it just gave two views as output
plz help
Annex
Annex wrote:
the table which are used for inventory...actually my senior today told me to see the inventory tables..i searched for them a lot but no use
plz helpYour senior might have meant the tables which stores the inventory of the application. These application can be very specific to your organization and might be nothing to do with Oracle in general. This application might have created the tables/objects in the database as an inventory but could be having a different name.
So check with your collegue/senior what are the name of the tables that is used to store the inventory of the application.
If your senior meant dictionary objects of Oracle (i.e where oracle stores the data dicitionary/metadata) then let us know which specific data you want.
Regards
Anurag
Similar Messages
-
Identify if an item is a Raw Material or Finished Goods? Inventory Table
Hello All,
How do we identify Material_type - whether the goods received is a Raw Material or a Finished Goods. (it should be in some Inventory Table )
I need to find out from which table and which column do I get this information from?Hi ,
In Inventory concepts, the table "MTL_SYSTEM_ITEMS_B" holds the definitions for inventory items, engineering items, and purchasing items.
So if you were not sure what the item type is of then check the following table for item description in 'Description' Column, set the language and source_language columns to your required language
1. "MTL_SYSTEM_ITEMS_TL"
In specific to finished goods use the following query
SELECT ITEM_TYPE
FROM MTL_SYSTEM_ITEMS_B
WHERE ITEM_TYPE = 'FG'; /******** Here FG = Finished Goods.
In others ( like Raw Material received from ) use the following item_type whichever applies to your requirement,
I - Inventory Type
P - Purchased item
SI - Supply item.
Regards,
@P
Edited by: 995022 on Mar 21, 2013 10:55 PM -
Hi,
Can anyone let me know what is the table for physical inventory which are carried out for warehouse.
I want to know the table in which my before count and after count results gets posted.
SunilHi
Check the table ISEG and element ERFMG and MENGE for counted quantity and book quantity.
Thanks -
Hi,
I would like to get your help regarding the following questions:
In order to get the following information: Quantity of inventory in stock for each product- What table do I need?
Is it possible to define number of days in which inventory in production can be in stock regarding to each product? If the answer is yes, how can I see this definition for each product in the system?
In order to set a tolerance for inventories clear differences, is the definition is per product? How can I get the tolerance info defined in the system?there are many different tables with stock information in SAP, partly they have redundand info.
mard, "storage location stock
mchb, "batch stock
mkol, "vendor consignment
msca, "customer order stock at vendor
mska, "customer order stock
msku, "customer consignment
mslb, "subcontracting stock
mspr, "project stock
LQUA "warehouse stock
MBEW " valuated stock
e.g. if your material is batch managed own stock, then you can find the stock in MARD (without batch information) and in MCHB separated by batch number.
if this stock is valuated, then you can find it as well in MBEW
however, if you have a customer return of this batch number, then this customer return is not valuated, and MARD has the complete quantity in your storage location, but MBEW shows only the quantity that is valuated.
What do you mean by inventory in production? You can have a shelf life for a material, but this is valid wherever the material is, you cannot have a number of days for the time the material is located in the production area only.
you can define tolerance groups per company code in OMJ2, this tolerance is not material specific. -
Cannot find Site Inventory table in Logging database in SharePoint 2013
I'm trying to build an Analysis Services cube based on the wss_logging SharePoint 2013 database, like I did some times ago in SharePoint 2010.
I'm extracting Site Sizes for example from the sitesize table. My problem is that all sites are referenced by their Id, and I can't find any table in the WSS_Logging database that convert Id's into Url (or anything readable). In SharePoint 2010, there was
a table named SiteInventory that did the job, but it seems that the timerjob related to this table no longer exists in SharePoint 2013 (the job name was Site Collection Usage if I remember right).
Any idea where I can (easily) find the correspondance Id - Site Name in SQL Server Logging database ? Or somewhere else (but remember I must use it in Analysis Services) ?
Regards.Hi Bolebo,
Thank you for your question.
We are currently looking into this issue and will give you an update as soon as possible.
Thank you for your understanding and support.
Best Regards,
Wendy
Wendy Li
TechNet Community Support -
Need Interactive Report EBiz 11.5.9 inventory tables and views over DB Link
I need to create an Interactive report on this SQL:
select glcc.segment4 as ENTITY_CODE
, glcc.segment2 as DEPARTMENT_NUMBER
, glcc.segment1 as Account
, ai.VENDOR_NUMBER as VENDOR_NUMBER
, ai.VENDOR_NAME as VENDOR_NAME
, aiv.DESCRIPTION as DESCRIPTION
-- , aiv.period_name
, aiv.AMOUNT as INVOICE_DISTRIBUTION_AMOUNT
, aiv.INVOICE_NUM as INVOICE_NUM
, aiv.PO_NUMBER as PO_NUMBER
, trunc(aiV.ACCOUNTING_DATE,'DD') as GL_DATE
, aipv.CHECK_AMOUNT as CHECK_AMOUNT
, aipv.CHECK_DATE as CHECK_DATE
, aipv.CHECK_NUMBER as CHECK_NUMBER
, glcc.segment3 as FUNDING_SOURCE
, glcc.segment5 as IC
-- ,to_char(aiv.INVOICE_DATE,'MON-YY') INVOICE_DAT\
-- ,aiv.DISTRIBUTION_LINE_NUMBER
from
apps.ap_invoice_distributions_V@FIN_PRD aiv
,apps.Ap_invoices_v@FIN_PRD ai
,apps.ap_invoice_payments_v@FIN_PRD aipv
,apps.gl_code_combinations@FIN_PRD glcc
where 1=1
and aiv.INVOICE_ID=aipv.INVOICE_ID(+)
and ai.INVOICE_ID=aiv.invoice_id
and aiv.PERIOD_NAME='JUL-08'
and glcc.code_combination_id=aiv.DIST_CODE_COMBINATION_ID
--and aipv.CHECK_ID is nullas you can see I am using a database link. I have the link setup and working fine on other Interactive Reports. The thing about this on is I need to run this in the connection before I run the SQL in order to see any data:
begin
dbms_application_info.set_client_info('0');
end;Any idea how I can do this?Hi Scott;
I tried this in Home>Application Builder>Application 108>Shared Components>Edit Security Attributes \"Virtual Private Database (VPD)":
if :APP_PAGE_ID = 2 then
begin
dbms_application_info.set_client_info('0');
end;
end if;
The page ran but saw no data.
Then this:
if :APP_PAGE_ID = 2 then
begin
dbms_application_info.set_client_info('0')@FIN_PRD;
end;
end if;
The page failed to run with this error:
ORA-06550: line 3, column 51: PLS-00103: Encountered the symbol "@" when expecting one of the following: := . ( % ; The symbol ":= was inserted before "@" to continue
I thought for sure this would have done it! -
Where do I find the inventory master table?
I need to search our inventory by keyword and since SAP doesn't have this capability I'd like to write a basic SQL query to find the items I'm looking for. So where do I find the inventory master table? I found the table INV1 but it only has 274 records and we have tens of thousands of inventory items in the system. I've searched Google for the databasee structure and found it but every reference to it I can find doesn't have the same tables we do. We're running SAP Business One 2007a.
Thanks!Hi,
The inventory table is OITM
one tip though is to go to the tools menu in SAP and select System Information.
You can then hover over the item master data screen and in the bottom right hand corner it will tell you not only the table name but also the field name you are hovering over.
Please note, if you log out of SAP, the next time you log in you will have to turn system information back on again.
Regards,
Adrian -
I have a master table and i need to import the rows into the parent and child table.
Master table name is Flatfile_Inventory
Parent Table name is INVENTORY
Child Tables name are INVENTORY_AMOUNT,INVENTORY_DETAILS,INVENTORY_VEHICLE,
Error details will be goes to LOG_INVENTORY_ERROR
I have 4 duplicate rows in the Flatfile_Inventory which i have already inserted in the Parent and child table.
Again when i run the query using stored procedure,
its tells that all the 4 rows are duplicate and will move to the Log_Inventory_Error.
I need is if i have the duplicate rows in the flatfile_Inventory when i start inserting into the parent and child table the already inserted row have the unique ID i
must identify it and delete that row in the both parent and chlid table.And latest row must get inserted into the Parent and child table from Flatfile_Inventory.
Please help me to write the query i have attached the Full stored procedure Script..
Arunraj KumarHi Santhosh,
This is my Script.
-- =============================================
-- Stored Procedure for FLATFILE_INVENTORY
-- =============================================
-- Drop stored procedure if it already exists
DROP PROCEDURE SP_Flatfile_Inventory
GO
CREATE PROCEDURE SP_Flatfile_Inventory
AS
--USE IconicMarketing
GO
DECLARE
@FileType varchar(50) ,
@ACDealerID varchar(50) ,
@ClientDealerID varchar(50) ,
@DMSType varchar(50) ,
@StockNumber varchar(50) ,
@InventoryDate datetime ,
@StockType varchar(100) ,
@DMSStatus varchar(50) ,
@InvoicePrice numeric(18, 2) ,
@CostPack varchar(50) ,
@SalesCost numeric(18, 2) ,
@HoldbackAmount numeric(18, 2) ,
@ListPrice numeric(18, 2) ,
@MSRP varchar(max) ,
@LotLocation varchar(50) ,
@TagLine varchar(max) ,
@Certification varchar(max) ,
@CertificationNumber varchar(max) ,
@VehicleVIN varchar(50) ,
@VehicleYear bigint ,
@VehicleMake varchar(50) ,
@VehicleModel varchar(50) ,
@VehicleModelCode varchar(50) ,
@VehicleTrim varchar(50) ,
@VehicleSubTrimLevel varchar(max) ,
@Classification varchar(max) ,
@TypeCode varchar(100) ,
@VehicleMileage bigint ,
@EngineCylinderCount bigint ,
@TransmissionType varchar(50) ,
@VehicleExteriorColor varchar(50) ,
@VehicleInteriorColor varchar(50) ,
@CreatedDate datetime ,
@LastModifiedDate datetime ,
@ModifiedFlag varchar(max) ,
@InteriorColorCode varchar(50) ,
@ExteriorColorCode varchar(50) ,
@PackageCode varchar(50) ,
@CodedCost varchar(50) ,
@Air varchar(100) ,
@OrderType varchar(max) ,
@AgeDays bigint ,
@OutstandingRO varchar(50) ,
@DlrAccessoryRetail varchar(50) ,
@DlrAccessoryCost varchar(max) ,
@DlrAccessoryDesc varchar(max) ,
@ModelDesc varchar(50) ,
@Memo1 varchar(1000) ,
@Memo2 varchar(max) ,
@Weight varchar(max) ,
@FloorPlan numeric(18, 2) ,
@Purchaser varchar(max) ,
@PurchasedFrom varchar(max) ,
@InternetPrice varchar(50) ,
@InventoryAcctDollar numeric(18, 2) ,
@VehicleType varchar(50) ,
@DealerAccessoryCode varchar(50) ,
@AllInventoryAcctDollar numeric(18, 2) ,
@BestPrice varchar(50) ,
@InStock bigint ,
@AccountingMake varchar(50) ,
@GasDiesel varchar(max) ,
@BookValue varchar(10) ,
@FactoryAccessoryDescription varchar(max) ,
@TotalReturn varchar(10) ,
@TotalCost varchar(10) ,
@SS varchar(max) ,
@VehicleBody varchar(max) ,
@StandardEquipment varchar(max) ,
@Account varchar(max) ,
@CalculatedPrice varchar(10) ,
@OriginalCost varchar(10) ,
@AccessoryCore varchar(10) ,
@OtherDollar varchar(10) ,
@PrimaryBookValue varchar(10) ,
@AmountDue varchar(10) ,
@LicenseFee varchar(10) ,
@ICompany varchar(max) ,
@InvenAcct varchar(max) ,
@Field23 varchar(max) ,
@Field24 varchar(max) ,
@SalesCode varchar(max) ,
@BaseRetail varchar(10) ,
@BaseInvAmt varchar(10) ,
@CommPrice varchar(10) ,
@Price1 varchar(10) ,
@Price2 varchar(10) ,
@StickerPrice varchar(10) ,
@TotInvAmt varchar(10) ,
@OptRetail varchar(max) ,
@OptInvAmt varchar(10) ,
@OptCost varchar(10) ,
@Options varchar(max) ,
@Category varchar(max) ,
@Description varchar(max) ,
@Engine varchar(max) ,
@ModelType varchar(max) ,
@FTCode varchar(max) ,
@Wholesale varchar(max) ,
@Retail varchar(max) ,
@Draft varchar(max) ,
@Inventoryid int;
DECLARE Inventory_Cursor CURSOR FOR
SELECT * from [dbo].[FLATFILE_INVENTORY];
OPEN Inventory_Cursor
FETCH NEXT FROM Inventory_Cursor
INTO @FileType ,
@ACDealerID ,
@ClientDealerID ,
@DMSType ,
@StockNumber ,
@InventoryDate ,
@StockType ,
@DMSStatus ,
@InvoicePrice ,
@CostPack ,
@SalesCost ,
@HoldbackAmount ,
@ListPrice ,
@MSRP ,
@LotLocation ,
@TagLine ,
@Certification ,
@CertificationNumber ,
@VehicleVIN ,
@VehicleYear ,
@VehicleMake ,
@VehicleModel ,
@VehicleModelCode ,
@VehicleTrim ,
@VehicleSubTrimLevel ,
@Classification ,
@TypeCode ,
@VehicleMileage ,
@EngineCylinderCount ,
@TransmissionType ,
@VehicleExteriorColor ,
@VehicleInteriorColor ,
@CreatedDate ,
@LastModifiedDate ,
@ModifiedFlag ,
@InteriorColorCode ,
@ExteriorColorCode ,
@PackageCode ,
@CodedCost ,
@Air ,
@OrderType ,
@AgeDays ,
@OutstandingRO ,
@DlrAccessoryRetail ,
@DlrAccessoryCost ,
@DlrAccessoryDesc ,
@ModelDesc ,
@Memo1 ,
@Memo2 ,
@Weight ,
@FloorPlan ,
@Purchaser ,
@PurchasedFrom ,
@InternetPrice ,
@InventoryAcctDollar ,
@VehicleType ,
@DealerAccessoryCode ,
@AllInventoryAcctDollar ,
@BestPrice ,
@InStock ,
@AccountingMake ,
@GasDiesel ,
@BookValue ,
@FactoryAccessoryDescription ,
@TotalReturn ,
@TotalCost ,
@SS ,
@VehicleBody ,
@StandardEquipment ,
@Account ,
@CalculatedPrice ,
@OriginalCost ,
@AccessoryCore ,
@OtherDollar ,
@PrimaryBookValue ,
@AmountDue ,
@LicenseFee ,
@ICompany ,
@InvenAcct ,
@Field23 ,
@Field24 ,
@SalesCode ,
@BaseRetail ,
@BaseInvAmt ,
@CommPrice ,
@Price1 ,
@Price2 ,
@StickerPrice ,
@TotInvAmt ,
@OptRetail ,
@OptInvAmt ,
@OptCost ,
@Options ,
@Category ,
@Description ,
@Engine ,
@ModelType ,
@FTCode ,
@Wholesale ,
@Retail ,
@Draft ;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @VehicleVIN ;
-- ****************** insert into Inventory Table ***********
INSERT INTO INVENTORY
IconicDealerID,
StockNumber,
DMSType,
InventoryDate
VALUES (@ClientDealerID,@StockNumber,@DMSType,@InventoryDate);
set @Inventoryid = scope_identity();
PRINT @Inventoryid;
--Insert into Inventory_Details Table
INSERT INTO [INVENTORY_DETAILS]
InventoryID,
StockType,
DMSStatus,
LotLocation,
TagLine,
Certification,
CertificationNumber,
CreatedDate,
LastModifiedDate,
ModifiedFlag,
PackageCode,
OrderType,
AgeDays,
OutstandingRO,
Memo1,
Memo2,
Purchaser,
PurchasedFrom,
DealerAccessoryCode,
InStock,
AccountingMake,
SS,
Account,
AccessoryCore,
ICompany,
InvenAcct,
Field23,
Field24,
SalesCode,
Draft,
FTCode
VALUES (
@InventoryID,
@StockType,
@DMSStatus,
@LotLocation,
@TagLine,
@Certification,
@CertificationNumber,
@CreatedDate,
@LastModifiedDate,
@ModifiedFlag,
@PackageCode,
@OrderType,
@AgeDays,
@OutstandingRO,
@Memo1,
@Memo2,
@Purchaser,
@PurchasedFrom,
@DealerAccessoryCode,
@InStock,
@AccountingMake,
@SS,
@Account,
@AccessoryCore,
@ICompany,
@InvenAcct,
@Field23,
@Field24,
@SalesCode,
@Draft,
@FTCode
--Insert into Inventory_Amount Table
INSERT INTO [dbo].[INVENTORY_AMOUNT]
InventoryID,
AllInventoryAcctDollar,
OtherDollar,
PrimaryBookValue,
AmountDue,
LicenseFee,
CalculatedPrice,
OriginalCost,
BookValue,
TotalReturn,
TotalCost,
DlrAccessoryRetail,
DlrAccessoryCost,
DlrAccessoryDesc,
InternetPrice,
InventoryAcctDollar,
BestPrice,
Weight,
FloorPlan,
CodedCost,
InvoicePrice,
CostPack,
SalesCost,
HoldbackAmount,
ListPrice,
MSRP,
BaseRetail,
BaseInvAmt,
CommPrice,
Price1,
Price2,
StickerPrice,
TotInvAmt,
OptRetail,
OptInvAmt,
OptCost,
Wholesale,
Retail
VALUES (
@InventoryID,
@AllInventoryAcctDollar,
@OtherDollar,
@PrimaryBookValue,
@AmountDue,
@LicenseFee,
@CalculatedPrice,
@OriginalCost,
@BookValue,
@TotalReturn,
@TotalCost,
@DlrAccessoryRetail,
@DlrAccessoryCost,
@DlrAccessoryDesc,
@InternetPrice,
@InventoryAcctDollar,
@BestPrice,
@Weight,
@FloorPlan,
@CodedCost,
@InvoicePrice,
@CostPack,
@SalesCost,
@HoldbackAmount,
@ListPrice,
@MSRP,
@BaseRetail,
@BaseInvAmt,
@CommPrice,
@Price1,
@Price2,
@StickerPrice,
@TotInvAmt,
@OptRetail,
@OptInvAmt,
@OptCost,
@Wholesale,
@Retail
--Insert into Inventory_Vehicle Table
INSERT INTO [dbo].[INVENTORY_VEHICLE]
InventoryID,
InteriorColorCode,
ExteriorColorCode,
Air,
ModelDesc,
VehicleType,
VehicleVIN,
VehicleYear,
VehicleMake,
VehicleModel,
VehicleModelCode,
VehicleTrim,
VehicleSubTrimLevel,
Classification,
TypeCode,
VehicleMileage
VALUES (
@InventoryID,
@InteriorColorCode,
@ExteriorColorCode,
@Air,
@ModelDesc,
@VehicleType,
@VehicleVIN,
@VehicleYear,
@VehicleMake,
@VehicleModel,
@VehicleModelCode,
@VehicleTrim,
@VehicleSubTrimLevel,
@Classification,
@TypeCode,
@VehicleMileage
-- Move cursor to Next record
FETCH NEXT FROM Inventory_Cursor
INTO @FileType ,
@ACDealerID ,
@ClientDealerID ,
@DMSType ,
@StockNumber ,
@InventoryDate ,
@StockType ,
@DMSStatus ,
@InvoicePrice ,
@CostPack ,
@SalesCost ,
@HoldbackAmount ,
@ListPrice ,
@MSRP ,
@LotLocation ,
@TagLine ,
@Certification ,
@CertificationNumber ,
@VehicleVIN ,
@VehicleYear ,
@VehicleMake ,
@VehicleModel ,
@VehicleModelCode ,
@VehicleTrim ,
@VehicleSubTrimLevel ,
@Classification ,
@TypeCode ,
@VehicleMileage ,
@EngineCylinderCount ,
@TransmissionType ,
@VehicleExteriorColor ,
@VehicleInteriorColor ,
@CreatedDate ,
@LastModifiedDate ,
@ModifiedFlag ,
@InteriorColorCode ,
@ExteriorColorCode ,
@PackageCode ,
@CodedCost ,
@Air ,
@OrderType ,
@AgeDays ,
@OutstandingRO ,
@DlrAccessoryRetail ,
@DlrAccessoryCost ,
@DlrAccessoryDesc ,
@ModelDesc ,
@Memo1 ,
@Memo2 ,
@Weight ,
@FloorPlan ,
@Purchaser ,
@PurchasedFrom ,
@InternetPrice ,
@InventoryAcctDollar ,
@VehicleType ,
@DealerAccessoryCode ,
@AllInventoryAcctDollar ,
@BestPrice ,
@InStock ,
@AccountingMake ,
@GasDiesel ,
@BookValue ,
@FactoryAccessoryDescription ,
@TotalReturn ,
@TotalCost ,
@SS ,
@VehicleBody ,
@StandardEquipment ,
@Account ,
@CalculatedPrice ,
@OriginalCost ,
@AccessoryCore ,
@OtherDollar ,
@PrimaryBookValue ,
@AmountDue ,
@LicenseFee ,
@ICompany ,
@InvenAcct ,
@Field23 ,
@Field24 ,
@SalesCode ,
@BaseRetail ,
@BaseInvAmt ,
@CommPrice ,
@Price1 ,
@Price2 ,
@StickerPrice ,
@TotInvAmt ,
@OptRetail ,
@OptInvAmt ,
@OptCost ,
@Options ,
@Category ,
@Description ,
@Engine ,
@ModelType ,
@FTCode ,
@Wholesale ,
@Retail ,
@Draft ;
END
CLOSE Inventory_Cursor;
DEALLOCATE Inventory_Cursor;
GO
SET ANSI_PADDING OFF
GO
Arunraj Kumar -
11gR2 Data Pump. Import table in one schema into a different schema
I stady oracle. I export shema HR into file hrexport.dmp. When I import tables from this file I had trouble. I used Enterprise Manager:
1. connected by user SYSTEM as NORMAL
2. selected file, chosen import type - tables
3. data from file was imported
4. chosen tables which tables to import
5. in the next step I try insert row in table Re-Map Shemas and edit cell Destination Shema, but in the list is only one name of shema - HR! Why?
Edited by: alvahtin on 10.03.2013 6:11Paul M. wrote:
Did you try using impdp command at OS prompt ?I don't know what this command use. I try:
impdp system/oracle remap_schema=hr:inventory tables=employees, departments, locations directory=ORACLES_HOME dumpfile=hrexport.dmp logfile=hrimport.log
But it finished with error:
ORA-39166: Object SYSTEM.EMPLOYEES was not found.
ORA-39166: Object SYSTEM.DEPARTMENTS was not found.
ORA-39166: Object SYSTEM.LOCATIONS was not found.
Job "SYSTEM"."SYS_IMPORT_TABLE_01" successfully completed at 18:43:19
Job "SYSTEM"."SYS_IMPORT_TABLE_01" successfully completed at 18:43:19
Why SYSTEM? I want import to INVENTORY from HR - replaced in the file hrexport.dmp -
Autocomplete from another table in another sheet in same file
I found how to get a price to autofill using VLOOKUP. I like it.
Now, I want to be lazier and not need to type in the full item name in the row heading completely & exactly every time. I also don't want to have a drop down menu in every item line in each table unless there is no better alternative. I would like Numbers to autofill from an inventory list (table with quantities, prices, etc.) in another sheet. It seems that I should have been able to find this function explained but my searches were inadequate.
Then, I will want Numbers to automatically update another column in the inventory table with the quantity of that item sold & the amount remaining which will cause calculations for the value remaining & sold in other columns (without changing the original inventory column). It seems to me that the formula may require numbers to search each table in each sheet for the item name in that row and add all sale quantities together. This means that the formulas would be constantly searching which sounds like it could slow things down a bit. So, again, maybe there's a more efficient way of doing this.
Please help me find these efficiency tools. ThankUMr. "P" wrote:
I want to copy an entire row from one table in one sheet to another table in another sheet retaining all values and formulas? So that if I make a change in the original sheet it propagates to the other sheet
(1) A change in the original will propagate to the other table if the change is in the 'copied' row.
(2) what you require can't be achieve by a copy process.
It requires the use of external references which are perfectly described in the User Guide (page 122 in the English version).
(3) sure, a reference is a cell's attribute so you will have to enter it in every cell of the row.
When it's done for one row you may use the Fill Down tool which is also described (with quite all you need to use Numbers) in the User Guide.
Yvan KOENIG (from FRANCE vendredi 19 juin 2009 15:53:03) -
Inventory by LocationId (were locations are hierarchical)
Hi,
I have a problem with an inventory system I'm designing. It is an inventory system by LocationId. The problem I have is that the locations are hierarchical. By hierarchical I mean that a given location might belong to a next location.
For example given the following (simplified) schema of 3 tables (Locations, Articles and Inventory)
CREATE TABLE Locations (
LocationId INTEGER NOT NULL,
ParentLocationId INTEGER NULL,
CONSTRAINT w_Ub_LLAVE PRIMARY KEY (LocationId)
GO
INSERT INTO Locations (LocationId,ParentLocationId) VALUES (1,NULL);
INSERT INTO Locations (LocationId,ParentLocationId) VALUES (2,NULL);
INSERT INTO Locations (LocationId,ParentLocationId) VALUES (3,NULL);
INSERT INTO Locations (LocationId,ParentLocationId) VALUES (4,1);
INSERT INTO Locations (LocationId,ParentLocationId) VALUES (5,4);
INSERT INTO Locations (LocationId,ParentLocationId) VALUES (6,4);
INSERT INTO Locations (LocationId,ParentLocationId) VALUES (7,5);
CREATE TABLE Articles (
ItemId INTEGER NOT NULL,
Description VARCHAR(50),
CONSTRAINT ArticlePK PRIMARY KEY (ItemId)
GO
INSERT INTO Articles (ItemId,Description) VALUES (100,'BREAD');
CREATE TABLE Inventory (
LocationId INTEGER NOT NULL,
ItemId INTEGER NOT NULL,
Qty DECIMAL(14,4) NULL,
CONSTRAINT InventoryPK PRIMARY KEY (LocationId,ItemId)
GO
INSERT INTO Inventory (LocationId,ItemId,Qty) VALUES (1,100,5);
INSERT INTO Inventory (LocationId,ItemId,Qty) VALUES (2,100,5);
INSERT INTO Inventory (LocationId,ItemId,Qty) VALUES (3,100,5);
INSERT INTO Inventory (LocationId,ItemId,Qty) VALUES (4,100,5);
INSERT INTO Inventory (LocationId,ItemId,Qty) VALUES (5,100,5);
INSERT INTO Inventory (LocationId,ItemId,Qty) VALUES (6,100,5);
INSERT INTO Inventory (LocationId,ItemId,Qty) VALUES (7,100,5);
I would like to list the contents by locationId.
For example, if I list LocationId=1 I should get
5 (in LocationId = 1) +
5 (in LocationId = 4 which belongs to 1) +
5 (in LocationId=5 which belongs to 4 which belongs to 1) +
5 (in LocationId=6 which belongs to 4 which belongs to 1) +
5 (in LocationId=7 which belongs to 5 which belongs to 4 which belongs to 1)
= 25
If I list LocationId=7 I would only get 5 (those in locationId=7)
If I list LocationId=5 I would bet 10 (those in LocationId=5 and those in LocationId=7).
Hopefully I was able to explain myself. Does anybody know how this could be done?
Thanks,
EdgardOne way to solve this is expanding the hierarchy starting from the node in question all the way down till the last descendant. Then you can join the result to the inventory table to aggregate.
DECLARE @LocationId int =5;
WITH TC AS (
SELECT
LocationId AS ReportsTo,
LocationId
FROM
Locations
WHERE
LocationId = @LocationId
UNION ALL
SELECT
P.ReportsTo,
C.LocationId
FROM
TC AS P
INNER JOIN
Locations AS C
ON C.ParentLocationId = P.LocationId
SELECT
A.ReportsTo,
B.ItemId,
SUM(B.Qty) AS sum_Qty
FROM
TC AS A
INNER JOIN
Inventory AS B
ON A.LocationId = B.LocationId
GROUP BY
A.ReportsTo,
B.ItemId
GO
It gets a little bit more complicated if you want to see all locations, their quantities and the aggregation of the descendants.
WITH TC AS (
SELECT
LocationId AS ReportsTo,
LocationId
FROM
Locations
UNION ALL
SELECT
P.ReportsTo,
C.LocationId
FROM
TC AS P
INNER JOIN
Locations AS C
ON C.ParentLocationId = P.LocationId
, Agg AS (
SELECT
A.ReportsTo,
B.ItemId,
SUM(CASE WHEN A.ReportsTo = B.LocationId THEN B.Qty END) AS Qty,
SUM(B.Qty) AS TotalQty
FROM
TC AS A
INNER JOIN
Inventory AS B
ON A.LocationId = B.LocationId
GROUP BY
A.ReportsTo,
B.ItemId
, LocHie AS (
SELECT
LocationId,
CAST(LocationId AS varbinary(900)) AS SortBy,
0 AS lvl
FROM
Locations
WHERE
ParentLocationId IS NULL
UNION ALL
SELECT
C.LocationId,
CAST(P.SortBy + CAST(ROW_NUMBER() OVER(PARTITION BY P.LocationId ORDER BY C.LocationId) AS binary(8)) AS varbinary(900)),
P.lvl + 1
FROM
LocHie AS P
INNER JOIN
Locations AS C
ON C.ParentLocationId = P.LocationId
SELECT
REPLICATE('|', 8 * lvl) + LTRIM(A.LocationId) AS LocId,
B.ItemID,
B.Qty,
B.TotalQty
FROM
LocHie AS A
LEFT OUTER JOIN
Agg AS B
ON A.LocationId = B.ReportsTo
ORDER BY
A.SortBy;
GO
This approach will not perform well if you have too many levels in the hierarchy and a procedural approach that traverses each level at a time, starting from the leaves, will perform better.
Itzik Ben-Gan has a whole chapter dedicated to Graph theory in his book "Inside Microsoft® SQL Server® 2008: T-SQL Querying".
http://shop.oreilly.com/product/9780735626034.do
AMB
Some guidelines for posting questions... -
Comparing two columns in two tables using partial text strings and copying data between tables
I have two tables:
The Vendor table is supplied by a clothing manufacturer and lists product data by row with a column that contains a unique manufacturer ID, such as T5C4. In this table is a short product description and a long product description that I need to find and copy into the second table, Inventory.
The Inventory table is an export from our Magento store. Each row contains a unique inventory number in a column that includes but does not match the unique manufacturer ID from the Vendor table. For example, the unique inventory number could be T5C4-W12, or RED-T5C4W12 or some other variation.
For each product in Inventory, I need to find the matching product in Vendor, and then copy the short description and long description from Vendor to Inventory.
Any tips? Thanks!
KarlKarl,
Here's a start, as you requested.
The formula for Our Inventory Row is:
=IFERROR(MATCH("*"&A&"*", Our Inventory :: A, 0), "n/a")
The formula for Brief Description in the inventory table is:
=IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 2), "n/a")
The formula for the Full description in the inventory table is:
=IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 3), "n/a")
The Manufacturer's table knows the concise product numbers, so it has the ability to search the Inventory table for it's product id's using wildcards and it then displays the line number of the item in the inventory table. The Inventory table can then search the manufacturer's table for its row number and can reference the brief and full descriptions.
This approach has a serious limitation. It will only find the first occurrence in the inventory. Now, if you want to accept this, you can sort all the found descriptions and pull them out of the inventory table, and then the next product in line will display it's description too.
I wish I could do better with this, but it's all I can come up with at this point, knowing only what you have told me.
Jerry -
How to parse XML Column and insert values into a table
Hello,
I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
The table that needs to be loaded is as follows:
create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
The XML document is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thank you for any help you can offer.First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
EDIT: In your code right here:
select xt.*
3 from Inventory inve,
4 XMLTable('/dataroot/Inventory'
5 PASSING inve.Inv
I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
END EDIT
EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
END EDIT2
drop table InventoryOut;
create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt;
select * from InventoryOut;
select * from v$version;
table INVENTORYOUT dropped.
table INVENTORYOUT created.
Error starting at line 4 in command:
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt
Error at Command Line:8 Column:12
Error report:
SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
PARTNUMBER QTY WHLOCATION
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
If this helps here is the code and output for the creation of the Inventory table itself:
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
directory XMLSRC created.
table INVENTORY dropped.
table INVENTORY created.
1 rows inserted.
INV
<?xml version="1.0" encoding="WINDOWS-1252"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thanks again for your help so far! Hope we can get this working :)
Edited by: 926502 on Apr 11, 2012 2:47 PM
Edited by: 926502 on Apr 11, 2012 2:49 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM -
"Referenced" Table Cells not copying formatting of the source table
Hi-
I have one sheet that has a rental inventory table that is quite large. On another page, I have a "printable" version that has filtering applied to hide certain columns.
What I did orginally was duplicate the table on the inventory page, cut it, then go to my printable sheet, and paste it. I now have a duplicate version of the original. Then I go and select all cells, hit delete and all the contents disappear leaving me with the correct formating.
At this point I can type in cells and see that the formating is intact (certain cells are in Bold for example).
I delete the test contents, then reference the first cell (a1) to the source table, then copy the references across that entire printable table. Once I've done that, all of the contents of the source table now appear in the "printable" table.
The problem is, that once I reference the source table, the formatting goes away. The data shows up correctly: ie, =Equip List :: B2, but the specific cell formating is gone.
What am i doing wrong here?
Thanks
Matt"I delete the test contents, then reference the first cell (a1) to the source table, then copy the references across that entire printable table."
If you do this by selecting and Copying the first cell containing the formula, that "copy" includes the formatting of the copied cell. If you then Paste, the Paste includes that format setting. You could try Edit > Paste and Match format.
If that doesn't work, you could try this:
Enter, then fill the formula as you've done, then set the format of each cell or group of cells to include the attributes you want at that location.
Regards,
Barry -
Check what records are missing in child tables when compared to Primary tables
I have a person table(200 records with 200Persons),Column Person Id (PK),FN, LN,USERNAME and there are 13 tables which are referenced by Person id ex: Attachement table has a column UpdatedPersonid
ex: Inventory table has a column ModifiedbyPersoind
like wise I have 13 child tables...
What i need to find is which person is not active , which means i have to find which personid is not exists in any 13 tables, so that i can delete the person from Personid (person table)....I know a way to do for each table, but i am more
interested in a single query to find which user is not active ..
Please help me ..ThanksSelect p.PersonID, p.FN, p.LN, p.USERNAME
FROM Persons p
Where Not Exists(Select * From Table1 t Where p.PersonID = t.PersonID)
And Not Exists(Select * From Table2 t Where p.PersonID = t.PersonID)
And Not Exists(Select * From Table3 t Where p.PersonID = t.PersonID)
And Not Exists(Select * From Table13 t Where p.PersonID = t.PersonID)
Tom
Maybe you are looking for
-
I get this when trying to get an appMod, any clues? JBO-29000: Unexpected exception caught: oracle.jbo.common.ampool.ApplicationPoolException, msg=JBO-30003: The application pool (fsweb.jbo.account.AccountModule) failed to checkout an application mod
-
I see only a small cross when i want to use my pinsel o rubber.
I see only a small cross when i want to use my pinsel o rubber in Photoshop CC. I would like to see a circle that change the size, when i need it big or small. Can somebody tell me how to change this, please?
-
Hello, I have generated a simple VI, to make multiplication and division operations. I have the following operation performed with the following inputs. A1 has a value range from 1 -10 fixed A2 has an input range of 1 - 5 A3,A4 are constants. so Resu
-
I recently migrated to the Photos app on my Mac. I previously used iPhoto. I would often rename my images from my iPhone (ex. 001, 002, 003) in order so that I can burn them to a DVD. However, when the album was migrated to Photos, it no longer shows
-
Hi Experts, Can anybody plz send me the table where the request number of a function module get stored. (Function groups are stored in E071,But i need the request number for function module.) Regards, Anoop Chandran