Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 sequence

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-02 : 18:50:29
srininas writes "still now we are working in oracle.
now we have porting it to SQL server. We have problem with sequence .

we have created a sequence xyz
then in our ASP code we are getting next value by following statement.

"select xyz.nextval from dual" we are getting it from oracle , then we are using this for concatenation and so on.

i want the same as code should work. But it is giving problem.
Is dula table does'nt exist in SQL.if not how to handle it ?

Expecting response ASAP

thanks in advance

bye
srinivas
"

nr
SQLTeam MVY

12543 Posts

Posted - 2001-12-02 : 22:52:29
I don't know much Oracle but I thought by default dual has a single cilumn dummy with value 'X' which you can easily create yourself.

In sql server you shouldn't embed sql in the asp code but call stored procedures. This will give a much more flexible system that is easier to maintain.

I don't see how a select can increment the value in dual as you are seeming to expect - it would mean that Oracle is doing something very weird.
To do this you would create an SP getnextval which updates the value held in a table and returns it as an output parameter.



==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2001-12-03 : 11:58:55
I haven't used Oracle for a while, but I thought FROM DUAL was what you put in when you didn't have a real table that you were getting information from, because Oracle required you to have a FROM clause.

In SQL Server, you don't have that requirement. You can issue the statement SELECT getdate() with no from clause, and you get the current date.

-------------------
It's a SQL thing...

Edited by - AjarnMark on 12/03/2001 11:59:25
Go to Top of Page

efelito
Constraint Violating Yak Guru

478 Posts

Posted - 2001-12-03 : 14:51:22
You guys are correct. Oracle can not handle a SQL statement without a from clause so they have a dummy table called dual. It really has nothing to do with the select. A sequence is kind of like identity in SQL Server, but it's not attached to a particular table. You call nextval and it gives you a unique value to the sequence and increments the sequence.

The closest thing SQL Server has to an Oracle sequence is the uniqueidentifier. You can say "select newid()" and it is pretty much garenteed to be a unique value across the world. They are a little bulky and tough to manipulate though.

The other thing you can do to reproduce this behavior is to create a dummy table with an int field. Then you could select and update the field as necessary. This option greatly reduces your concurency, however.

Jeff Banschbach
Consultant, MCDBA
Go to Top of Page
   

- Advertisement -