What is CYCLE/NO CYCLE in a Sequence?

Answer Posted / gvmahesh

NOCYCLE keyword is default in sequences.

CYCLE :If we want use cycle keyword first we check the table
having primary key or not.If there is no primary key we
absolutely use the CYCLE keyword.

In hierarchical structure,the descendant act as a
ancestor,is called CYCLE.

For eliminating ancestor descendant problem we use NOCYCLE
KEYWORD.

for example we take the EMP table

In EMP table the MGR column has a NULL managerial number.In
that column we insert some of the empno.Then ancestor
descendant problem occur.

select * from emp;

update emp set mgr=7566 where mgr is null;

Then we write a hierarchical query

select empno,ename,sal,mgr from emp
start with ename='KING'
connect by prior empno=mgr;

we execute this query it shows an error

ERROR:
ORA-01436: CONNECT BY loop in user data.

in this situation also we want to see the data through
NOCYCLE keyword.

select empno,ename,sal,mgr from emp
start with ename='KING'
connect by NOCYCLE prior empno=mgr;

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is cursor explain with example?

651


how to load data files into tables with 'mysqlimport'? : Sql dba

617


How do you modify a column in sql?

643


what is text? : Sql dba

666


How many types of literals are available in pl sql?

629






What is mutating table error?

761


what is an index? : Sql dba

620


What are procedures used for?

609


how to return query output in html format? : Sql dba

745


What is coalesce sql?

602


What is sql*loader?

666


What is scope and visibility in PL/SQL?

690


What is pragma in sql?

705


What is the starting oracle error number? What is meant by forward declaration in functions?

637


Can a key be both primary and foreign?

605