📄 dbiopenvchklist.html
字号:
<HTML>
<HEAD>
<TITLE>BDE API Examples (DbiOpenVChkList)</TITLE>
<META NAME="KEYWORDS" CONTENT="BDE, Borland">
<META NAME="DESCRIPTION" CONTENT="">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000000" ALINK="#999999" VLINK="#666666">
<CENTER>
<TABLE CELLPADDING="4" CELLSPACING="4" BORDER="0" WIDTH="600">
<TR>
<TD ALIGN="CENTER" VALIGN="TOP" COLSPAN="1"><NOBR><A HREF="/"><IMG SRC="/images/bolus.gif" ALT="[View Borland Home Page]" BORDER="0"></A><A HREF="/products.html"><IMG SRC="/images/products.gif" ALT="[View Product List]" BORDER="0"></A><A HREF="/searchsite/"><IMG SRC="/images/search.gif" ALT="[Search This Web Site]" BORDER="0"></A><A HREF="/download.html"><IMG SRC="/images/downloads.gif" ALT="[View Available Downloads]" BORDER="0"></A><A HREF="/membership.html"><IMG SRC="/images/membership.gif" ALT="[Join Borland Online]" BORDER="0"></A><A HREF="/newsgroups/"><IMG SRC="/images/newsgroups.gif" ALT="[Enter Discussion Area]" BORDER="0"></A><A HREF="/feedback/"><IMG SRC="/images/feedback.gif" ALT="[Send Email To Webmaster]" BORDER="0"></A></NOBR></TD>
</TR>
<TR>
<TR><TD ALIGN="LEFT" VALIGN="TOP" COLSPAN="1"><font size=2>
<h2>BDE API Examples (DbiOpenVChkList)</h2>
Creates an in-memory table containing records with information about validity
checks for fields within the specified table.
<hr size=2 noshade>
<H3>Return all validity check information for a specific field</H3>
This example uses the following input:<BR> <I>HasVChk(Table1, Table1.Fields[0], VChk);</I><BR>
TChk is defind as follows:
<PRE>TVChk = record
Required, HasDefault, HasMin, HasMax: boolean;
DefValue, MinValue, MaxValue: string;
end;</PRE>
If a validity check exists on the specified field, the function returns TRUE. If the function
returns TRUE then the information in TVChk will return specific validity check information.<BR>
The function is defined as follows:
<PRE>function HasVChk(Table: TTable; Field: TField; var VChk: TVChk): boolean;
function ValToStr(VCHK: DBIVCHK; FldType: word): string;
var
L: longint;
I: Integer;
D: Double;
MyDate: BDE.DBIDATE;
MyTime: BDE.Time;
Hour, Minute, MSecond: Word;
MyTS: BDE.TimeStamp;
W1: word;
Month, Day: word;
Year: Smallint;
begin
case FldType of
fldZSTRING: Result := PChar(@VCHK);
fldFLOAT:
begin
Move(VCHK, D, sizeof(D));
Result := FloatToStr(D);
end;
fldINT32, fldUINT32:
begin
Move(VCHK, L, sizeof(L));
Result := IntToStr(L);
end;
fldINT16:
begin
Move(VCHK, I, sizeof(I));
Result := IntToStr(I);
end;
fldUINT16:
begin
Move(VCHK, W1, sizeof(W1));
Result := IntToStr(W1);
end;
fldDATE:
begin
Move(VCHK, MyDate, sizeof(MyDate));
if MyDate < 0 then
Result := 'TODAY'
else
begin
Check(DbiDateDecode(MyDate, Month, Day, Year));
Result := Format('%d/%d/%d', [Month, Day, Year]);
end;
end;
fldTIME:
begin
Move(VCHK, MyTime, sizeof(MyTime));
if MyTime < 0 then
Result := 'NOW'
else
begin
Check(DbiTimeDecode(MyTime, Hour, Minute, MSecond));
if Hour < 12 then
Result := Format('%d:%d:%d AM', [Hour, Minute, MSecond div 1000])
else
Result := Format('%d:%d:%d PM', [Hour - 12, Minute, MSecond div 1000]);
end;
end;
fldTIMESTAMP:
begin
Move(VCHK, MyTS, sizeof(MyTS));
if MyTS = 0 then
Result := 'NOW'
else
begin
Check(DbiTimeStampDecode(MyTS, MyDate, MyTime));
Check(DbiDateDecode(MyDate, Month, Day, Year));
Check(DbiTimeDecode(MyTime, Hour, Minute, MSecond));
if Hour < 12 then
Result := Format('%d/%d/%d @ %d:%d:%d AM',
[Month, Day, Year, Hour, Minute, MSecond div 1000])
else
Result := Format('%d/%d/%d @ %d:%d:%d PM',
[Month, Day, Year, Hour - 12, Minute, MSecond div 1000]);
end;
end;
end;
end;
var
Props: CURProps;
V: VCHKDesc;
hCur: hDBICur;
pField: pFLDDesc;
begin
Result := False;
Check(DbiGetCursorProps(Table.Handle, Props));
if Props.iValChecks > 0 then
begin
Check(DbiOpenVChkList(Table.DBHandle, PChar(Table.TableName),
Props.szTableType, hCur));
pField := AllocMem(Props.iFields * sizeof(FLDDesc));
try
while DbiGetNextRecord(hCur, dbiNOLOCK, @V, nil) = DBIERR_NONE do
begin
if V.iFldNum = Field.Index + 1 then
begin
Result := true;
VChk.Required := V.bRequired;
VChk.HasDefault := V.bHasDefVal;
VChk.HasMin := V.bHasMinVal;
VChk.HasMax := V.bHasMaxVal;
Check(DbiGetFieldDescs(Table.Handle, pField));
Inc(pField, Field.Index);
if VChk.HasDefault = TRUE then
VChk.DefValue := ValToStr(V.aDefVal, pField^.iFldType);
if VChk.HasMin = TRUE then
VChk.MinValue := ValToStr(V.aMinVal, pField^.iFldType);
if VChk.HasMax = TRUE then
VChk.MaxValue := ValToStr(V.aMaxVal, pField^.iFldType);
Dec(pField, Field.Index);
end;
end;
finally
FreeMem(pField);
Check(DbiCloseCursor(hCur));
end;
end;
end;</PRE>
<hr size=2 noshade>
<p>
<A HREF="/devsupport/bde/bdeapiex/index.html">Back to BDE API Reference Page</A>
</TD></TR>
<TR><TD ALIGN="LEFT" VALIGN="TOP" COLSPAN="1"><font size=2>
<HR SIZE="2" NOSHADE>
<FONT SIZE = 2><i><b>DISCLAIMER:</b> You have the right to use this technical information subject to
the terms of the No-Nonsense License Statement that you received with the Borland product to which
this information pertains.</FONT></i></B>
</dl>
</td>
</TR>
<TR>
<!-- THIS IS THE BOTTOM COPYRIGHT & UPDATED MESSAGE -->
<TD ALIGN="CENTER" VALIGN="TOP" COLSPAN="3"><FONT SIZE="2"><A HREF="/copyright.html">Trademarks & Copyright</A> © 1998 Borland International, Inc.
<SCRIPT LANGUAGE="JavaScript">
<!-- HIDE FROM OLD BROWSERS
// THIS WILL WRITE OUT THE LAST MODIFIED DATE
// YOU DO NOT NEED TO CHANGE ANYTHING HERE
function makeArray(arraySize) {
this.length = arraySize
return this
}
monthNames = new makeArray(12)
monthNames[1] = "January"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"
updated = new Date(document.lastModified)
theMonth = monthNames[updated.getMonth() + 1]
theDate = updated.getDate()
theYear = updated.getYear() + 1900
document.write("Last modified on " + theDate + "-" + theMonth + "-" + theYear + ".")
// END HIDING -->
</SCRIPT></FONT></TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -