title: Loop through all user tables and insert row in each
body: <p>for some reason I just can not figure this out.  I have a seperate schema in PostgreSQL for notification related tables for each user connected to the server.  My plan is to have each user create a TEMP table to receive extra notification info from since Xojo doesn't support PostgreSQL payloads.<br>
  I feel like I'm starting to get close so I'll just post my code that is in my trigger function.</p>
  
  <pre><code>    DECLARE
          my_table    RECORD;
      BEGIN       
          FOR my_table IN 
              SELECT table_name
              FROM   information_schema.tables
              WHERE  table_schema = 'information_schema'
          LOOP
              INSERT INTO my_table.table_name (effected_row_id)
                  VALUES (NEW.effected_row_id);
          END LOOP;
      END;
  </code></pre>
  
  <p>Tell me if I'm wrong, but I believe my main problem is figuring out how to use the table name returned from the SELECT statement in the INSERT statement.</p>
  
  <p>EDIT:
  This is my current trigger function</p>
  
  <pre><code>-- Function: notification.my_insert_trigger_function()
  
  -- DROP FUNCTION notification.my_insert_trigger_function();
  
  CREATE OR REPLACE FUNCTION notification.my_insert_trigger_function()
    RETURNS trigger AS
  $BODY$DECLARE
      my_table    RECORD;
  BEGIN       
      FOR my_table IN 
          SELECT table_name
          FROM   information_schema.tables
          WHERE  table_schema = 'notification' AND table_name &lt;&gt; 'notification_global' AND table_name &lt;&gt; 'switcher'
      LOOP
          EXECUTE(FORMAT($f$
          INSERT INTO %s (effected_row_username)
              VALUES (%s);
          $f$, 'notification.' || my_table.table_name, NEW.effected_row_username));
      END LOOP;
  RETURN new;
  END;$BODY$
    LANGUAGE plpgsql VOLATILE
    COST 100;
  ALTER FUNCTION notification.my_insert_trigger_function()
    OWNER TO serveradmin;
  </code></pre>