You are not logged in.
Hello,
I have a Table where the key consists of 2 fields. Prior
to adding a new record (am using batch insertion)
I'd like to check that no previous identical key exists.
So am looking for a quick way to test if the given 2 key values
already exist in the table.
I used a multiindex method to setup the index,
but instead of using validate I tried the following,
which does work, although it's a bit slow.
Is there a better way to do this?
Much obliged for any help.
Const QTS= '''';
Var
Tbl_Classe:TSQLRecordClass;
TableEssaie : TSQLmytbl;
parenth1, parenth2,
where_str :RawUTF8;
parenth1 := '=:(';
parenth2 := '):';
where_str := G_CRSTBL_INDEXES_Ar[0] + parenth1 +
QTS + TableEssaie.KeyField1 +QTS + parenth2 + ' AND ' +
G_CRSTBL_INDEXES_Ar[1] +parenth1 +
QTS + TableEssaie.KeyField2 + QTS + parenth2;
Tbl_Classe := model.Table[Tname];
If globalClient.MultiFieldValue(Tbl_Classe,
G_CRSTBL_INDEXES_Ar, Fld_vals,where_str) Then
Begin
Showmessage("Key violation!");
End
Else
globalClient.BatchAdd(TableEssaie, true);Hello,
Am getting a little bit the hang of this great framework
and was trying to add a couple of thousands of rows
to a simple stand alone application.
Seems though, that each row insertion is generating
a disk access and the whole process is quite slow,
at least 25 seconds/1000 rows.
The table has around 15 fields
and was using :
CourseId := StringToUTF8(Courseid_);
StudentId := StringToUTF8(StudentId_);
ID := globalClient.Add(myrec, true);Also tried swithing to the synBigTable but with D2009,
compiling the following example code gives an error
for the AddField, saying:
E2010 Incompatible types: 'TSynTableFieldProperties' and 'Boolean'
Var FieldText : TSynTableFieldProperties;
TableBig:TSynBigTableRecord;
BEGIN
TableBig := TSynBigTableRecord.Create('DB.big','Mytable');
FieldText := Table.AddField('text',tftWinAnsi,[tfoIndex]); // error!
...
END;Any ideas? Your help is much appreciated,
thanks, Sami
Hello,
Assuming the mybaby example in the documentation
was implemented so that Male babies go to a separate table
and Females to their own table.
Since both TSQLBabyMale and TSQLBabyFeMale
have a similar structure, one would like to write
generic code to add a baby to the correct
table depending on its gender.
However, in the call:
myBaby.add_Baby (myBaby, Name_,Address_,BirthDate_);the whole instance of the table, myBaby, is sent as a parameter.
Is this the way to do it?
Or am I missing something...
Much obliged for your kind help,
Sami
---
Here's the full simplified code:
TSQLBaby = class(TSQLRecord)
private
fName: RawUTF8;
fAddress: RawUTF8;
fBirthDate: TDateTime;
published
property Name: RawUTF8 read fName write fName;
property Address: RawUTF8 read fAddress write fAddress;
property BirthDate: TDateTime read fBirthDate write fBirthDate;
Procedure add_Baby (Const Name_,Address_:String;Const BirthDate_: TDateTime);
end;
TSQLBabyMale = class(TSQLBaby)
end;
TSQLBabyFeMale = class(TSQLBaby)
end;
Procedure TSQLBaby.add_Baby (Const myBaby:TSQLBaby;
Const Name_,Address_:String;Const BirthDate_: TDateTime);
BEGIN
myBaby.Name: := Name_;
myBaby.Address: := Address_;
// now can add record
globalClient.Add(myBaby, true);
END;
Procedure add_new_baby (Const Gender_, Name_,Address_:String;Const BirthDate_: TDateTime);
Var
myBaby :TSQLBaby ;
BEGIN
If Gender ='Male' Then
myBaby := TSQLBabyMale
Else
myBaby := TSQLBabyFeMale;
myBaby.add_Baby (myBaby, Name_,Address_,BirthDate_);
FreeAndNil(myBaby);
END;Hello,
This Framework looks great! Downloaded latest source,
run the TestProject, only 1 failure in Pdf module which
I figure was minor.
However, when running 'MainDemo' on D2009 (Win XP)
get an access violation in unit SQLite3ToolBar, traced to line 2476, where the error occurs on the 2nd pass
of the loop:
---
for aPage := 0 to PagesCount-1 do begin
if TP^.CustomHint<>nil then // error! ---------------
So the stmt:
if TP^.CustomHint<>nil then
seems to fail the 2nd time it's executed.
Thanks for any help,
Regards Sami