Re: ADO conditional insert, update, or delete




"billy" <wcasse@xxxxxxxxx> wrote in message
news:f30ff1b6-5275-4dd8-9bfe-695a5e8c05e4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have not been able to find a good example of this and was hoping
that someone might have one or a helpful URL. Specifically, when to
use CreateObject("ADODB.Recordset") and what should my sql querys
be.

I have a multi-dimensional array and an Access database. What I am
trying to do is to compare the array to the database:
If MyArray(0,0) does not exist in the database, then insert
MyArray(0,0) and MyArray(1,0) into table1.
If MyArray(0,1) is equal to table1-recordset1-field1 and
MyArray(1,1)
is equal to table1-recordset1-field2 then do nothing.
If MyArray(0,2) does exist and MyArray(1,2) is NOT equal to
recordset2-
field2 then update recordset2.
Next, I think I need a separate loop to go through the database and
delete recordsets that do not exist in the array.

I only know enough about ADO and SQL to be dangerous. Hopefully
someone with more knowledge will jump in here.

It sounds to me like one SQL statement could do most of the work. A
left join of your array and table1 might contain the result you want.

Perhaps you could save your array to a file in CSV format. I think
SQL can left join the data from the CSV file with the data from the
database's table 1, and put the result into a new table 1. I would
suggest going through the ADO and SQL tutorials at
http://www.w3schools.com.

-Paul Randall


.



Relevant Pages

  • Re: Clustering Newbie - SAN Advice
    ... I have not used that particular unit, bit it does meet my basic criteria of having the controllers and cache on-board the array. ... Senior SQL Infrastructure Consultant ... A SAN generally has gigabtes of cache and uses large internal block sizes ... The SAN or Smart array will dictate what internal connection the disks have. ...
    (microsoft.public.sqlserver.clustering)
  • Re: [PHP] From TXT to a mySQL db
    ... database is viable to do. ... Then contruct an SQL INSERT query and execute it to put the array values ...
    (php.general)
  • Re: Passing arrays to a stored procedure
    ... sql developers around the world and Joe your attitude was quite frankly rude ... I am also writing a stored procedure and have to put an array of values into ... > into scalars. ...
    (microsoft.public.sqlserver.programming)
  • RE: SQL Cluster on SAN
    ... MSA1000 supports ADG RAID that allows at most 2 physical ... ADG array is formed by ... MSDTC are created on ADG RAID drives for optimal ... my system have 2 clustered SQL servers sharing ...
    (microsoft.public.sqlserver.clustering)
  • Re: DTS Transform Loop
    ... the data from the RS to the array, then manipulate the array (display data, ... because it keeps the trips to the SQL Server down. ... > Loop over the files and insert 1 at a time. ... >> Then this goes into the Active-X loop and the ExcelLink is loaded into ...
    (microsoft.public.sqlserver.dts)

Loading