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
 General SQL Server Forums
 New to SQL Server Programming
 sequences

Author  Topic 

Jeskit@hotmail.co.uk
Starting Member

20 Posts

Posted - 2008-01-03 : 11:26:17
hi

i'm creating a sql hoilday database and i need to write a sequence but i've been told its wrong but i dont know why, can anyone help?
CREATE SEQUENCE SEQ_HOILDAY_SITES
INSERT INTO Details_of_sites_visited(Code_of_the_sites, Sites_name)
VALUES(SEQ_HOILDAY_SITES.NEXTVAL,'124','Yosemite National Park');


thanks

jessica

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2008-01-03 : 11:38:32
Dont understand what you mean by "but i've been told its wrong..". You mean someone told you the approach is wrong or do you get errors from SQL?

Your INSERT has 2 columns and your VALUES has 3 values.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

Jeskit@hotmail.co.uk
Starting Member

20 Posts

Posted - 2008-01-03 : 11:49:19
i've been told the sql command is ended wrongly. how do my values have three values?
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-01-03 : 11:50:35
Are you talking about ORACLE here?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Jeskit@hotmail.co.uk
Starting Member

20 Posts

Posted - 2008-01-03 : 11:53:13
thats the application i'm using why?
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-01-03 : 12:40:27
because this forum is for ms sql server, not oracle.


elsasoft.org
Go to Top of Page

Jeskit@hotmail.co.uk
Starting Member

20 Posts

Posted - 2008-01-03 : 12:43:10
well i have to write it in ql first before i can put it in oracle
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-01-03 : 12:56:18
oracle's flavor of sql is different from ms. you will have better luck asking your question on an oracle forum.

www.orafaq.com for example.


elsasoft.org
Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2008-01-03 : 13:59:40
quote:
Originally posted by Jeskit@hotmail.co.uk

i've been told the sql command is ended wrongly. how do my values have three values?



Jessica,

Because Dinakar can count and you can't?

Your code:


CREATE SEQUENCE SEQ_HOILDAY_SITES
INSERT INTO Details_of_sites_visited(Code_of_the_sites, Sites_name)
/* ^^^ Col 1 ^^^ Col 2 */
VALUES(SEQ_HOILDAY_SITES.NEXTVAL, '124', 'Yosemite National Park');
/* ^^^ Col 1 ^^Col 2 ^^^ Col 3 */


Jezemine is right, too. Oracle's PL/SQL is much different than SQL Server's T-SQL. For instance, CREATE SEQUENCE and SEQ_HOILDAY_SITES.NEXTVAL are both Oracle-specific and don't exist in SQL Server's dialect; in SQL Server, it's done with a data type assigned to the column, as in 'ID IDENTITY(1, 0)'.
Go to Top of Page
   

- Advertisement -