use a loop to get the output of an EXECUTE
authorMike Rylander <miker@esilibrary.com>
Fri, 20 Mar 2009 14:55:47 +0000 (14:55 +0000)
committerMike Rylander <miker@esilibrary.com>
Fri, 20 Mar 2009 14:55:47 +0000 (14:55 +0000)
sql/base/base_migration_schema_procs.sql

index 391e83e..ae20943 100644 (file)
@@ -22,8 +22,13 @@ INSERT INTO migration_tools.config (key,value) VALUES ( 'production_tables', 'as
 CREATE OR REPLACE FUNCTION migration_tools.production_tables (TEXT) RETURNS TEXT[] AS $$
     DECLARE
         migration_schema ALIAS FOR $1;
+        output  RECORD;
     BEGIN
-        EXECUTE 'SELECT string_to_array(value,'','') FROM ' || migration_schema || '.config WHERE key = ''production_tables'';';
+        FOR output IN
+            EXECUTE 'SELECT string_to_array(value,'','') AS tables FROM ' || migration_schema || '.config WHERE key = ''production_tables'';'
+        LOOP
+            RETURN output.tables;
+        END;
     END;
 $$ LANGUAGE PLPGSQL STRICT STABLE;