title: INSERT SELECT in Firebird
body: <p>I'm new to firebird and I have verious issues. I want to insert various lines into a table selected from another table.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>/*CREATE GENERATOR POS; */
  SET GENERATOR POS TO 1;
  
  SET TERM ^;
  
  create trigger BAS_pkassign
     for MATERIAL
  active before insert position 66
  
  EXECUTE BLOCK
  AS
  
    declare posid bigint;
    select gen_id(POS, 1)
    from RDB$DATABASE
    into :posid;
  
  BEGIN
  
  
  
  END
  
  SET TERM ; ^
  
  
  INSERT INTO MATERIAL ( /*ID */ LOCATION, POSID, ARTID, ARTIDCONT, QUANTITY )
  SELECT  1000, ':posid', 309, BAS_ART.ID, 1
  FROM    BAS_ART
  WHERE   BAS_ART.ARTCATEGORY LIKE '%MyWord%'
  </code></pre>
  
  <p>The ID should autoincrement from 66 on. The posid should autoincrement from 1 on.</p>
  
  <p>Actually it is not inserting anything.</p>
  
  <p>I'm using Firebird Maestro and have just opened the SQL Script Editor (which doesnt throw any error message on executing the script).</p>
  
  <p>Can anybody help me?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Additional information:</strong></p>
  
  <p>The trigger should autoincrement the column "ID" - but I dont know how exactly I can change it so it works.. The ':posid' throws an error using it :posid but like this theres no error (I guess its interpretated as a string). But how do I use it right? </p>
  
  <p>I dont get errors when I execute it. The table structure is easy. I have 2 tables:
  1.</p>
  
  <pre><code> Material (
  ID (INTEGER),
  Location (INTEGER),
  POSID (INTEGER),
  ARTID (INTEGER),
  ARTIDCONT (INTEGER),
  QUANTITY (INTEGER),
  OTHERCOLUMN (INTEGER)) 
  </code></pre>
  
  <p>and the 2. other table</p>
  
  <pre><code>BAS_ART (ID (INTEGER), ARTCATEGORY (VARCHAR255))
  </code></pre>
  
  <p>-> I want to insert all entries from the table BAS_ART which contain "MyWord" in the column ARTCATEGORY into the MATERIAL table.</p>