Buenos dias:

On Wed, Apr 13, 2016 at 12:33 AM, mauricio pullabuestan
<jmaurici...@yahoo.es> wrote:
> Necesito crear un campo en todas que no tengan un campo en concreto para ello 
> tengo 2 funciones, el problema se da es que la funcion
> campo_check_fnc me devuelve también las vista y se produce un error.
> Como puedo fitrar que solo me devuelva tablas.

Asi por encima tu problema parece ser que seleccionas de donde no
debes ( o para ser exacto no seleccionas de todos los sitios donde
debes ):

>  SELECT table_schema, table_name
>   FROM information_schema.columns
...
>        SELECT table_schema, table_name, column_name = 'mi_campo' As 
> existe_campo
>         FROM information_schema.columns
...

Si vas a las docs veras ( lo siento, en ingles, no se donde estan las
docs en español ):

http://www.postgresql.org/docs/9.5/static/infoschema-columns.html

34.16. columns

The view columns contains information about all table columns (or view
columns) in the database. System columns (oid, etc.) are not included.
Only those columns are shown that the current user has access to (by
way of being the owner or having some privilege).

Prueba a hacer un join con tables para coger solo las tablas:

http://www.postgresql.org/docs/9.5/static/infoschema-tables.html

34.52. tables

The view tables contains all tables and views defined in the current
database. Only those tables and views are shown that the current user
has access to (by way of being the owner or having some privilege).
....
table_type - character_data - Type of the table: BASE TABLE for a
persistent base table (the normal table type), VIEW for a view,
FOREIGN TABLE for a foreign table, or LOCAL TEMPORARY for a temporary
table

( Podrias probar a hacer un not exists o u nouter join filtrado con
views, pero creo que tables.table_type te dara mejor resultado ya que
te permite decidir que hacer con las FOREIGN TABLE y/o TEMPORARY TABLE
).


Fancisco Olarte.

-
Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda@postgresql.org)
Para cambiar tu suscripci�n:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

Responder a