Board index » delphi » changing "not null" status of fields

changing "not null" status of fields

I have seen some posts which state that some people believe you cannot
adjust the not null property of a field.  Am I missing something or is it
done like this:

update rdb$relation_fields
  set rdb$null_flag = 1
where rdb$relation_name = 'TABLENAME' and
          rdb$field_name = 'FIELDNAME'

I pirated the idea from studying the sqlmonitor in EMS quickdesk to find out
how they did it.

I just wish I could change the rdb$default_source column the same way :-)

 

Re:changing "not null" status of fields


Hi Josh,

it is not completely done like this...

Yes, setting the NOT NULL flag can be done like this, but changing a NOT
NULL to NULL for the first time (that is, it is defined as COLUMNAME
DATATYPE NOT NULL) cannot be done as easily...

For some reason, IB creates an entry in the RDB$RELATION_CONSTRAINTS table
with constraint type NOT NULL ... This constraint needs to be dropped too.

--
Martijn Tonies
Upscene Productions

InterBase Workbench - The Developer Tool for InterBase
http://www.interbaseworkbench.com

"Experience is what you get when you didn't get what you wanted"

Quote
> I have seen some posts which state that some people believe you cannot
> adjust the not null property of a field.  Am I missing something or is it
> done like this:

> update rdb$relation_fields
>   set rdb$null_flag = 1
> where rdb$relation_name = 'TABLENAME' and
>           rdb$field_name = 'FIELDNAME'

> I pirated the idea from studying the sqlmonitor in EMS quickdesk to find
out
> how they did it.

> I just wish I could change the rdb$default_source column the same way :-)

Other Threads