Search Postgresql Archives

Create recursive view schema.name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx  |                 -- Fortunato Depero, 1929.



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux