Osvaldo Kussama escreveu:
> Alguém pode tentar dar uma luz no que eu não estou conseguindo enxergar?
>
> bdteste=# SELECT 1::smallint <> ALL (ARRAY[2::smallint, 3::smallint,
> 4::smallint]);
>  ?column?
> ----------
>  t
> (1 registro)
>
> bdteste=# SELECT conkey FROM pg_constraint WHERE conrelid = (select
> oid from pg_class where relname = 'teste') AND contype = 'p';
>  conkey
> --------
>  {1}
> (1 registro)
>
> bdteste=# SELECT pa.attname FROM pg_attribute pa
> bdteste-#  where pa.attrelid = (select pc.oid from pg_class pc where
> pc.relname = 'teste')
> bdteste-#    and pa.attnum > 0
> bdteste-#    and pa.attnum <> ALL (SELECT pco.conkey FROM
> pg_constraint pco WHERE pco.conrelid = pa.attrelid AND pco.contype =
> 'p');
> ERRO:  operador não existe: smallint <> smallint[]
> DICA:  Nenhum operador corresponde com o nome e o(s) tipo(s) de
> argumento(s) informados. Você precisa adicionar conversões de tipo
> explícitas.
>
> De "Table 44-13. pg_constraint Columns":
> conkey        int2[]
>
> Osvaldo
> PS: quero a relação de atributos não integrantes da chave primária.
> _______________________________________________
> pgbr-geral mailing list
> [email protected]
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>
>
>   
Bom dia Osvaldo,

Utilize da seguinte forma: (deve funcionar)

SELECT
    pa.attname
FROM
    pg_attribute pa
where
    pa.attrelid = (select pc.oid from pg_class pc where pc.relname = 
'teste')
and
    pa.attnum > 0
and
    array[pa.attnum] <> ALL (SELECT pco.conkey FROM pg_constraint pco 
WHERE pco.conrelid = pa.attrelid AND pco.contype = 'p');

Abraço!!!

-- 
Luiz Henrique Livrari
Implantador de Sistemas Jr.
MSI SOLUÇÕES - Unidade Ourinhos
Av. Dr. Altino Arantes, 131 Sala 145 - 146
Centro - Ourinhos/SP - Brasil
Fone/Fax: +55 (14) 3324-8181
www.msisolucoes.com.br

_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a