0

I am trying to insert into a table B from a query A that has 5 records using a generator based on the primary ID of Table B, lets call it GEN_B so they don't repeat IDs in tableB.

TableB has (ID, nameB, lastnameB). Query A (5 records) is the select query here:

Insert Into TableB (ID, nameB, lastnameB) 
SELECT 
  GEN_ID(GEN_B,1), Name, LastNAme
FROM 
  Table123
  left join .....
  left join.....
where...

Why do I only see one record being inserted into TableB when I ran the "Insert into Select...", as opposed to the five records in the select query A? Is it because of the generator not updating the record inserted every time? Will I need to make a execute block for this? If so, any ideas how?

3
  • Which Firebird version are you using? Is TableB also involved in the source query? Please provide a minimal reproducible example which we can basically copy, paste and execute to reproduce. For your information, in Firebird 4.0, this would work. Oct 4 at 12:58
  • 2
    If only one record gets inserted that would suggest your query returns only one record. Oct 4 at 15:25
  • problem is solved, turns out as Ondrej Kelle kind of mentioned it. After the first insert, the query interates again and returns an empty value, hence, no insert. Thanks guys. Oct 5 at 7:21

1 Answer 1

0

problem is solved, turns out after the first insert, the query interates again and returns an empty value, hence, no insert after the first one.

1
  • Which Firebird version are you using? Oct 6 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.