Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
INSERT INTO many-to-many table
I have two tables related many-to-many. I display the first of these tables in a form with a grid showing the child table that contains the keys of both parents. The second parent table has a child table of its own. I want to click a button and create new children for each of several records in parent2 that are related to the current parent1 shown in the form. I was thinking I could just
SELECT * FROM mychild INTO CURSOR mycursor WHERE keyfield == currentparentkey
SELECT mycursor
SCAN
INSERT INTO childofparent2(parentkey,field1) VALUES mycursor.parent2key, cStuff_for_field)
ENDSCAN
USE IN mycursor
but I was wondering if there was a better way. I have not yet tried this code. It doesn't seem to take advantage of the relations, or the grid. Is there anything more slick that I can do?
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement