views:

313

answers:

4

I want my C# program to know if the notNULL constraint is set for a specific Firebird database column. Can it be checked dynamically, perhaps by querying the meta data? I find the Firebird documentation to be very sparse.

Also, how does Firebird provide information what columns exist in a specific table?

A: 

Ok, didn't find it by using Stackoverflow's internal search, but by changing keywords in Google: How to check if NOT NULL constraint exists

Norbert
Solution recommended in answers to that question would work with MS Sql Server, _not_ Firebird.
ib
A: 

Here is a Firebird Null Guide

http://www.firebirdsql.org/manual/nullguide.html

drorhan
That guide does not describe how to determine whether column has NULL-constraint or not.
ib
+1  A: 

You need to request Firebird metadata about constraints — all information about it is stored in system tables. For example how to do that look at this page: http://www.alberton.info/firebird_sql_meta_info.html (see "List CONSTRAINTs" section).

ib
The information in the link is good, however your answer would be much better if you copied the parts about `NULL` constraints and getting table columns into it. That would be in the spirit of SO, which aims to be more than a collection of (possibly outdated) links.
mghie
A: 

To do it manually, use the following statement:

select rdb$null_flag
from rdb$relation_fields
where rdb$relation_name = 'MyTable' and rdb$field_name = 'MyField'

Alternatively you may try exploring FbDataReader.GetSchemaTable().

Douglas Tosi