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!

Create sequence, function and view all at once -script or something similar

601863Nov 27 2008 — edited Nov 27 2008
Hi I would like to know in what way can I write a script or something like that which would define names for a sequence, function and a view in the beginning (for example TEST_SEQ, TEST_FJ, TEST_VIEW...) and after that create this sequence, function and view with definitions like

CREATE SEQUENCE TEST_SEQ
MINVALUE 1 MAXVALUE 999999999999999999999999999
INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE;

create or replace FUNCTION TEST_FJ RETURN NUMBER AS
tmp number;
BEGIN
select TEST_SEQ.NEXTVAL into tmp from dual
RETURN tmp;
END TEST_FJ;

and so on...

In the end I would also like to grant some rights on these objects I just created:

grant select on TEST_SEQ to public;
grant execute on TEST_FJ to public;

So my question is how to package all these things together so I can execute them from a single file in SQL Developer, and if i need to change the names of these tables I want do it in one place in the beginning of this script (or something like a script, I'm not sure what)...


Thanks in advance!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 25 2008
Added on Nov 27 2008
5 comments
292 views