Re: check if column is NULL (php)

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Robert Wimmer <seppwimmer(at)hotmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: check if column is NULL (php)
Date: 2004-12-12 01:17:24
Message-ID: 20041212011724.GA43147@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sat, Dec 11, 2004 at 10:51:08PM +0000, Robert Wimmer wrote:

> the question i have is : is it possible to check in a resultSet - as a
> result of pg_query("SELECT ...") - if a column in this result can be set to
> NULL.
>
> important : it should work with any select statement - if i use only one
> table in the select, i know that i could use pg_meta_data.
>
> i need this for a existing formular generator, which works fine, but i cant
> check if NULL values are allowed in this form if i dont know it.

If PHP provides constraint metadata for queries then I'm not aware
of it. If you want to know about a table's constraints then you'll
have to get them in a separate query (call pg_meta_data(), query
the PostgreSQL system catalogs, etc.).

An API that provides constraint metadata will have to explictly
query for it, although this could be made transparent to the
programmer. The PostgreSQL protocol doesn't provide constraint
metadata in the RowDescription message, which is what describes the
field names and types in the subsequent DataRow messages (see the
"Frontend/Backend Protocol" chapter in the PostgreSQL documentation
for details).

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Keith Worthington 2004-12-12 03:09:10 Re: can't set sequence
Previous Message Robert Wimmer 2004-12-11 22:51:08 check if column is NULL (php)