Questions tagged [sequence]

A sequence is an ordered list of objects (or events). Like a set, it contains members (also called elements or terms), and the number of terms (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence. In a relational database, a sequence is an object that is used to generate unique numbers for a primary key.

A sequence is an ordered list of objects (or events). Like a set, it contains members (also called elements or terms), and the number of terms (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence.

Sometimes, sequence is used as a generic name for both list, array and set for convenience.

In a , a sequence is an object that is used to generate unique numbers for a .

5959 questions
93
votes
7 answers

Python: check if an object is a sequence

In python is there an easy way to tell if something is not a sequence? I tried to just do: if x is not sequence but python did not like that
nicotine
  • 2,519
  • 3
  • 19
  • 15
83
votes
7 answers

How to slice a list from an element n to the end in python?

I'm having some trouble figuring out how to slice python lists, it is illustrated as follows: >>> test = range(10) >>> test [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> test[3:-1] [3, 4, 5, 6, 7, 8] >>> test[3:0] [] >>> test[3:1] [] >>> test [0, 1, 2, 3, 4,…
FurtiveFelon
  • 14,714
  • 27
  • 76
  • 97
82
votes
2 answers

How can I get all sequences in an Oracle database?

Is there any command that I can run so that I can get all the sequences? I am using Oracle 11g. I am using Toad for Oracle to connect to it. I can visually see the sequences in Toad, but I like to know the command line for it.
sheidaei
  • 9,842
  • 20
  • 63
  • 86
77
votes
2 answers

Why does Python allow out-of-range slice indexes for sequences?

So I just came across what seems to me like a strange Python feature and wanted some clarification about it. The following array manipulation somewhat makes sense: p = [1,2,3] p[3:] = [4] p = [1,2,3,4] I imagine it is actually just appending…
Akaisteph7
  • 5,034
  • 2
  • 20
  • 43
76
votes
6 answers

How does the JPA @SequenceGenerator annotation work

I am learning JPA and have confusion in the @SequenceGenerator annotation. To my understanding, it automatically assigns a value to the numeric identity fields/properties of an entity. Q1. Does this sequence generator make use of the database's…
Amit
  • 33,847
  • 91
  • 226
  • 299
70
votes
10 answers

Scala: Remove duplicates in list of objects

I've got a list of objects List[Object] which are all instantiated from the same class. This class has a field which must be unique Object.property. What is the cleanest way to iterate the list of objects and remove all objects(but the first) with…
parsa
  • 2,628
  • 3
  • 34
  • 44
68
votes
9 answers

Best way to reset an Oracle sequence to the next value in an existing column?

For some reason, people in the past have inserted data without using sequence.NEXTVAL. So when I go to use sequence.NEXTVAL in order to populate a table, I get a PK violation, since that number is already in use in the table. How can I update the…
Cade Roux
  • 88,164
  • 40
  • 182
  • 265
60
votes
1 answer

How to append or prepend on a Scala mutable.Seq

There's something I don't understand about Scala's collection.mutable.Seq. It describes the interface for all mutable sequences, yet I don't see methods to append or prepend elements without creating a new sequence. Am I missing something obvious…
Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234
57
votes
6 answers

can't multiply sequence by non-int of type 'float'

Why do I get an error of "can't multiply sequence by non-int of type 'float'"? from the following code: def nestEgVariable(salary, save, growthRates): SavingsRecord = [] fund = 0 depositPerYear = salary * save * 0.01 for i in…
user425727
56
votes
10 answers

Sequential Guid Generator

Is there any way to get the functionality of the Sql Server 2005+ Sequential Guid generator without inserting records to read it back on round trip or invoking a native win dll call? I saw someone answer with a way of using rpcrt4.dll but I'm not…
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
55
votes
4 answers

When to use forEach(_:) instead of for in?

As documented in both Array and Dictionary forEach(_:) Instance methods: Calls the given closure on each element in the sequence in the same order as a for-in loop. Nevertheless, adapted from Sequence Overview: A sequence is a list of values…
Ahmad F
  • 30,560
  • 17
  • 97
  • 143
54
votes
2 answers

Get current value from a SQL Server SEQUENCE

I want to get the current value from my sequence - the same value that is shown in the sequence properties window SQL Server Management Studio My sequence is created with this statement: CREATE SEQUENCE [OrderNumberSequence] as int START…
Henrik Stenbæk
  • 3,982
  • 5
  • 31
  • 33
53
votes
2 answers

Postgresql - Using subqueries with alter sequence expressions

Is it possible to use subqueries within alter expressions in PostgreSQL? I want to alter a sequence value based on a primary key column value. I tried using the following expression, but it wouldn't execute. alter sequence public.sequenceX restart…
Danmaxis
  • 1,710
  • 4
  • 17
  • 27
52
votes
6 answers

Oracle: sequence MySequence.currval is not yet defined in this session

What does this mean, and how can I get around it? SELECT MySequence.CURRVAL FROM DUAL; Result: ORA-08002: sequence MySequence.CURRVAL is not yet defined in this session
Doug
  • 1,678
  • 2
  • 14
  • 17
50
votes
19 answers

Compute the minimal number of swaps to order a sequence

I'm working on sorting an integer sequence with no identical numbers (without loss of generality, let's assume the sequence is a permutation of 1,2,...,n) into its natural increasing order (i.e. 1,2,...,n). I was thinking about directly swapping the…
mintaka
  • 982
  • 1
  • 9
  • 25