Sample Create table
<< Click to Display Table of Contents >>
Sample Create table
|
|
Purpose
Sample Create table
Description
This sample shows how to create a Btrieve table with its indexes
Example(s)
FUNCTION Start
LOCAL cFields
LOCAL cIndexes
LOCAL oServer AS BtServer
LOCAL i, oErr
BEGIN SEQUENCE
// "xxxx5xxxx0xxxx5xxxx0
// "FFFFFFFFFFFFFFFFFFFFXXbbbDMNQSU;
cFields := "NUMBER NI00004.00 ;" + ;
"LNAME C 00030.00 ;" + ;
"FNAME C 00010.00 ;" + ;
"ADDRESS C 00040.00 ;" + ;
"ZIP_CODE C 00010.00 ;" + ;
"CITY C 00040.00 ;" + ;
"COUNTRY C 00030.00 ;" +;
"DATE D 00004.00 ;" +;
"TIME CT00004.00 ;" +;
"STRINGZ CZ00010.00 ;" +;
"STRINGL CL00010.00 ;" +;
"NUM1 N+00004.00 ;" +;
"NUM2 NU00004.00 ;" +;
"NUM3 NP00008.02 ;" +;
"NUM4 N$00008.02 ;" +;
"NUM5 NF00008.02 ;" +;
"NUM6 NS00008.02 ;" +;
"NUM7 NA00008.02 ;" +;
"NOTES M 01024.00 ;"
cIndexes := "NUMBER XX dmnQSu;" + ;
"LNAME XX dMnqsu;" + ;
"FNAME XX dMnqsu;" + ;
"DATE XX dMnqsu;" +;
"TIME XX dmnqsu;" +;
"STRINGL XX dmnQsu;" +;
"STRINGZ XX dmnqsu;" +;
"NUM1 XX dmnQsu;" +;
"NUM2 XX dmnqsu;" +;
"NUM3 XX dmnqsu;" +;
"NUM4 XX dmnqsu;" +;
"NUM5 XX dmnqsu;" +;
"NUM6 XX dmnqsu;" +;
"ZIP_CODE XX dmNqsu;"
if ! Bt_Create("d:.btr", cFields, cIndexes,0,4096)
? Bt_ErrorMsg()
Break
Endif
oServer := BtServer"D:.btr", cFields, BFM_NORMAL
oServer:SetOwner("Roberto",3)
FOR i = 1 TO 10
oServer:Append()
oServer:FieldPut(#Number,i)
oServer:FieldPut(#Num1,i)
oServer:FieldPut(#Num2,i)
oServer:FieldPut(#Num3,i)
oServer:FieldPut(#Num4,i)
oServer:FieldPut(#Num5,i)
oServer:FieldPut(#Num6,i)
oServer:FieldPut(#Num7,i)
oServer:FieldPut(#ADDRESS, "Address "+Str(i,2))
oServer:FieldPut(#ZIP_CODE, "Zip "+Str(i,2))
oServer:FieldPut(#STRINGZ, "SZ "+Str(i,2))
oServer:FieldPut(#STRINGL, "SL "+Str(i,2))
oServer:FieldPut(#LNAME , "Lname "+Str(i,2))
oServer:FieldPut(#FNAME , "Fname "+Str(i,2))
oServer:FieldPut(#DATE , Today()+i)
oServer:FieldPut(#Notes , Repl("X", i*10))
oServer:Commit()
NEXT
oServer := BtServer"D:.btr", cFields, BFM_NORMAL,"Roberto"
oServer:GoTop()
DO WHILE ! oServer:Eof
FOR i := 1 TO oserver:Fcount
?? oServer:FieldGet(i),""
NEXT
oServer:Skip(1)
ENDDO
oServer:GoBottom()
oServer:Close()
END
wait