ActionQuery and sequence

Posts   
 
    
orenpeled
User
Posts: 53
Joined: 25-Jul-2005
# Posted on: 27-May-2006 15:49:23   

Hi

My code goes like this:

String[] nameArr = { "John", "David", "Dan" }; OracleCommand cmd = new OracleCommand(); cmd.CommandText = "INSERT INTO T(ID, NAME) VALUES(:1, :2)"; //cmd.Parameters.Add(new OracleParameter(":1", ...)); cmd.Parameters.Add(new OracleParameter(":2", ..., nameArr, ...)); cmd.ArrayBindCount = 3; ActionQuery aq = new ActionQuery(...);

Now, I need to initialize the first parameter (":1") with a new value from a sequence, and moreover - I need it to be performed for each row in a single round-trip. In short, the final result should be 3 new rows in DB.

Does somebody have an idea?

  • No LLBLGen entity exists for the table "T", thats why I use ActionQuery.
sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 27-May-2006 18:28:49   

Hello

I need it to be performed for each row in a single round-trip.

I understand the reason you would like this operation to happen in a single round trip, but unfortunately, and I could be wrong, I cannot see a method of achieving it without first getting the sequence number first and then using it to perform the insert.

Not sure why you are choosing not to have T as an LLBLGen entity, but I am sure you have good reason, an alternative is to have a Store procedure that will perform the whole thing and you call this SP instead.

orenpeled
User
Posts: 53
Joined: 25-Jul-2005
# Posted on: 28-May-2006 09:48:25   

Suppose I wouldn't have want to use a sequence - it would have worked as a single round trip, since this feature depends on the provider - OracleCommand.ArrayBindCount, ODP. The thing is, it also worked when I specifically wrote in the OracleCommand.CommandText the sequence-query: "INSERT INTO T (ID, NAME) VALUES (SEQ.NEXTVAL, :2). So I thought there must be a way to do this with LLBLGen - and then I noticed the ActionQuery.SequenceRetrievalQueries collection property. So I created a SequenceRetrievalQuery object representing my sequence-query, and added it to the property. Unfortunatelly, it didn't do the job. The question is, am I in the right direction?

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 28-May-2006 18:10:30   

Hi

Take a look in the Oracle DQE's sourcecode -> DynamicQueryEngine -> Create Insert query. The sequence query has to be told to run after the insert. The DQE sourcecode will explain how to. wink