Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 2AD092F4276 for ; Wed, 21 Mar 2012 05:58:37 -0300 (ADT) Received: from news.hub.org ([200.46.204.72]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SAHNM-0002DJ-0A for pgsql-sql@postgresql.org; Wed, 21 Mar 2012 08:58:36 +0000 Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id q2L8wNew095667 for ; Wed, 21 Mar 2012 05:58:23 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id q2L8iOYx085434 for pgsql-sql@postgresql.org; Wed, 21 Mar 2012 05:44:24 -0300 (ADT) (envelope-from news) From: Bear X-Newsgroups: pgsql.sql Subject: Problem with inserting data produced by the function (when the function is performed). Date: Wed, 21 Mar 2012 01:30:45 -0700 (PDT) Organization: http://groups.google.com Lines: 49 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Complaints-To: groups-abuse@google.com Complaints-To: groups-abuse@google.com Injection-Info: r27g2000vbn.googlegroups.com; posting-host=212.33.81.250; posting-account=phv_zwoAAADWlIItqWRLEQipwamV29aK User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,gzip(gfe) To: pgsql-sql@postgresql.org X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/63 X-Sequence-Number: 36458 The function calculates the data line by line, and inserts into the table, at the end of the function I need to send data from a table to another database via dblink. I noticed that the problem is to perform this operation in one function (or the main function of the two subfunction). My guess is that unless the function has finished running postgres no data dumps. Data is available in the table after the function finished, and I can send them without a problem. The operation must be done in one function or the main function and two of subfunction (first subfunction loads the data into a table, second subfunction sends data to another database via dblik). How to force a permanent record of data in a table when executing the function? Sample code: ------------------------------ CREATE OR REPLACE FUNCTION filter_reports_yesterday() RETURNS void AS $BODY$declare target_table_name varchar; res record; cr cursor for select distinct substr(tablename, 0, position('_row' in tablename)) as adr_sym from pg_tables where tablename like '%_row' and schemaname = 'arch_'|| to_char((current_date-1),'YYYY_MM'); al_cr refcursor; begin for res in cr loop --first subfunction generating data in table execute 'select packet_filter_yesterday('''||(current_date-1)||''', '''||res.adr_sym||''')'; target_table_name := 'rap_' || to_char((current_date-1),'YYYY_MM') || '.' || res.adr_sym || '_fil'; --second function inserting data from table to another database via dblink execute 'select insert_FS3('''||target_table_name||''')'; end loop; end$BODY$ LANGUAGE plpgsql ------------------------------ When doing the first function (for a single table, no loops) and after the second run separately the data is sent. When both feature walk in a loop in main function is the result of lack of data. thanks in advance