Automatically adding records based upon data in another table

Automatically adding records based upon data in another table

Post by Nina Paule » Fri, 04 Aug 2000 04:00:00



I am a newbe at Access and SQL, however I have written a boat load of
code in FoxPro 2.6.  Thank you for taking the time to consider my
question.

1. I have a table called control.  It has 10 records in it.
2. I also have a table called RevDtl.
3. For each record in control, I would like to make a record in RevDtl,
copying into it two fields of info from control.
4. I would also like to place into each newly added RevDbl record a
field from RevHdr.
5. I would like to do this after a new record has been added to RevHdr.

Thank you for your time.

Nina Paules

 
 
 

Automatically adding records based upon data in another table

Post by Stefan Gustafsso » Sat, 05 Aug 2000 04:00:00


You can do this with a trigger. You could also do it with a stored procedure
that you call manually after inserting a record into RevHdr.

The trigger could look something like this:

create trigger t1 on RevHdr for insert as
insert into RevDtl
(c1,c2,r1) -- the fields we are filling with data
select c.c1,c.c2,i.r1
from control c, inserted i

/SG


> I am a newbe at Access and SQL, however I have written a boat load of
> code in FoxPro 2.6.  Thank you for taking the time to consider my
> question.

> 1. I have a table called control.  It has 10 records in it.
> 2. I also have a table called RevDtl.
> 3. For each record in control, I would like to make a record in RevDtl,
> copying into it two fields of info from control.
> 4. I would also like to place into each newly added RevDbl record a
> field from RevHdr.
> 5. I would like to do this after a new record has been added to RevHdr.

> Thank you for your time.

> Nina Paules



 
 
 

1. How to automatically insert a record based on another record

I am new to SQL server and I am in the process of learning it.

For testing I have a table (Table A) that has a primary key called ID
and it is an identity.  When a record is inserted into Table A, I want
to insert a record in another table (Table B) with the same identity
number into the ID field.  How could I do this?  I was looking at
triggers and that seemed like it could work.

thanks
joe z

Sent via Deja.com
http://www.deja.com/

2. Audit trails -- any ideas?

3. Return records based upon multiple criteria.

4. PICK consultant with Help Desk experience needed immediately - please read

5. duplicate data based upon primary key

6. poor query

7. Newbie question--Duplicate data based upon primary keys?

8. Group BY

9. Gathering data based upon user input of date

10. Dynamic table name based upon an IDENTITY value?

11. I want a QReport form based upon 3 tables master/details

12. Cannot add record to Visual Foxpro table after deleting all records in table

13. Automatically adding a record