Note that there are some explanatory texts on larger screens.

plurals
  1. POTClientDataSet and big insert
    primarykey
    data
    text
    <p>In my application I use TADOQuery with select (MSSQL) and linked with it TClientDataSet. I have to insert about million records and ApplyUpdates.</p> <p>So what I see in the SQL Server Profiler? I see that for <strong>each</strong> inserted row we have 3 queries: sp_prepare of insert script, sp_execute it with some values and sp_unprepare.</p> <p>I want just to prepare sql <strong>once</strong> for all of the records before insert and unprepare it after. How can I do it?</p> <p><strong>Added after</strong>:</p> <p>In the query I have a script for the stored procedure execution:</p> <pre><code>tmpQuery := DefineQuery(FConnection, [ 'exec up_getOperatorDataSet ', ' @tablename = :tablename, ', ' @operator = :operator, ', ' @forappend = :forappend, ', ' @withlinksonly = :withlinksonly, ', ' @ids = :ids ' ], [ Param(ftString, sTableName), Param(ftInteger, FOperatorId), Param(ftBoolean, opForAppendOnly in OpenParams), Param(ftBoolean, opOnlyWithModelLinks in OpenParams), Param(ftString, sIds) ], Result); </code></pre> <p>It selects all of the fields from table <em>sTableName</em> with some parameters.</p> <p>Example of inserting from profiler:</p> <p>step 1:</p> <pre><code>declare @p1 int set @p1=486 exec sp_prepare @p1 output,N'@P1 int,@P2 int,@P3 datetime,@P4 int,@P5 int,@P6 int,@P7 int,@P8 int,@P9 varchar(128),@P10 bit,@P11 numeric(19,4),@P12 smallint,@P13 smallint,@P14 smallint,@P15 smallint',N'insert into parser_prices (operator_id, request_id, date, nights, model_hotel_id, model_meal_id, model_room_id, model_htplace_id, spo, hotelstop, price, frout_econom, frout_business, frback_econom, frback_business) values (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15) ',1 select @p1 </code></pre> <p>step 2:</p> <pre><code>exec sp_execute 486,21,2000450,'2009-12-04 00:00:00',14,2118,22,-9555,18,'2009-10.MSK.Bali.13.10.09-27.03.10',0,15530.0000,3,3,3,3 </code></pre> <p>step 3:</p> <pre><code>exec sp_unprepare 486 </code></pre> <p>and it is <strong>for all</strong> of the new rows.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload