GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 122 of 171    Print  
What is output of this SQL where current value of sequence is 3?
Select seq.curval,seq.Nextval,seq.Nextval from dual ? Give reason?

  
Total Answers and Comments: 2 Last Update: March 08, 2007     Asked by: ddkdhar 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 08, 2007 01:04:03   #1  
Nikhil_4_Oracle        

RE: What is output of this SQL where current value of ...


HI ddkdhar

U r output wll be...

CURRVAL NEXTVAL NEXTVAL
----------- ----------- -----------
3 3 3

Coz sequence are stored objects in oracle and Incremented only when they

are use with in executable code let Us C.....


--Seq.currval 3;

--Desc tabQ

--NUM NUMBER(2)

1 begin for i in 1..10
2 loop
3 insert into tabq values(Seq.nextval);
4 end loop;
5* end;
SQL> /


PL/SQL procedure successfully completed.

Elapsed: 00:00:00.04

SQL> select * from tabq;


NUM
----------
4
5
6
7
8
9
10
11
12
13


10 rows selected.


Elapsed: 00:00:00.16

SQL> select Seq.currval Seq.nextval from dual;


CURRVAL NEXTVAL
---------- ----------
14 14


1 row selected.

Elapsed: 00:00:00.07

Now there is no issue how many times u fire above select Query its always 14.

so Is this Clear ddkdhar.....

Regards

Nikhil.


 
Is this answer useful? Yes | No
March 08, 2007 14:38:30   #2  
ddkdhar Member Since: June 2006   Contribution: 48    

RE: What is output of this SQL where current value of ...
nikhil take 14 is the currvalue in the sequence
the result for this query is
select s.currval s. nextval s.nextval from dual
is
15 15 15

yes :-) ok
now about execution of this query
.i have one doubt


oracle executes from right to left columns ....
then the next seq in the middle should be incremented by 1


but here we arre getting
all same values .
thanks for giving responses nikhil


.

 
Is this answer useful? Yes | No

 Related Questions

SELECTCONNECTRESOURCES 
Latest Answer : objectes privileges such asselect,delete,update,connect ...

delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name); ordelete duplicate_values_field_name dv from table_name ta where rowid  
Latest Answer : Delete table_name t1where rowid>(select rowid from table_name t2)and t1.column1=t2.column1 ...

SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output BCDEINSTR provides character position in which a pattern is found in a string. eg INSTR('ABC-DC-F','-',2) 
Latest Answer : hi Buddy,   Substr only give the sub part of the stringSubstr(String,'start postion','length')Substr('ABCDEFAG',3,7); /*out put is =cdefag */Instr to give only possion  of letter in use in a stringInstr(String,'letter',possition  ...

INSTR('120000 12 0 .125',1,'.')output 13 
Latest Answer : select instr('1200023.56', '.') from dual; ...

SELECT * FROM empWhere emp_no+' '=12345;i.e you have to concatenate the column name with space within codes in the where condition.SELECT /*+ FULL(a) */ ename, emp_no from empwhere emp_no=1234;i.e 
Latest Answer : One way is to diable the index on the column using syntaxAlter index indexname on table_name disable.One way is to apply  /*+no_index */ hint to the query For eg: select ename /*+no_index */from empwhere ename ='smith' ...

It is a column that is not an actual column in the table.eg USER, UID, SYSDATE, ROWNUM, ROWID, NULL, AND LEVEL. 
Latest Answer : Pseudo columns is not actula column in the table. it behaves like table columnwe can retivesv values of pseduo column but can not insert,update or delete value in that.has two data type 1. rowid  2. urowidrow id uniqely identify row in databaseEXM ...

Suppose a customer table is having different columns like customer no, payments.What will be the query to select top three max payments?
SELECT customer_no, payments from customer C1WHERE 3 

select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum  
Latest Answer : select * from employees where salary between(1000 and 5000); ...

SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal 
Latest Answer : SELECT v.sal FROM (SELECT TO_NUMBER(salary) sal,rank() over (ORDER BY TO_NUMBER(salary) DESC) ranksal FROM employee ORDER BY 1 DESC)v WHERE v.ranksal=6 Pls note where 6 is the ranknumber ...

SQL> select sal, (to_char(to_date(sal,'j'), 'jsp'))from emp;the output like,SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP'))--------- -----------------------------------------------------800 
Latest Answer : In order to display the number values , the best it can be done is with the julian i.e. j and jsp. however, using the translate also returns the same value for whatever value to display.select to_char(to_date(1920,'j'),'jsp') from dual; ...


 Sponsored Links

 
Related Articles

Querying Data with Oracle XQuery

Querying Data with Oracle XQuery Starting with Oracle Database 10g Release 2 you can take advantage of a full featured native XQuery engine integrated with the database With Oracle XQuery you can accomplish various tasks involved in developing PHP Oracle XML applications operating on any kind of dat
 

Using Oracle XML DB Repository

Using Oracle XML DB Repository Another variation on accessing and manipulating XML content stored in Oracle database is provided by Oracle XML DB repository which is an essential component of Oracle XML DB mosgoogle NOTE Oracle XML DB repository also known as XML repository is a hierarchically organ
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

XML Processing in PHP and Oracle Applications

Processing XML in PHP Oracle Applications As mentioned there are two alternatives when it comes to performing XML processing in your PHP Oracle application You can perform any required XML processing using either PHP s XML extensions or PEAR XML packages or Oracle s XML features mosgoogle In the fol
 

PHP Oracle Web Development

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax is a good starting b
 

Getting Started with Oracle and ODP.NET

ODP NET Developer’ s Guide by Jagadish Chatarji Pulakhandam Sunitha Paruchuri A practical guide for developers working with the Oracle Data Provider for NET and the Oracle Developer Tools for Visual Studio 2005 Application development with ODP NET Dealing with XML DB using ODP NET Oracle
 

PHP Oracle Web Development Review

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books The author is also an expert in open source technologies and SOA Service Oriented Architecture But besides
 

jQuery - Marking the Current Page

Learning jQuery Marking the Current Page Our pager can be made more user friendly by highlighting the current page number We just need to update the classes on the buttons every time one is clicked mosgoogle geshibot lang php" var pager ; for var page 0; page numPages; page pag
 

Step by Step Oracle PL-SQL Tutorial

This introductory tutorial to PL SQL will help you to understand the basic concepts of PL SQL Please review the following tutorials and practice the sample SQL Statements on your local Oracle Database Please note that you must learn these basic things before we actually start getting in to Advanced
 

Working with XML in Oracle

Working with XML in Oracle Introduction to XML Extensive markup language is the language which presents data in a human readable form of text The data can be anything from a purchase order or a stock quote or weather radar or a flight schedule it can be represented using XML XML is very similar to H
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape