Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert last updated by

525042Aug 20 2007 — edited Aug 23 2007
May be this is the funny question but I don't have any idea about that.

I want to insert or update last updated by column how can I do this.

Please see my below code.

Thanks,
Zeeshan

CREATE OR REPLACE PROCEDURE cinsscst
(
o_errbuf OUT VARCHAR2,
o_retcode OUT VARCHAR2,
i_org_id IN Number,
i_cost_type_id IN Number,
i_resource_id IN Number)
AS
I Number;
--v_user_id apps.cst_item_cost_details.last_updated_by%type;

BEGIN

UPDATE cst_item_cost_details cstd
SET ( cstd.USAGE_RATE_OR_AMOUNT , cstd.item_cost) = (SELECT SHG.item_cost,SHG.item_cost
FROM cost_SSCHG SHG,mtl_system_items mtl WHERE mtl.organization_id = i_org_id
AND mtl.segment1 = ltrim(rtrim(SHG.item_number))
AND mtl.organization_id= cstd.organization_id
AND mtl.inventory_item_id = cstd.inventory_item_id
AND cstd.cost_type_id = i_cost_type_id
AND CSTD.resource_id = i_resource_id
)
WHERE ( cstd.organization_id, cstd.inventory_item_id, cstd.cost_type_id , CSTD.resource_id)
IN (SELECT mtl.organization_id,mtl.inventory_item_id,i_cost_type_id,i_resource_id
FROM cost_SSCHG SHG,mtl_system_items mtl
WHERE mtl.organization_id = i_org_id
AND mtl.segment1 = ltrim(rtrim(SHG.item_number)));


INSERT INTO apps.cst_item_cost_details
(inventory_item_id
,organization_id
,cost_type_id
,last_updated_by
,last_update_date
,creation_date
,created_by
,level_type
,usage_rate_or_amount
,basis_type
,basis_factor
,net_yield_or_shrinkage_factor
,item_cost
,rollup_source_type
,cost_element_id
,resource_id)
SELECT
mtl.inventory_item_id
,mtl.organization_id
,i_cost_type_id
,1004--last updated by
,sysdate
,sysdate
,1004--last updated by
,1
,shg.item_cost
,1
,1
,1
,shg.item_cost
,1
,2
,i_resource_id

FROM cost_SSCHG SHG,mtl_system_items mtl
WHERE mtl.organization_id = i_org_id
AND mtl.segment1 = ltrim(rtrim(SHG.item_number))
AND NOT EXISTS (SELECT 1
FROM cst_item_cost_details cstd
WHERE cstd.organization_id = mtl.organization_id
AND cstd.inventory_item_id = mtl.inventory_item_id
AND cstd.cost_type_id = i_cost_type_id
AND cstd.resource_id = i_resource_id) ;
COMMIT;
END cinsscst;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2007
Added on Aug 20 2007
6 comments
1,588 views