|
 |
asp_databases thread: Inserting whole recordset back into a table
Message #1 by gbrown@c... on Thu, 13 Dec 2001 14:57:03
|
|
Hi all
What I have is a select statement that takes all records from table1 where
they match certain criterion, I then have a loop til eof through this
recordset and then a command object that inserts these into table2.
The routine itself copies live records to an archive file at the end of
the month. There can be many thousands of records that can be archived at
the end of the month.
Does anyone know of a way to make this simpler. Ideally what I would like
to do is
ors.open "select * from live_table where record_is_complete=true"...
append into archive_table from ors.
Hope that is sort of clear what I am trying to.
Does anyone know of a better way that doesn't include a "Do while not
ors.eof"?
Regards
Graham
Message #2 by "Tomm Matthis" <matthis@b...> on Thu, 13 Dec 2001 11:32:29 -0500
|
|
Why do do a SQL INSERT INTO instead? No recordsets needed, so no looping.
"INSERT INTO archive_table FROM live_table WHERE record_is_complete=true"
-- Tomm
> -----Original Message-----
> From: gbrown@c... [mailto:gbrown@c...]
> Sent: Thursday, December 13, 2001 2:57 PM
> To: ASP Databases
> Subject: [asp_databases] Inserting whole recordset back into a table
>
>
> Hi all
>
> What I have is a select statement that takes all records from table1 where
> they match certain criterion, I then have a loop til eof through this
> recordset and then a command object that inserts these into table2.
>
> The routine itself copies live records to an archive file at the end of
> the month. There can be many thousands of records that can be archived at
> the end of the month.
>
> Does anyone know of a way to make this simpler. Ideally what I would like
> to do is
>
> ors.open "select * from live_table where record_is_complete=true"...
>
> append into archive_table from ors.
>
> Hope that is sort of clear what I am trying to.
> Does anyone know of a better way that doesn't include a "Do while not
> ors.eof"?
>
> Regards
> Graham
>
> $subst('Email.Unsub').
Message #3 by gbrown@c... on Thu, 13 Dec 2001 17:50:19
|
|
Hi Tomm
I've not come across this syntax before I thought I had to always at least
specify values. Will give that a go!
Thanks
Graham
> Why do do a SQL INSERT INTO instead? No recordsets needed, so no looping.
>
> "INSERT INTO archive_table FROM live_table WHERE record_is_complete=true"
>
> -- Tomm
>
<snipped>
|
|
 |