Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btrcf-0003ko-KA for pgsql-general@arkaria.postgresql.org; Tue, 11 Oct 2016 07:37:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1btrcf-0006hM-70 for pgsql-general@arkaria.postgresql.org; Tue, 11 Oct 2016 07:37:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btrce-0006gx-A9 for pgsql-general@postgresql.org; Tue, 11 Oct 2016 07:37:12 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1btrcX-0003aO-EA for pgsql-general@postgresql.org; Tue, 11 Oct 2016 07:37:11 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1btrcS-0004uk-SA for pgsql-general@postgresql.org; Tue, 11 Oct 2016 09:37:00 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: Lele Gaifax Subject: Create recursive view schema.name Date: Tue, 11 Oct 2016 09:36:37 +0200 Organization: Nautilus Entertainments Lines: 48 Message-ID: <871sznz69m.fsf@metapensiero.it> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cancel-Lock: sha1:gV1Ax4g42Fncnieqd+9kArWgb6Y= X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Hi all, I'm using PG 9.6, learning the "recursive" queries. I have a working recursive-CTE query, and I tried wrapping it in a view: reading the documentation I found the "CREATE RECURSIVE VIEW" form, so I tried it. It works as far as I use a "simple" name for the view: CREATE OR REPLACE RECURSIVE VIEW procedure_sites (procedure_id, site_id) AS SELECT pr.id, pr.site_id FROM sop.procedures pr JOIN sop.phases ph on ph.procedure_id = pr.id UNION ALL SELECT s.procedure_id, ss.site_id FROM procedure_sites s JOIN risk.company_sites ss ON ss.id = s.site_id WHERE ss.site_id IS NOT NULL; but I get an error when I create it in a specific schema: CREATE OR REPLACE RECURSIVE VIEW sop.procedure_sites (procedure_id, site_id) AS SELECT pr.id, pr.site_id FROM sop.procedures pr JOIN sop.phases ph on ph.procedure_id = pr.id UNION ALL SELECT s.procedure_id, ss.site_id FROM sop.procedure_sites s JOIN risk.company_sites ss ON ss.id = s.site_id WHERE ss.site_id IS NOT NULL; ERROR: relation "sop.procedure_sites" does not exist RIGA 8: JOIN sop.procedure_sites s ON s.site_id = ss.id ^ Am I missing something? Thanks in advance for any hint, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general