sequence

Create a Sequence with START WITH from Query

How can I create a Sequence where my START WITH value comes from a query? I'm trying this way: CREATE SEQUENCE "Seq" INCREMENT BY 1 START WITH (SELECT MAX("ID") FROM "Table"); But, I get the ORA-01722 error ...

What are the pros and cons of a sprite sheet compared to an image sequence?

Hi, I come from a 2D animation background and so when ever I us an animated sequence I prefer to use a sequence of images. To me this makes a lot of sense because you can easily export the image sequence from your compositing/editing software and easily define the aspect. I am new to game development and am curious about the use of a s...

What is the correct term for the following functional programming pattern?

I've heard it referred to as a stream, as an infinite list, and sometimes even as a lazy sequence. What is the correct term for the following pattern? (Clojure code shown) (def first$ first) (defn second$ [str] (cond (empty? str) () true ((first (rest str))))) (defn stream-builder [next_ n] (cons n (cons (fn [] (stream-bu...

Short unique values with Amazon Web Services

I'm working on a system conceptually similar to an URL shortener like bit.ly -- a client sends in a bit of data and the system returns a very short URL to represent it (a base URL + a token representing the data). Ideally, it would start with the shortest token possible (maybe 4 or 5 alphanumeric characters) and move on to longer tokens ...

mysql query where IN statement

Hi there. I want to do the following: SELECT count(id) FROM table WHERE value BETWEEN 3 AND 40; But it should do the following: SELECT count(id) FROM table WHERE value IN(3, 4, 5, 6, 7, 8, 9, 10, 11, ..., 40); It should even print out zero count(id) for value between 3 and 40, but not value = x. I want to check if a value is in a s...

Given a list and a bitmask, how do I return the values at the indices that are True?

I start with the following list s and bitmask b: s = ['baa', 'baa', 'black', 'sheep', 'have', 'you', 'any', 'wool'] b = [1, 0, 0, 0, 1, 1, 1, 0] # or any iterable with boolean values How do I write some function apply_bitmask(s, b) so that it returns ['baa', 'have', 'you', 'any'] ...

how can I maintain sequence of my list using set?

In [1]: l1 = ['a',2,3,0,9.0,0,2,6,'b','a'] In [2]: l2 = list(set(l1)) In [3]: l2 Out[3]: ['a', 0, 2, 3, 6, 9.0, 'b'] Here you can see the the list l2 is falling with different sequence then the original l1, I need to remove the duplicate elements from my list without changing the sequence/order of the list elements.... ...

how to insert to a identity column using sequences in DB2

Hi, how to insert to a identity column using sequences in DB2? Thanks in advacne ...

Hibernate is not auto creating sequencies to database when using auto creating of tables

I want to create my database tables automatically with Hibernate and Postgresql, but I get errors about sequences. Is it possible to auto create sequences too with Hibernate, or do I have generate sequences manually? Example of my entity: import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence...

How to create a PostgreSQL partitioned sequence?

Is there a simple (ie. non-hacky) and race-condition free way to create a partitioned sequence in PostgreSQL. Example: Using a normal sequence in Issue: | Project_ID | Issue | | 1 | 1 | | 1 | 2 | | 2 | 3 | | 2 | 4 | Using a partitioned sequence in Issue: | Project_ID | Issue | | 1 ...

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

level: beginner why do i get error "can't multiply sequence by non-int of type 'float'"? def nestEgVariable(salary, save, growthRates): SavingsRecord = [] fund = 0 depositPerYear = salary * save * 0.01 for i in growthRates: fund = fund * (1 + 0.01 * growthRates) + depositPerYear SavingsRecord += [fund...

Creating a DB2 sequence with a specific START WITH value

In Oracle we can do it like this: declare current_max_value NUMBER; begin select last_number+1 into current_max_value from USER_SEQUENCES where sequence_name = 'HIBERNATE_SEQUENCE'; execute immediate 'CREATE SEQUENCE SEQ__NEW_SEQUENCE MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH '||current_max_value|| ' CACH...

Calculating which item is next in a percentage distribution

I'm working on a project that involves diverting phone calls to a number of destinations. For example, I want: 10% of calls to go to destination A 20% of calls to go to destination B 30% of calls to go to destination C 40% of calls to go to destination D The number of destinations and their percentages must be configurable. I've ...

Return a result set in numeric pattern / sequence

I have a problem in hand and that is to fetch a result set in a numeric pattern / sequence based on a single column's value. Say I have the following table: +-------+ | val | +-------+ | 1 | | 1 | | 1 | | 1 | | 2 | | 2 | | 2 | | 2 | | 3 | | 3 | | 3 | | 3 | +-------+ How can I make...

Can I create my own sequence in Hibernate?

Can I create my own sequence in Hibernate, like I have a database sequence and I have to add 2 characters before the sequence? ...

call backs / que loading - call function after complete

What would be the best way to call render() once all the imageData vars have been populated? would I just call them all in sequence using callbacks, and call render, or is there a better method? function loadImageData() { //Get Background Image Data var backgroundImg = loadImage(background, function(){ ...

going through a dictionary and printing its values in sequence

def display_hand(hand): for letter in hand.keys(): for j in range(hand[letter]): print letter, Will return something like: b e h q u w x. This is the desired output. How can I modify this code to get the output only when the funtion has finished its loops? Something like below code causes me problems as I can...

Oracle-SQL: Generating cyclical, composite sequences

I want to generate composite sequences in the following format: <Alphabet><2 digit numeric code> Each alphabet series will have numeric values ranging from 00 to 99. The initial value will be A00, the subsequent values will be A01, A02 and so on. Upon reaching A99, the next sequence should carry-on to B00. When the "B" series is exha...

XML sequence with arbitrary number of comments

Alright, so I'm using XML schema to validate a following type of xml file: (just pretend the parens are actually angled brackets). <root> <A> <B></B> <C></C> </A> </root> pretty simple -> except the catch is that I also want to have a comment element, which can occur an unbounded number of times in any order (provid...

Handling sequences through C++ class interfaces

Let's say I'm writing an interface for a class A that keeps a list of objects of type B, and I want to be able to manipulate that list through class A's interface. I could put add_B, remove_B, etc. methods to A's interface, but that's a lot of code duplication (this situation occurs in many classes in my programme), so I'd rather return...