473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Sequence problem

Dan
Hello there.

I have recently been tasked with creating a mySql database. I am much
more used to using Oracle, so I guess my problem is translating Oracle
into mySql. My current problem is the auto-increment. In oracle, I
would never do such a thing, I would instead use a sequence. However,
when I try creating a sequence in mySql I get the following error:
create sequence test;

ERROR 1064: You have an error in your SQL syntax. Check the manual
that corresponds to your MySQL server version for the right syntax to
use near 'sequence test' at line 1
Now, I would be more than happy to use the auto-increment feature if I
could be guarenteed a way to retrieve the next sequence for that
session. Since mySql isn't transaction based, and I have hundreds of
users making updates to the table, I don't see a way to guarentee that
I will be getting the correct ID for the insert I am about to do so
that I can use it as a foreign key in another table. I hope this
makes sense.

If anyone can shed some light on this I would be very grateful.
Please let me know if I am tackiling this problem incorrectly.

Thanks
Dan
Jul 19 '05 #1
2 10266
Dan wrote:
Now, I would be more than happy to use the auto-increment feature if I
could be guarenteed a way to retrieve the next sequence for that
session. Since mySql isn't transaction based, and I have hundreds of
users making updates to the table, I don't see a way to guarentee that
I will be getting the correct ID for the insert I am about to do so
that I can use it as a foreign key in another table.


http://www.mysql.com/doc/en/Getting_unique_ID.html

"The most recently generated ID is maintained in the server on a
per-connection basis. It will not be changed by another client. It will
not even be changed if you update another AUTO_INCREMENT column with a
non-magic value (that is, a value that is not NULL and not 0)."

Jul 19 '05 #2
Dan wrote:
Now, I would be more than happy to use the auto-increment feature if I
could be guarenteed a way to retrieve the next sequence for that
session. Since mySql isn't transaction based, and I have hundreds of
users making updates to the table, I don't see a way to guarentee that
I will be getting the correct ID for the insert I am about to do so
that I can use it as a foreign key in another table.


http://www.mysql.com/doc/en/Getting_unique_ID.html

"The most recently generated ID is maintained in the server on a
per-connection basis. It will not be changed by another client. It will
not even be changed if you update another AUTO_INCREMENT column with a
non-magic value (that is, a value that is not NULL and not 0)."

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan | last post by:
Hello there. I have recently been tasked with creating a mySql database. I am much more used to using Oracle, so I guess my problem is translating Oracle into mySql. My current problem is the...
2
by: Krzysztof Opała | last post by:
Hi I've got my CORBA application written in Borland C++ Builder, using Visibroker. What I wanna do is get from server a set of strings (the number of string is not constant). I was trying to do it...
10
by: Anthony Best | last post by:
I'm working on an idea that uses sequences. I'm going to create a table like this: id serial, sequence int, keyword varchar(32), text text for every keyword there will be a uniq sequence...
4
by: Eric E | last post by:
Hi, I have a question about sequences. I need a field to have values with no holes in the sequence. However, the values do not need to be in order. My users will draw a number or numbers from...
1
by: Marek Lewczuk | last post by:
Hello, I would like to ask if my problem with sequence is a proper behavior or this is a bug (probably not)... I have a table: CREATE TABLE "testtable" ( "serialfield" SERIAL,...
3
by: kevin | last post by:
Is that even possible? I am creating a web service in .NET to expose some already created .NET programs to other groups. One group is writing the client in PERL, and thus wishes the wsdl schema...
8
by: regis | last post by:
Greetings, about scanf matching nonempty sequences using the "%" matches a nonempty sequence of anything except '-' "%" matches a nonempty sequence of anything except ']" matches a nonempty...
14
by: pat270881 | last post by:
hello, I have to implement a sequence class, however the header file is predefined class sequence { public: // TYPEDEFS and MEMBER CONSTANTS
5
by: Anan18 | last post by:
Hello sir, I'm supposed to Implement and Test the sequence Class Using a Fixed-Sized Array (Chapter 3), from Data Structures & Other objects using c++. The header file is provided, and so is a test...
8
by: Slaunger | last post by:
Hi all, I am a Python novice, and I have run into a problem in a project I am working on, which boils down to identifying the patterns in a sequence of integers, for example ..... 1 6 6 1 6 6...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.