Home » SQL & PL/SQL » SQL & PL/SQL » procedures (merged 2 topics by bb)
procedures (merged 2 topics by bb) [message #354707] Mon, 20 October 2008 22:52 Go to next message
gupta_vama
Messages: 8
Registered: October 2008
Location: hyderabad
Junior Member
Hi,

i have 3 tables i.e.
promotions(promo_name,promo_subcategory,promo_category)
times(time_id,calendar_month_desc)
sales(time_id,promot_id,quantity_sold,amount_sold)

using above there tables i created one table i.e. aggr_calmonth_desc(promo_name,promo_subcategory_promo_category,calendar_month_desc,total_quantity_sold,total_amount_sold)

total_quantity_sold=sum(quantity_sold) group by promotions by calendar month
total_amount_sold=sum(amount_sold) group by promotions by calendar month


i am inserting values in a table by using procedure but whenever execute again the same procedure then again same records are inserted but how can i remove alredy existing values using procedure how can do it.

Re: procedures [message #354717 is a reply to message #354707] Mon, 20 October 2008 23:49 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Questin is not clear .

Anyway use DELETE in procedure

Thumbs Up
Rajuvan
Re: procedures [message #354719 is a reply to message #354707] Tue, 21 October 2008 00:05 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
a) by deleting previous values (records), and then inserting new ones
b) by updating previous values, instead of inserting new ones
Re: procedures [message #354744 is a reply to message #354707] Tue, 21 October 2008 01:31 Go to previous messageGo to next message
tanmoy1048
Messages: 133
Registered: June 2007
Senior Member
You can use MINUS to find out the new rows.
Re: procedures [message #354762 is a reply to message #354707] Tue, 21 October 2008 02:49 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Replace your current script with one that uses the MERGE command - that way you can insert or update the table, depending on whether or not the rows were added durung the last run.
Re: procedures [message #355558 is a reply to message #354707] Sat, 25 October 2008 05:04 Go to previous message
dr.s.raghunathan
Messages: 540
Registered: February 2008
Senior Member
hi,
set flag through one column. insert or update whenever this column is null and on doing insert or update set some non null value to flag column. It is very simplest solution unless you are concerned with some storage problems.
yours
dr.s.raghunathan
Previous Topic: How to avoid ovelapping dates
Next Topic: Search the whole user
Goto Forum:
  


Current Time: Fri Dec 06 23:20:44 CST 2024