🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #4946

Re: How to find if a table column is null allowed or not ?

#4946
From: Harold Howe (TeamB)
Date: Tue, 04 Sep 2001 16:00
77 lines
5139 bytes
> I am using Microsoft SQL Server 2000 and Oracle 8i (8.1.6). For SQL server
I
> am using the OLEDB driver that came with MDAC2.6 and for Oracle I am using
> OLEDB driver provided by Oracle.

Since you are using OLEDB in both cases (guess I could have deduced that
from the fact that you are posting in the .ado group), then maybe you could
go directly to the OLEDB driver and ask it? I think this is a dead end, but
it might be worth investigating.

> Do I have to use the system tables specific to the respective database, to
> get this info ?
> In that case, what is the meaning of the following two properties ??
> (1) TDataSet->FieldDefList->FieldDefs[i]->Required
> (2) TDataSet->FieldDefList->FieldDefs[i]->Attributes.Contains(faRequired)

To simplify, you are really asking what is the purpose of
TFieldDef::Required (and also TField::Required) and why aren't they being
set correctly based on the schema of your tables. I will hazard a guess (but
it is only a guess). FieldDef's are typically used to create new persistent
fields in code, or to add fields to a table or clientdatset. Here, you would
set Required from your code, as opposed to having it read in for you.

Now to answer the question of why Required isn't being set for you based on
the table schema. My guess is that when you open and ADO dataset, the
information needed to determine the value of required is not available, so
the VCL sets it to false.

Think about the flow of control in calculating the required property. First
you have the generic VCL dataset code (TDataSet's, TField's, and
TFieldDef's). These database classes are generic, and are used for ADO, the
BDE, interbase express classes, and midas (TClientDataset). Then you have
the VCL ADO classes that talk directly to Microsoft's ADO COM objects.
Microsoft's ADO objects talk to the OLEDB provider you have chosen, and the
OLEDB provider talks directly (usually) to the backend database server. In
all, it looks like this

VCL(generic)->VCL(ado specific)->ADO COM->OLEDB->database server

So why isn't Required being set? Where is the weak link in the chain? Let's
start at the far right with the database server. Do we know that both Oracle
and SQL Server allow you to determine whether a field is required? I am
pretty confident that SQL server does, because you could query the system
tables if you had to. I don't know about oracle, but I will assume that it
does.

Now you have to look at the OLEDB provider. OLEDB is a complicated mess of
hundreds of different COM interfaces. Does one of those interfaces allow you
to inspect whether a field is required or not? This I don't know. If such an
interface does exist, do both the Oracle and the SQL server OLEDB providers
implement this interface correctly? Again I don't know. Some pretty big
unknowns.

Now we get to the ADO layer. Assuming that the OLEDB layer allows you to
figure out whether a field is required or not, does ADO provide a way to
propagate this information up when you perform a query? Again I don't know
(hmmm, I seem to be saying that a lot, maybe you should take my advice with
a grain of salt).

Finally, we arrive at the VCL. Since the VCL field and fielddef classes are
generic to many database engines(ADO, BDE, etc), it is conceivable that some
features may be available to one engine that is not available to another.
For example, the BDE may allow you to read whether a field is required, but
ado may not. In this case, TFieldDef::Required would work for the BDE, but
be meanlingless for ADO.

So where are we know? My best guess is that based on the database engine
that you have chosen (ADO) and the type of query you are running, the VCL is
unable to figure out what Required should be. FWIW, I tested a TTable with a
oracle table through the BDE SQL links driver, and the required property of
the field defs seemed to be set correctly!

Sorry if this isn't of much use to you.

Harold Howe [TeamB]
http://www.bcbdev.com
Technical Details
Message-ID: <3b94fa67$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.frii.net!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!news-in-austin.nuthinbutnews.com!intgwlon.nntp.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3b88fdf0$1_2@dnews> <3B8EFF8B.F6DF5A90@bcbdev.com> <3b90c9bc$1_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,15569c6db2db3bc8
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2001-09-04 09:02:48 PST
From: "Harold Howe \(TeamB\)" <hhowe@bcbdev.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3b88fdf0$1_2@dnews> <3B8EFF8B.F6DF5A90@bcbdev.com> <3b90c9bc$1_1@dnews>
Subject: Re: How to find if a table column is null allowed or not ?
Date: Tue, 4 Sep 2001 11:00:08 -0500
Lines: 79
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 12.152.193.134
Message-ID: <3b94fa67$1_2@dnews>
X-Trace: dnews 999619175 12.152.193.134 (4 Sep 2001 08:59:35 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!sn-xit-03!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.frii.net!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!news-in-austin.nuthinbutnews.com!intgwlon.nntp.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews