-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fce3049
commit ef1e6ef
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
set serveroutput on; | ||
|
||
DECLARE | ||
rand number(2); | ||
ct number(2); | ||
type prod is record(pid PRODUCT.PRODUCTID%type, | ||
pname PRODUCT.NAME%type, | ||
price PRODUCT.PRICE%type, | ||
image PRODUCT.IMAGE%type); | ||
rec prod; | ||
begin | ||
|
||
FOR i IN 1..4 LOOP | ||
select max(PRODUCTID) into ct from PRODUCT; | ||
select dbms_random.value(1,ct) into rand from dual; | ||
|
||
select productid, name, price, image into rec.pid,rec.pname,rec.price,rec.image from PRODUCT where productid = rand; | ||
update promotions | ||
set productid = rec.pid, name=rec.pname, price=rec.price, image=rec.image | ||
where repeatnum = i; | ||
END LOOP; | ||
|
||
|
||
end; |