Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Cursor
Both ways to insert data are functionaly equivalent.
May I suggest a few amendments :
Here's your INSERT STATEMENT:
INSERT INTO member promo(member id, promo id, run date ) SELECT customer.member id, promo , customer.bdate FROM customer WHERE customer.bdate=trunc(SYSDATE);
Moreover , if bdate is not stored in a truncated form , the condition
becomes :
WHERE trunc(customer.bdate)=trunc(SYSDATE)
This also applies for the queries in your procedure :
CURSOR member IS
SELECT member id FROM customer WHERE bdate = trunc(SYSDATE);
LOOP
FETCH member INTO l member id;
EXIT WHEN member%NOTFOUND;
INSERT INTO member promo VALUES(promo id, l member id,
TRUNC(SYSDATE)); /* to store date in a truncated form */
END LOOP; (The TRUNC in the insert statement eliminates time components (h,m & s) in the stored data)
If the amount of data to be inserted into the table member promo is
reasonably small, one single INSERT statement is preferable. If it's
bigger, doing so may cause you to run out of space in your rollback
segment.
In this case you would preferably use the procedure, issuing a COMMIT
statement just after the insert statement (before END LOOP)
--Received on Wed Jun 24 1998 - 00:00:00 CDT
![]() |
![]() |