Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

how to loop record in stored procedure

$
0
0

hi all,

i am newbie in sql server. i have a scenario as below:

1. i have new pricing table for all the products

2. i need to update sales order details table where sales order created 3 days back

how do i covert this oracle pl/sql code into sql code?

begin

for rec (select sd.rowid, sd.product from so so, so_details sd where so.order_date>= sysdate - 3

and sd.order_no = so.order_no) loop

select null from so_details where rowid=rec.rowid for update;

select price into x_price from product where product.product=rec.product no-lock;

update so_details set price=x_price where rowid=rec.rowid;

end loop;

commit;

end;

Thanks,

Richard


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>