list extend() to index, inserting list elements not only to the end

Sure, you can use slice indexing: a_list[1:1] = b_list Just to demonstrate the general algorithm, if you were to implement the my_extend function in a hypothetical custom list class, it would look like this: def my_extend(self, other_list, index): self[index:index] = other_list But don’t actually make that a function, just use the slice notation when you … Read more

SQL Populate table with random data

I dont know exactly if this fits the requirement for a “random description”, and it’s not clear if you want to generate the full data: but, for example, this generates 10 records with consecutive ids and random texts: test=# SELECT generate_series(1,10) AS id, md5(random()::text) AS descr; id | descr —-+———————————- 1 | 65c141ee1fdeb269d2e393cb1d3e1c09 2 | … Read more

Is there a standard way of moving a range into a vector?

You use a move_iterator with insert: v1.insert(v1.end(), make_move_iterator(v2.begin()), make_move_iterator(v2.end())); The example in 24.5.3 is almost exactly this. You’ll get the optimization you want if (a) vector::insert uses iterator-tag dispatch to detect the random-access iterator and precalculate the size (which you’ve assumed it does in your example that copies), and (b) move_iterator preserves the iterator category … Read more

Java: How to insert CLOB into oracle database

The easiest way is to simply use the stmt.setString(position, xml); methods (for “small” strings which can be easily kept in Java memory), or try { java.sql.Clob clob = oracle.sql.CLOB.createTemporary( connection, false, oracle.sql.CLOB.DURATION_SESSION); clob.setString(1, xml); stmt.setClob(position, clob); stmt.execute(); } // Important! finally { clob.free(); }